UNPKG

2.6 kBTypeScriptView Raw
1// Type definitions for npmlog 4.1
2// Project: https://github.com/npm/npmlog#readme
3// Definitions by: Daniel Schmidt <https://github.com/DanielMSchmidt>
4// Joseph Wynn <https://github.com/wildlyinaccurate>
5// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
6// TypeScript Version: 2.4
7
8import { EventEmitter } from "events";
9
10declare namespace npmlog {
11 // TODO: newStream, newGroup, setGaugeTemplate and setGaugeTemplateSet need to be added
12 interface Logger extends EventEmitter {
13 (): any;
14
15 level: string;
16 record: MessageObject[];
17 maxRecordSize: number;
18 prefixStyle: StyleObject;
19 headingStyle: StyleObject;
20 heading: string;
21 stream: any; // Defaults to process.stderr
22
23 log(level: LogLevels | string, prefix: string, message: string, ...args: any[]): void;
24
25 silly(prefix: string, message: string, ...args: any[]): void;
26 verbose(prefix: string, message: string, ...args: any[]): void;
27 info(prefix: string, message: string, ...args: any[]): void;
28 timing(prefix: string, message: string, ...args: any[]): void;
29 http(prefix: string, message: string, ...args: any[]): void;
30 notice(prefix: string, message: string, ...args: any[]): void;
31 warn(prefix: string, message: string, ...args: any[]): void;
32 error(prefix: string, message: string, ...args: any[]): void;
33 silent(prefix: string, message: string, ...args: any[]): void;
34
35 enableColor(): void;
36 disableColor(): void;
37
38 enableProgress(): void;
39 disableProgress(): void;
40 progressEnabled(): boolean;
41
42 enableUnicode(): void;
43 disableUnicode(): void;
44
45 pause(): void;
46 resume(): void;
47
48 addLevel(level: string, n: number, style?: StyleObject, disp?: string): void;
49
50 // Allows for custom log levels
51 // npmlog.addLevel("custom", level)
52 // npmlog.custom(prefix, message)
53 [key: string]: any;
54 }
55
56 type LogLevels = "silly" | "verbose" | "info" | "timing" | "http" | "notice" | "warn" | "error" | "silent";
57
58 interface StyleObject {
59 fg?: string | undefined;
60 bg?: string | undefined;
61 bold?: boolean | undefined;
62 inverse?: boolean | undefined;
63 underline?: boolean | undefined;
64 bell?: boolean | undefined;
65 }
66
67 interface MessageObject {
68 id: number;
69 level: string;
70 prefix: string;
71 message: string;
72 messageRaw: string;
73 }
74}
75
76declare var npmlog: npmlog.Logger;
77export = npmlog;