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
46 lines • 1.89 kB
TypeScript
import { LogEntry } from '../logger.js';
import { Transform } from '../transform.js';
import * as ansi from '@bevry/ansi';
/** A mapping of log level numbers to their intended colours */
interface LevelsToColorsMap {
[logLevelNumber: string]: ansi.ANSIApplier;
}
/** Configuration options for the Caterpillar Human Transform */
export interface HumanOptions {
/** Use to override the default value of {@link Human.color} */
color?: boolean;
/** Use to override the default value of {@link Human.colors} */
colors?: LevelsToColorsMap;
}
/**
* Convert Logger entries into human readable format.
* @extends Transform
* @example
* ``` javascript
* import { Logger, Human } from 'caterpillar'
* const logger = new Logger()
* const human = new Human()
* logger.pipe(human).pipe(process.stdout)
* logger.log('info', 'some', {data: 'oh yeah'}, 42)
* ```
*/
export declare class Human extends Transform {
/** Whether or not to use colors? */
color: boolean;
/** Mapping of which log level numbers correspond to which colours */
colors: LevelsToColorsMap;
/** Create our instance and apply our configuration options. */
constructor(opts?: HumanOptions);
/** Get the color for the log level */
getColor(levelNumber: number): ansi.ANSIApplier | false;
/** Pad the left of some content if need be with the specified padding to make the content reach a certain size */
padLeft(padding: string, size: number, content: string | number): string;
/** Convert logger entry arguments into a human readable string */
formatArguments(args: any[]): string;
/** Convert a datetime into a human readable format */
formatDate(datetime: Date | number | string): string;
/** Convert a logger entry into a human readable format */
format(entry: LogEntry): string;
}
export default Human;
//# sourceMappingURL=human.d.ts.map