UNPKG

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