@ix-xs/node-comfort 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +190 -0
- package/README.md +136 -549
- package/index.js +80 -35
- package/package.json +160 -33
- package/src/Arr.js +887 -419
- package/src/Async.js +585 -0
- package/src/Cache.js +329 -0
- package/src/Checker.js +971 -539
- package/src/Cli.js +1034 -0
- package/src/Color.js +415 -0
- package/src/Crypto.js +707 -0
- package/src/Emitter.js +289 -0
- package/src/Env.js +555 -0
- package/src/FS.js +1483 -894
- package/src/Func.js +670 -353
- package/src/Http.js +538 -0
- package/src/Id.js +384 -201
- package/src/Logger.js +739 -378
- package/src/Num.js +844 -361
- package/src/Obj.js +855 -372
- package/src/SQLite.js +1308 -1005
- package/src/Schema.js +1586 -0
- package/src/Str.js +983 -436
- package/src/Sys.js +511 -0
- package/src/Time.js +1260 -422
- package/src/Utils.js +321 -325
- package/src/errors.js +292 -0
- package/types/index.d.ts +693 -526
- package/types/src/Arr.d.ts +455 -145
- package/types/src/Arr.d.ts.map +1 -1
- package/types/src/Async.d.ts +321 -0
- package/types/src/Async.d.ts.map +1 -0
- package/types/src/Cache.d.ts +195 -0
- package/types/src/Cache.d.ts.map +1 -0
- package/types/src/Checker.d.ts +501 -235
- package/types/src/Checker.d.ts.map +1 -1
- package/types/src/Cli.d.ts +582 -0
- package/types/src/Cli.d.ts.map +1 -0
- package/types/src/Color.d.ts +294 -0
- package/types/src/Color.d.ts.map +1 -0
- package/types/src/Crypto.d.ts +534 -0
- package/types/src/Crypto.d.ts.map +1 -0
- package/types/src/Emitter.d.ts +170 -0
- package/types/src/Emitter.d.ts.map +1 -0
- package/types/src/Env.d.ts +382 -0
- package/types/src/Env.d.ts.map +1 -0
- package/types/src/FS.d.ts +686 -238
- package/types/src/FS.d.ts.map +1 -1
- package/types/src/Func.d.ts +380 -135
- package/types/src/Func.d.ts.map +1 -1
- package/types/src/Http.d.ts +374 -0
- package/types/src/Http.d.ts.map +1 -0
- package/types/src/Id.d.ts +149 -68
- package/types/src/Id.d.ts.map +1 -1
- package/types/src/Logger.d.ts +363 -46
- package/types/src/Logger.d.ts.map +1 -1
- package/types/src/Num.d.ts +473 -137
- package/types/src/Num.d.ts.map +1 -1
- package/types/src/Obj.d.ts +390 -104
- package/types/src/Obj.d.ts.map +1 -1
- package/types/src/SQLite.d.ts +646 -309
- package/types/src/SQLite.d.ts.map +1 -1
- package/types/src/Schema.d.ts +940 -0
- package/types/src/Schema.d.ts.map +1 -0
- package/types/src/Str.d.ts +569 -166
- package/types/src/Str.d.ts.map +1 -1
- package/types/src/Sys.d.ts +269 -0
- package/types/src/Sys.d.ts.map +1 -0
- package/types/src/Time.d.ts +663 -204
- package/types/src/Time.d.ts.map +1 -1
- package/types/src/Utils.d.ts +154 -102
- package/types/src/Utils.d.ts.map +1 -1
- package/types/src/errors.d.ts +292 -0
- package/types/src/errors.d.ts.map +1 -0
- package/types/index.d.ts.map +0 -1
package/types/src/Logger.d.ts
CHANGED
|
@@ -1,68 +1,385 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @param {boolean} value - True to enable, false to disable
|
|
4
|
-
* @returns {Logger} The same Logger instance (for chaining)
|
|
2
|
+
* Log levels, from the most verbose to the most severe. `silent` hides everything.
|
|
5
3
|
*/
|
|
6
|
-
export
|
|
4
|
+
export type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "fatal" | "silent";
|
|
7
5
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @param {string} [options.open] - New opening delimiter
|
|
11
|
-
* @param {string} [options.close] - New closing delimiter
|
|
12
|
-
* @returns {Logger} The same Logger instance (for chaining)
|
|
6
|
+
* Where logs go: `process.stdout`, a file stream, or anything with a
|
|
7
|
+
* `write(text)` method.
|
|
13
8
|
*/
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}): Logger;
|
|
9
|
+
export type LogStream = {
|
|
10
|
+
write(text: string): unknown;
|
|
11
|
+
};
|
|
18
12
|
/**
|
|
19
|
-
*
|
|
20
|
-
* @param {*} content - Content to print (string, object, or other)
|
|
21
|
-
* @returns {Logger} The same Logger instance (for chaining)
|
|
13
|
+
* Writing logs to a file.
|
|
22
14
|
*/
|
|
23
|
-
export
|
|
15
|
+
export type LogFileOptions = {
|
|
16
|
+
/**
|
|
17
|
+
* The file to append to. Folders are created, colors removed.
|
|
18
|
+
*/
|
|
19
|
+
path: string;
|
|
20
|
+
/**
|
|
21
|
+
* Rotate past this size, like `"10MB"`.
|
|
22
|
+
*/
|
|
23
|
+
maxSize?: string | number | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* How many rotated files to keep. Defaults to `5`.
|
|
26
|
+
*/
|
|
27
|
+
maxFiles?: number | undefined;
|
|
28
|
+
};
|
|
24
29
|
/**
|
|
25
|
-
*
|
|
26
|
-
* @param {*} content - Content to print.
|
|
27
|
-
* @returns {Logger} The same Logger instance (for chaining).
|
|
30
|
+
* Options for `createLogger()` and `configure()`.
|
|
28
31
|
*/
|
|
29
|
-
export
|
|
32
|
+
export type LoggerOptions = {
|
|
33
|
+
/**
|
|
34
|
+
* Hide messages below this level. Defaults to `LOG_LEVEL`, else `"info"`.
|
|
35
|
+
*/
|
|
36
|
+
level?: LogLevel | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Shown before each message, like `[db]`. Child loggers extend it (`db:pool`).
|
|
39
|
+
*/
|
|
40
|
+
scope?: string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* `true` shows `[HH:mm:ss]`, `false` hides it, a string is a `time.format` pattern. Defaults to `true`.
|
|
43
|
+
*/
|
|
44
|
+
timestamp?: string | boolean | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* `"json"` writes one object per line, for log collectors. Defaults to `LOG_FORMAT`, else `"pretty"`.
|
|
47
|
+
*/
|
|
48
|
+
format?: "pretty" | "json" | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Markup delimiters. Defaults to `<%` and `%>`.
|
|
51
|
+
*/
|
|
52
|
+
delimiter?: {
|
|
53
|
+
open?: string;
|
|
54
|
+
close?: string;
|
|
55
|
+
} | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Force colors on or off. By default, it depends on the terminal.
|
|
58
|
+
*/
|
|
59
|
+
colors?: boolean | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Where `trace` to `info` go. Defaults to `process.stdout`.
|
|
62
|
+
*/
|
|
63
|
+
stdout?: LogStream | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Where `warn`, `error` and `fatal` go. Defaults to `process.stderr`.
|
|
66
|
+
*/
|
|
67
|
+
stderr?: LogStream | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Also write every message to a file.
|
|
70
|
+
*/
|
|
71
|
+
file?: string | LogFileOptions | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Added to every JSON record, like a service name.
|
|
74
|
+
*/
|
|
75
|
+
fields?: Record<string, unknown> | undefined;
|
|
76
|
+
};
|
|
30
77
|
/**
|
|
31
|
-
*
|
|
32
|
-
* @param {*} content - Content to print.
|
|
33
|
-
* @returns {Logger} The same Logger instance (for chaining).
|
|
78
|
+
* A logger from `createLogger()`. Every method returns the logger, so calls chain.
|
|
34
79
|
*/
|
|
35
|
-
export
|
|
80
|
+
export type Logger = {
|
|
81
|
+
/**
|
|
82
|
+
* A plain message, no badge. Supports markup.
|
|
83
|
+
*/
|
|
84
|
+
log: (...args: unknown[]) => Logger;
|
|
85
|
+
/**
|
|
86
|
+
* Very detailed diagnostics, hidden unless the level is `trace`.
|
|
87
|
+
*/
|
|
88
|
+
trace: (...args: unknown[]) => Logger;
|
|
89
|
+
/**
|
|
90
|
+
* Diagnostics, hidden unless the level is `debug` or lower.
|
|
91
|
+
*/
|
|
92
|
+
debug: (...args: unknown[]) => Logger;
|
|
93
|
+
/**
|
|
94
|
+
* An `ℹ INFO` message.
|
|
95
|
+
*/
|
|
96
|
+
info: (...args: unknown[]) => Logger;
|
|
97
|
+
/**
|
|
98
|
+
* A `✔ OK` message.
|
|
99
|
+
*/
|
|
100
|
+
success: (...args: unknown[]) => Logger;
|
|
101
|
+
/**
|
|
102
|
+
* A `⚠ WARN` message, on stderr.
|
|
103
|
+
*/
|
|
104
|
+
warn: (...args: unknown[]) => Logger;
|
|
105
|
+
/**
|
|
106
|
+
* An `✖ ERROR` message, on stderr. Errors show their stack and cause.
|
|
107
|
+
*/
|
|
108
|
+
error: (...args: unknown[]) => Logger;
|
|
109
|
+
/**
|
|
110
|
+
* An `✖ FATAL` message, on stderr.
|
|
111
|
+
*/
|
|
112
|
+
fatal: (...args: unknown[]) => Logger;
|
|
113
|
+
/**
|
|
114
|
+
* Prints a label and indents what follows. Groups nest.
|
|
115
|
+
*/
|
|
116
|
+
group: (label?: string) => Logger;
|
|
117
|
+
/**
|
|
118
|
+
* Closes the current group.
|
|
119
|
+
*/
|
|
120
|
+
groupEnd: () => Logger;
|
|
121
|
+
/**
|
|
122
|
+
* Starts a named timer.
|
|
123
|
+
*/
|
|
124
|
+
timeStart: (label?: string) => Logger;
|
|
125
|
+
/**
|
|
126
|
+
* Prints how long since `timeStart(label)`.
|
|
127
|
+
*/
|
|
128
|
+
timeEnd: (label?: string) => Logger;
|
|
129
|
+
/**
|
|
130
|
+
* Prints rows as a table.
|
|
131
|
+
*/
|
|
132
|
+
table: (rows: Array<Record<string, unknown>> | unknown[][], options?: import("./Cli").TableOptions) => Logger;
|
|
133
|
+
/**
|
|
134
|
+
* Prints text in a box.
|
|
135
|
+
*/
|
|
136
|
+
box: (text: string, options?: import("./Cli").BoxOptions) => Logger;
|
|
137
|
+
/**
|
|
138
|
+
* Prints a horizontal line.
|
|
139
|
+
*/
|
|
140
|
+
divider: (title?: string) => Logger;
|
|
141
|
+
/**
|
|
142
|
+
* A logger with the same settings and a nested scope. Its `fields` are added to the parent's.
|
|
143
|
+
*/
|
|
144
|
+
child: (scope: string, options?: LoggerOptions) => Logger;
|
|
145
|
+
/**
|
|
146
|
+
* Changes the minimum level.
|
|
147
|
+
*/
|
|
148
|
+
setLevel: (level: LogLevel) => Logger;
|
|
149
|
+
/**
|
|
150
|
+
* The current minimum level.
|
|
151
|
+
*/
|
|
152
|
+
getLevel: () => LogLevel;
|
|
153
|
+
/**
|
|
154
|
+
* Would this level be printed? Skip expensive debug output when it wouldn't.
|
|
155
|
+
*/
|
|
156
|
+
isLevelEnabled: (level: LogLevel) => boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Changes several settings at once.
|
|
159
|
+
*/
|
|
160
|
+
configure: (options: LoggerOptions) => Logger;
|
|
161
|
+
};
|
|
36
162
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
163
|
+
* Prints a message without a badge. Strings support markup, objects are
|
|
164
|
+
* pretty-printed, and several arguments are joined with spaces.
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* nc.log("<% green ✔ Saved %> in <% bold 12ms %>");
|
|
168
|
+
* nc.log("user:", { id: 1, roles: ["admin"] });
|
|
169
|
+
*
|
|
170
|
+
* @param {...unknown} args
|
|
171
|
+
* @returns {typeof import("./Logger")}
|
|
40
172
|
*/
|
|
41
|
-
export function
|
|
173
|
+
export function log(...args: unknown[]): typeof import("./Logger");
|
|
42
174
|
/**
|
|
43
|
-
*
|
|
175
|
+
* Very detailed diagnostics, shown only at the `trace` level.
|
|
44
176
|
*
|
|
45
|
-
*
|
|
46
|
-
* @
|
|
47
|
-
* @returns {Logger} The same Logger instance (for chaining).
|
|
177
|
+
* @param {...unknown} args
|
|
178
|
+
* @returns {typeof import("./Logger")}
|
|
48
179
|
*/
|
|
49
|
-
export function
|
|
180
|
+
export function trace(...args: unknown[]): typeof import("./Logger");
|
|
50
181
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* @
|
|
182
|
+
* Diagnostics for developers, shown at the `debug` level (the default when
|
|
183
|
+
* `DEBUG` is set).
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* nc.debug("cache miss", { key });
|
|
187
|
+
*
|
|
188
|
+
* @param {...unknown} args
|
|
189
|
+
* @returns {typeof import("./Logger")}
|
|
55
190
|
*/
|
|
56
|
-
export function debug(
|
|
191
|
+
export function debug(...args: unknown[]): typeof import("./Logger");
|
|
57
192
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* @
|
|
193
|
+
* An informational message.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* nc.info("Server listening on http://localhost:3000");
|
|
197
|
+
*
|
|
198
|
+
* @param {...unknown} args
|
|
199
|
+
* @returns {typeof import("./Logger")}
|
|
61
200
|
*/
|
|
62
|
-
export function
|
|
201
|
+
export function info(...args: unknown[]): typeof import("./Logger");
|
|
63
202
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
203
|
+
* A success message.
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* nc.success("Database connected");
|
|
207
|
+
*
|
|
208
|
+
* @param {...unknown} args
|
|
209
|
+
* @returns {typeof import("./Logger")}
|
|
210
|
+
*/
|
|
211
|
+
export function success(...args: unknown[]): typeof import("./Logger");
|
|
212
|
+
/**
|
|
213
|
+
* A warning, written to stderr.
|
|
214
|
+
*
|
|
215
|
+
* @param {...unknown} args
|
|
216
|
+
* @returns {typeof import("./Logger")}
|
|
217
|
+
*/
|
|
218
|
+
export function warn(...args: unknown[]): typeof import("./Logger");
|
|
219
|
+
/**
|
|
220
|
+
* An error, written to stderr. Error objects show their stack trace and
|
|
221
|
+
* their chain of causes.
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* nc.error(new Error("Cannot save order", { cause: dbError }));
|
|
225
|
+
*
|
|
226
|
+
* @param {...unknown} args
|
|
227
|
+
* @returns {typeof import("./Logger")}
|
|
228
|
+
*/
|
|
229
|
+
export function error(...args: unknown[]): typeof import("./Logger");
|
|
230
|
+
/**
|
|
231
|
+
* A fatal error, written to stderr. It doesn't stop the process; call
|
|
232
|
+
* `process.exit(1)` yourself if you mean to.
|
|
233
|
+
*
|
|
234
|
+
* @param {...unknown} args
|
|
235
|
+
* @returns {typeof import("./Logger")}
|
|
236
|
+
*/
|
|
237
|
+
export function fatal(...args: unknown[]): typeof import("./Logger");
|
|
238
|
+
/**
|
|
239
|
+
* Prints a label and indents what follows, until `groupEnd()`. Groups nest.
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* nc.group("Startup").info("Loading config");
|
|
243
|
+
* nc.group("Database").success("Connected").groupEnd();
|
|
244
|
+
* nc.groupEnd();
|
|
245
|
+
*
|
|
246
|
+
* @param {string} [label]
|
|
247
|
+
* @returns {typeof import("./Logger")}
|
|
248
|
+
*/
|
|
249
|
+
export function group(label?: string): typeof import("./Logger");
|
|
250
|
+
/**
|
|
251
|
+
* Closes the current group.
|
|
252
|
+
*
|
|
253
|
+
* @returns {typeof import("./Logger")}
|
|
254
|
+
*/
|
|
255
|
+
export function groupEnd(): typeof import("./Logger");
|
|
256
|
+
/**
|
|
257
|
+
* Starts a named timer. `timeEnd()` prints the elapsed time.
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* nc.timeStart("import");
|
|
261
|
+
* await importProducts();
|
|
262
|
+
* nc.timeEnd("import"); // "import: 1.24s"
|
|
263
|
+
*
|
|
264
|
+
* @param {string} [label="default"]
|
|
265
|
+
* @returns {typeof import("./Logger")}
|
|
266
|
+
*/
|
|
267
|
+
export function timeStart(label?: string): typeof import("./Logger");
|
|
268
|
+
/**
|
|
269
|
+
* Prints the time since `timeStart()` with the same label.
|
|
270
|
+
*
|
|
271
|
+
* @param {string} [label="default"]
|
|
272
|
+
* @returns {typeof import("./Logger")}
|
|
273
|
+
*/
|
|
274
|
+
export function timeEnd(label?: string): typeof import("./Logger");
|
|
275
|
+
/**
|
|
276
|
+
* Prints rows as a table.
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* nc.table([{ name: "Ada", role: "admin" }, { name: "Bob", role: "user" }]);
|
|
280
|
+
*
|
|
281
|
+
* @param {Array<Record<string, unknown>> | unknown[][]} rows
|
|
282
|
+
* @param {import("./Cli").TableOptions} [options]
|
|
283
|
+
* @returns {typeof import("./Logger")}
|
|
284
|
+
*/
|
|
285
|
+
export function table(rows: Array<Record<string, unknown>> | unknown[][], options?: import("./Cli").TableOptions): typeof import("./Logger");
|
|
286
|
+
/**
|
|
287
|
+
* Prints text in a box. Nice for startup banners.
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* nc.box("Server ready\nhttp://localhost:3000", { title: "my-app", borderColor: "green" });
|
|
291
|
+
*
|
|
292
|
+
* @param {string} text
|
|
293
|
+
* @param {import("./Cli").BoxOptions} [options]
|
|
294
|
+
* @returns {typeof import("./Logger")}
|
|
295
|
+
*/
|
|
296
|
+
export function box(text: string, options?: import("./Cli").BoxOptions): typeof import("./Logger");
|
|
297
|
+
/**
|
|
298
|
+
* Prints a horizontal line, with an optional title in it.
|
|
299
|
+
*
|
|
300
|
+
* @param {string} [title]
|
|
301
|
+
* @returns {typeof import("./Logger")}
|
|
302
|
+
*/
|
|
303
|
+
export function divider(title?: string): typeof import("./Logger");
|
|
304
|
+
/**
|
|
305
|
+
* Sets the minimum level.
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* nc.setLevel("warn"); // warnings and errors only
|
|
309
|
+
* nc.setLevel("silent"); // nothing
|
|
310
|
+
*
|
|
311
|
+
* @param {LogLevel} level
|
|
312
|
+
* @returns {typeof import("./Logger")}
|
|
313
|
+
* @throws {RangeError} For an unknown level.
|
|
314
|
+
*/
|
|
315
|
+
export function setLevel(level: LogLevel): typeof import("./Logger");
|
|
316
|
+
/**
|
|
317
|
+
* The current minimum level.
|
|
318
|
+
*
|
|
319
|
+
* @returns {LogLevel}
|
|
320
|
+
*/
|
|
321
|
+
export function getLevel(): LogLevel;
|
|
322
|
+
/**
|
|
323
|
+
* Would this level be printed? Use it to skip building expensive debug
|
|
324
|
+
* output.
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* if (nc.isLevelEnabled("debug")) nc.debug(buildHugeReport());
|
|
328
|
+
*
|
|
329
|
+
* @param {LogLevel} level
|
|
330
|
+
* @returns {boolean}
|
|
331
|
+
*/
|
|
332
|
+
export function isLevelEnabled(level: LogLevel): boolean;
|
|
333
|
+
/**
|
|
334
|
+
* Changes several settings at once.
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* nc.configure({ level: "debug", file: "logs/app.log" });
|
|
338
|
+
* nc.configure({ format: "json", fields: { service: "api" } });
|
|
339
|
+
*
|
|
340
|
+
* @param {LoggerOptions} options
|
|
341
|
+
* @returns {typeof import("./Logger")}
|
|
342
|
+
*/
|
|
343
|
+
export function configure(options: LoggerOptions): typeof import("./Logger");
|
|
344
|
+
/**
|
|
345
|
+
* Shows or hides timestamps, or sets their pattern.
|
|
346
|
+
*
|
|
347
|
+
* @example
|
|
348
|
+
* nc.setTimestamp(false);
|
|
349
|
+
* nc.setTimestamp("YYYY-MM-DD HH:mm:ss.SSS");
|
|
350
|
+
*
|
|
351
|
+
* @param {boolean | string} value
|
|
352
|
+
* @returns {typeof import("./Logger")}
|
|
353
|
+
*/
|
|
354
|
+
export function setTimestamp(value: boolean | string): typeof import("./Logger");
|
|
355
|
+
/**
|
|
356
|
+
* Changes the markup delimiters, for when `<%` clashes with a template
|
|
357
|
+
* engine.
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* nc.setDelimiter({ open: "{{", close: "}}" });
|
|
361
|
+
* nc.log("{{red Hello}} world");
|
|
362
|
+
*
|
|
363
|
+
* @param {{ open?: string, close?: string }} [options]
|
|
364
|
+
* @returns {typeof import("./Logger")}
|
|
365
|
+
*/
|
|
366
|
+
export function setDelimiter(options?: {
|
|
367
|
+
open?: string;
|
|
368
|
+
close?: string;
|
|
369
|
+
}): typeof import("./Logger");
|
|
370
|
+
/**
|
|
371
|
+
* Creates a logger with its own settings.
|
|
372
|
+
*
|
|
373
|
+
* @example
|
|
374
|
+
* const log = nc.createLogger({ scope: "api", timestamp: "HH:mm:ss.SSS" });
|
|
375
|
+
* log.info("GET /users 200"); // [14:30:05.120] [api] ℹ INFO GET /users 200
|
|
376
|
+
* log.child("db").debug("query took 12ms");
|
|
377
|
+
*
|
|
378
|
+
* const prod = nc.createLogger({ format: "json", fields: { service: "billing" } });
|
|
379
|
+
* prod.error("charge failed", { orderId: 42 }, error);
|
|
380
|
+
*
|
|
381
|
+
* @param {LoggerOptions} [options]
|
|
382
|
+
* @returns {Logger}
|
|
66
383
|
*/
|
|
67
|
-
export function
|
|
384
|
+
export function createLogger(options?: LoggerOptions): Logger;
|
|
68
385
|
//# sourceMappingURL=Logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../src/Logger.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../src/Logger.js"],"names":[],"mappings":";;;uBA8Ba,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ;;;;;wBAMlE;IAAE,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE;;;;;;;;UAM/B,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAYG,MAAM;gBAAU,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAY/B,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,MAAM;;;;WAC9B,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,MAAM;;;;WAC9B,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,MAAM;;;;UAC9B,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,MAAM;;;;aAC9B,CAAC,GAAG,I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