import { EventEmitter } from "events"; import { Writable } from "stream"; import { Chalk } from "chalk"; export interface Options { write?: (log: string) => void; levels?: LevelMap; format?: FormatterMap; level?: string; priority?: number; colors?: boolean; displayPrefix?: boolean; traceErrors?: boolean; inspectDepth?: number; } export interface Level { priority?: number; alias?: string | string[]; display?: string | ((this: Logger) => any); } export interface LevelMap { [key: string]: Level; } export type Formatter = (this: Logger, ...args: any[]) => any; export interface FormatterMap { [key: string]: Formatter; } export type Plugin = (this: Logger, logger: Logger) => any; export interface PrefixedLogger { (...args: any[]): string; prefixed: string; logger: Logger; // default logging levels error(...args: any[]): this; warn(...args: any[]): this; info(...args: any[]): this; debug(...args: any[]): this; verbose(...args: any[]): this; silly(...args: any[]): this; // progress methods enableProgress(stream?: Writable): this; disableProgress(): this; startProgress(): this; progress(section: string, completed?: number): this; pulse(...args: any[]): this; endProgress(): this; } export class Logger extends EventEmitter { public static isLogger(l: any): l is Logger; public options: Options; public levels: LevelMap; public color: Chalk; public priorities: string[]; public priority: number; public level: string; constructor(opts?: Options); public use(fn?: Plugin | Plugin[]): this; public addLevel(levels: LevelMap): this; public addLevel(name: string, spec: Level): this; public priorityToLevel(priority: number): string | undefined; public levelToPriority(level: string): number | undefined; public toLevel(levelOrPriority?: string | number): string | undefined; public toPriority(levelOrPriority?: string | number): number | undefined; public hasPriority(levelOrPriority: string | number): boolean; public write(log: string): void; public format(type: string, ...args: any[]): any; public printf(levelOrPriority: string | number, prefix: string, ...args: any[]): this; public sprintf(levelOrPriority: string | number, prefix: string, ...args: any[]): string; public prefix(prefix: string): PrefixedLogger; // default logging levels public error(prefix: string, ...args: any[]): this; public warn(prefix: string, ...args: any[]): this; public info(prefix: string, ...args: any[]): this; public debug(prefix: string, ...args: any[]): this; public verbose(prefix: string, ...args: any[]): this; public silly(prefix: string, ...args: any[]): this; // progress methods public enableProgress(stream?: Writable): this; public disableProgress(): this; public startProgress(): this; public progress(prefix: string, section: string, completed?: number): this; public pulse(...args: any[]): this; public endProgress(): this; } export interface ProgressOptions { stream?: Writable; guage?: object; enabled?: boolean; } export function progress(opts?: ProgressOptions): Plugin; export const globalLevel: string; declare const log: Logger; export default log;