UNPKG

typescript-log

Version:

Logger interface with a few simple implementations, interface compatible with pino, bunyan and probably others

33 lines (32 loc) 1.05 kB
export declare type Levels = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace'; export interface LogObject { [key: string]: any; } export interface ErrorObject extends LogObject { err?: Error; } export interface Logger { trace(msg: string | LogObject): void; trace(obj: LogObject, msg: string): void; debug(msg: string | LogObject): void; debug(obj: LogObject, msg: string): void; info(msg: string | LogObject): void; info(obj: LogObject, msg: string): void; warn(msg: string): void; warn(obj: LogObject, msg: string): void; error(msg: string): void; error(obj: ErrorObject, msg: string): void; fatal(msg: string): void; fatal(obj: ErrorObject, msg: string): void; child(childObj: LogObject): Logger; } export declare function noopLogger(): { trace: () => void; debug: () => void; info: () => void; warn: () => void; error: () => void; fatal: () => void; child: () => any; }; export declare function consoleLogger(level?: Levels, context?: LogObject): Logger;