-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
189 lines (185 loc) · 8.01 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/// <reference types="node" />
export = caipora;
declare const caipora: caipora.Caipora & {
/**
* This is an alias of {@link Caipora} class. It is not the same as {@link console.Console}.
* It is exported for compatibility reasons.
*/
Console: caipora.Caipora;
/**
* The Caipora class can be used to create a simple logger with configurable output streams.
* The default log level will be set to the environment variable `LOG_LEVEL` or `info`.
*/
Caipora: caipora.Caipora;
};
declare namespace caipora {
/**
* Supported levels are `trace`, `debug`, `info`,
* `warn`, `error`, and `silent`. Log levels are
* case insensitive.
*/
export type LogLevel = string;
export interface Caipora {
new(stdout: NodeJS.WritableStream, stderr?: NodeJS.WritableStream, ignoreErrors?: boolean): Caipora;
new(options: NodeJS.ConsoleConstructorOptions): Caipora;
/**
* A simple assertion test that verifies whether `condition` is truthy.
* If it is not, an `AssertionError` is printed.
* If provided, the error `message` is formatted using `util.format()` and used as the error message.
*/
assert(condition: boolean): void;
assert(condition: boolean, message: string, ...optionalParams: any[]): void;
/**
* When `stdout` is a TTY, calling `console.clear()` will attempt to clear the TTY.
* When `stdout` is not a TTY, this method does nothing.
*/
clear(): void;
/**
* Maintains an internal counter specific to `label` and outputs to `stdout` the number of times `console.count()` has been called with the given `label`.
*/
count(label?: string): void;
/**
* Resets the internal counter specific to `label`.
*/
countReset(label?: string): void;
/**
* Prints to `stdout` with newline if debug level is enabled.
* If a single argument is passed and it is a function, it prints lazily.
*/
debug(func: () => [string, ...any[]]): void;
debug(func: () => any[]): void;
debug(func: () => any): void;
debug(message: string, ...optionalParams: any[]): void;
debug(...args: any[]): void;
/**
* Uses {@link util.inspect()} on `obj` and prints the resulting string to `stdout`.
* This bypasses any custom `inspect()` defined on `obj`.
*/
dir(obj: any, options?: NodeJS.InspectOptions): void;
/**
* This method calls {@link console.log()} passing it the arguments received. Please note that this method does not produce any XML formatting
*/
dirxml(...data: any[]): void;
/**
* Prints to `stderr` with newline if error level is enabled.
* If a single argument is passed and it is a function, it prints lazily.
*/
error(func: () => [string, ...any[]]): void;
error(func: () => any[]): void;
error(func: () => any): void;
error(message: string, ...optionalParams: any[]): void;
error(...args: any[]): void;
/**
* Gets the current log level.
*/
getLevel(): LogLevel;
/**
* Increases indentation of subsequent lines by two spaces.
* If one or more `label`s are provided, those are printed first without the additional indentation.
*/
group(...label: any[]): void;
/**
* The `console.groupCollapsed()` is an alias for {@link console.group()}.
*/
groupCollapsed(): void;
/**
* Decreases indentation of subsequent lines by two spaces.
*/
groupEnd(): void;
/**
* Prints to `stdout` with newline if info level is enabled.
* If a single argument is passed and it is a function, it prints lazily.
*/
info(func: () => [string, ...any[]]): void;
info(func: () => any[]): void;
info(func: () => any): void;
info(message: string, ...optionalParams: any[]): void;
info(...args: any[]): void;
/**
* Prints to `stdout` with newline regardless of the log level.
* If a single argument is passed and it is a function, it prints lazily.
*/
log(func: () => [string, ...any[]]): void;
log(func: () => any[]): void;
log(func: () => any): void;
log(message: string, ...optionalParams: any[]): void;
log(...args: any[]): void;
/**
* This method does not display anything unless used in the inspector.
* Prints to `stdout` the array `array` formatted as a table.
*/
table(tabularData: any, properties?: string[]): void;
/**
* Starts a timer that can be used to compute the duration of an operation. Timers are identified by a unique `label`.
*/
time(label?: string): void;
/**
* Stops a timer that was previously started by calling {@link console.time()} and prints the result to `stdout`.
*/
timeEnd(label?: string): void;
/**
* For a timer that was previously started by calling {@link console.time()}, prints the elapsed time and other `data` arguments to `stdout`.
*/
timeLog(label?: string, ...data: any[]): void;
/**
* Prints to `stderr` the string 'Trace :', followed by the {@link util.format()} formatted message and stack trace to the current position in the code if trace level is enabled.
* If a single argument is passed and it is a function, it prints lazily.
*/
trace(func: () => [string, ...any[]]): void;
trace(func: () => any[]): void;
trace(func: () => any): void;
trace(message: string, ...optionalParams: any[]): void;
trace(...args: any[]): void;
/**
* Prints to `stderr` with newline if warn level is enabled.
* If a single argument is passed and it is a function, it prints lazily.
*/
warn(func: () => [string, ...any[]]): void;
warn(func: () => any[]): void;
warn(func: () => any): void;
warn(message: string, ...optionalParams: any[]): void;
warn(...args: any[]): void;
// --- Inspector mode only ---
/**
* This method does not display anything unless used in the inspector.
* The console.markTimeline() method is the deprecated form of console.timeStamp().
*
* @deprecated Use console.timeStamp() instead.
*/
markTimeline(label?: string): void;
/**
* This method does not display anything unless used in the inspector.
* Starts a JavaScript CPU profile with an optional label.
*/
profile(label?: string): void;
/**
* This method does not display anything unless used in the inspector.
* Stops the current JavaScript CPU profiling session if one has been started and prints the report to the Profiles panel of the inspector.
*/
profileEnd(label?: string): void;
/**
* Sets the current log level.
* The log level defaults to LOG_LEVEL environment variable if set or `info` if not set.
*/
setLevel(level: LogLevel): void;
/**
* This method does not display anything unless used in the inspector.
* Adds an event with the label `label` to the Timeline panel of the inspector.
*/
timeStamp(label?: string): void;
/**
* This method does not display anything unless used in the inspector.
* The console.timeline() method is the deprecated form of console.time().
*
* @deprecated Use console.time() instead.
*/
timeline(label?: string): void;
/**
* This method does not display anything unless used in the inspector.
* The console.timelineEnd() method is the deprecated form of console.timeEnd().
*
* @deprecated Use console.timeEnd() instead.
*/
timelineEnd(label?: string): void;
}
}