UNPKG

2.83 kBTypeScriptView Raw
1/// <reference types="node" />
2
3import { EventEmitter } from "events";
4
5declare namespace npmlog {
6 // TODO: newStream, newGroup, setGaugeTemplate and setGaugeTemplateSet need to be added
7 interface Logger extends EventEmitter {
8 (): any;
9
10 level: string;
11 record: MessageObject[];
12 maxRecordSize: number;
13 prefixStyle: StyleObject;
14 headingStyle: StyleObject;
15 heading: string;
16 stream: any; // Defaults to process.stderr
17
18 /**
19 * Creates a log message
20 * @param level
21 * @param prefix
22 * @param message message of the log which will be formatted using utils.format()
23 * @param args additional arguments appended to the log message also formatted using utils.format()
24 */
25 log(level: LogLevels | string, prefix: string, message: any, ...args: any[]): void;
26
27 /**
28 * @param prefix
29 * @param message message of the log which will be formatted using utils.format()
30 * @param args additional arguments appended to the log message also formatted using utils.format()
31 */
32 silly(prefix: string, message: any, ...args: any[]): void;
33 verbose(prefix: string, message: any, ...args: any[]): void;
34 info(prefix: string, message: any, ...args: any[]): void;
35 timing(prefix: string, message: any, ...args: any[]): void;
36 http(prefix: string, message: any, ...args: any[]): void;
37 notice(prefix: string, message: any, ...args: any[]): void;
38 warn(prefix: string, message: any, ...args: any[]): void;
39 error(prefix: string, message: any, ...args: any[]): void;
40 silent(prefix: string, message: any, ...args: any[]): void;
41
42 enableColor(): void;
43 disableColor(): void;
44
45 enableProgress(): void;
46 disableProgress(): void;
47 progressEnabled(): boolean;
48
49 enableUnicode(): void;
50 disableUnicode(): void;
51
52 pause(): void;
53 resume(): void;
54
55 addLevel(level: string, n: number, style?: StyleObject, disp?: string): void;
56
57 // Allows for custom log levels
58 // npmlog.addLevel("custom", level)
59 // npmlog.custom(prefix, message)
60 [key: string]: any;
61 }
62
63 type LogLevels = "silly" | "verbose" | "info" | "timing" | "http" | "notice" | "warn" | "error" | "silent";
64
65 interface StyleObject {
66 fg?: string | undefined;
67 bg?: string | undefined;
68 bold?: boolean | undefined;
69 inverse?: boolean | undefined;
70 underline?: boolean | undefined;
71 bell?: boolean | undefined;
72 }
73
74 interface MessageObject {
75 id: number;
76 level: string;
77 prefix: string;
78 message: string;
79 messageRaw: string;
80 }
81}
82
83declare var npmlog: npmlog.Logger;
84export = npmlog;