caterpillar
Version:
Caterpillar is the ultimate logging system for Deno, Node.js, and Web Browsers. Log levels are implemented to the RFC standard. Log entries can be filtered and piped to various streams, including coloured output to the terminal, the browser's console, and
42 lines • 2.03 kB
TypeScript
/**
* Caterpillar supports piping to anything that supports this interface.
* Which includes:
* - {@link Transform Caterpillar Transforms}
* - [Deno Writer Streams](https://doc.deno.land/https/github.com/denoland/deno/releases/latest/download/lib.deno.d.ts#Deno.Writer), e.g.
* - [Deno.stdout](https://doc.deno.land/https/github.com/denoland/deno/releases/latest/download/lib.deno.d.ts#Deno.stdout)
* - [Node.js Writable Streams](https://nodejs.org/dist/latest-v14.x/docs/api/stream.html#stream_writable_streams), e.g.
* - [process.stdout](https://nodejs.org/dist/latest-v14.x/docs/api/process.html#process_process_stdout)
* - [fs.createWriteStream](https://nodejs.org/dist/latest-v14.x/docs/api/fs.html#fs_fs_createwritestream_path_options)
* - [WhatWG Writable Streams](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream)
*/
export interface Pipeable {
write(chunk: any): any;
end?(cb?: () => void): void;
close?(): Promise<void> | void;
}
/**
* Caterpillar Transform Class.
* Provides the methods needed to provide a pipable Caterpillar Transform.
* Such that all you need to do is write your {@link Transform.format} method.
* It can pipe to anything that provides a {@link Pipeable.write} method.
* @example [Writing a Custom Transform](https://repl.it/@balupton/caterpillar-custom-transform)
*/
export declare class Transform implements Pipeable {
/** Where is this Transform piping to? */
private pipes;
/**
* Format the received log entry representation.
* Your transformer should extend this.
*/
format(message: any): any;
/** Pipe future log entries into a caterpillar transform or a stream. */
pipe<T extends Pipeable>(to: T): T;
/** Maintain a write queue such that multiple Deno writes do not stall */
private writer;
/** Write to the child pipes. */
write(chunk: any): Promise<void>;
/** Close the child pipes. */
close(): Promise<void>;
end(cb?: () => void): void;
}
//# sourceMappingURL=transform.d.ts.map