@logtape/logtape 1.4.0-dev.461 → 1.4.0-dev.464
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/dist/logger.cjs +302 -28
- package/dist/logger.d.cts +172 -0
- package/dist/logger.d.cts.map +1 -1
- package/dist/logger.d.ts +172 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +302 -28
- package/dist/logger.js.map +1 -1
- package/dist/sink.cjs +13 -2
- package/dist/sink.d.cts +25 -0
- package/dist/sink.d.cts.map +1 -1
- package/dist/sink.d.ts +25 -0
- package/dist/sink.d.ts.map +1 -1
- package/dist/sink.js +13 -2
- package/dist/sink.js.map +1 -1
- package/package.json +1 -1
package/dist/logger.cjs
CHANGED
|
@@ -95,6 +95,11 @@ var LoggerImpl = class LoggerImpl {
|
|
|
95
95
|
if (this.parent != null && this.parentSinks === "inherit") for (const sink of this.parent.getSinks(level)) yield sink;
|
|
96
96
|
for (const sink of this.sinks) yield sink;
|
|
97
97
|
}
|
|
98
|
+
isEnabledFor(level) {
|
|
99
|
+
if (this.lowestLevel === null || require_level.compareLogLevel(level, this.lowestLevel) < 0) return false;
|
|
100
|
+
for (const _ of this.getSinks(level)) return true;
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
98
103
|
emit(record, bypassSinks) {
|
|
99
104
|
const categoryPrefix = require_context.getCategoryPrefix();
|
|
100
105
|
const baseCategory = "category" in record ? record.category : this.category;
|
|
@@ -201,52 +206,185 @@ var LoggerImpl = class LoggerImpl {
|
|
|
201
206
|
});
|
|
202
207
|
}
|
|
203
208
|
trace(message, ...values) {
|
|
204
|
-
if (typeof message === "string")
|
|
205
|
-
|
|
209
|
+
if (typeof message === "string") {
|
|
210
|
+
const props = values[0];
|
|
211
|
+
if (typeof props === "function") {
|
|
212
|
+
if (props.constructor.name === "AsyncFunction") {
|
|
213
|
+
if (!this.isEnabledFor("trace")) return Promise.resolve();
|
|
214
|
+
return props().then((resolvedProps) => {
|
|
215
|
+
this.log("trace", message, resolvedProps);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
const result = props();
|
|
219
|
+
if (result instanceof Promise) {
|
|
220
|
+
if (!this.isEnabledFor("trace")) return Promise.resolve();
|
|
221
|
+
return result.then((resolvedProps) => {
|
|
222
|
+
this.log("trace", message, resolvedProps);
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
this.log("trace", message, result);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
this.log("trace", message, props ?? {});
|
|
229
|
+
} else if (typeof message === "function") this.logLazily("trace", message);
|
|
206
230
|
else if (!Array.isArray(message)) this.log("trace", "{*}", message);
|
|
207
231
|
else this.logTemplate("trace", message, values);
|
|
208
232
|
}
|
|
209
233
|
debug(message, ...values) {
|
|
210
|
-
if (typeof message === "string")
|
|
211
|
-
|
|
234
|
+
if (typeof message === "string") {
|
|
235
|
+
const props = values[0];
|
|
236
|
+
if (typeof props === "function") {
|
|
237
|
+
if (props.constructor.name === "AsyncFunction") {
|
|
238
|
+
if (!this.isEnabledFor("debug")) return Promise.resolve();
|
|
239
|
+
return props().then((resolvedProps) => {
|
|
240
|
+
this.log("debug", message, resolvedProps);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
const result = props();
|
|
244
|
+
if (result instanceof Promise) {
|
|
245
|
+
if (!this.isEnabledFor("debug")) return Promise.resolve();
|
|
246
|
+
return result.then((resolvedProps) => {
|
|
247
|
+
this.log("debug", message, resolvedProps);
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
this.log("debug", message, result);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
this.log("debug", message, props ?? {});
|
|
254
|
+
} else if (typeof message === "function") this.logLazily("debug", message);
|
|
212
255
|
else if (!Array.isArray(message)) this.log("debug", "{*}", message);
|
|
213
256
|
else this.logTemplate("debug", message, values);
|
|
214
257
|
}
|
|
215
258
|
info(message, ...values) {
|
|
216
|
-
if (typeof message === "string")
|
|
217
|
-
|
|
259
|
+
if (typeof message === "string") {
|
|
260
|
+
const props = values[0];
|
|
261
|
+
if (typeof props === "function") {
|
|
262
|
+
if (props.constructor.name === "AsyncFunction") {
|
|
263
|
+
if (!this.isEnabledFor("info")) return Promise.resolve();
|
|
264
|
+
return props().then((resolvedProps) => {
|
|
265
|
+
this.log("info", message, resolvedProps);
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
const result = props();
|
|
269
|
+
if (result instanceof Promise) {
|
|
270
|
+
if (!this.isEnabledFor("info")) return Promise.resolve();
|
|
271
|
+
return result.then((resolvedProps) => {
|
|
272
|
+
this.log("info", message, resolvedProps);
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
this.log("info", message, result);
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
this.log("info", message, props ?? {});
|
|
279
|
+
} else if (typeof message === "function") this.logLazily("info", message);
|
|
218
280
|
else if (!Array.isArray(message)) this.log("info", "{*}", message);
|
|
219
281
|
else this.logTemplate("info", message, values);
|
|
220
282
|
}
|
|
221
283
|
warn(message, ...values) {
|
|
222
284
|
if (message instanceof Error) this.log("warning", "{error.message}", { error: message });
|
|
223
285
|
else if (typeof message === "string" && values[0] instanceof Error) this.log("warning", message, { error: values[0] });
|
|
224
|
-
else if (typeof message === "string")
|
|
225
|
-
|
|
286
|
+
else if (typeof message === "string") {
|
|
287
|
+
const props = values[0];
|
|
288
|
+
if (typeof props === "function") {
|
|
289
|
+
if (props.constructor.name === "AsyncFunction") {
|
|
290
|
+
if (!this.isEnabledFor("warning")) return Promise.resolve();
|
|
291
|
+
return props().then((resolvedProps) => {
|
|
292
|
+
this.log("warning", message, resolvedProps);
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
const result = props();
|
|
296
|
+
if (result instanceof Promise) {
|
|
297
|
+
if (!this.isEnabledFor("warning")) return Promise.resolve();
|
|
298
|
+
return result.then((resolvedProps) => {
|
|
299
|
+
this.log("warning", message, resolvedProps);
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
this.log("warning", message, result);
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
this.log("warning", message, props ?? {});
|
|
306
|
+
} else if (typeof message === "function") this.logLazily("warning", message);
|
|
226
307
|
else if (!Array.isArray(message)) this.log("warning", "{*}", message);
|
|
227
308
|
else this.logTemplate("warning", message, values);
|
|
228
309
|
}
|
|
229
310
|
warning(message, ...values) {
|
|
230
311
|
if (message instanceof Error) this.log("warning", "{error.message}", { error: message });
|
|
231
312
|
else if (typeof message === "string" && values[0] instanceof Error) this.log("warning", message, { error: values[0] });
|
|
232
|
-
else if (typeof message === "string")
|
|
233
|
-
|
|
313
|
+
else if (typeof message === "string") {
|
|
314
|
+
const props = values[0];
|
|
315
|
+
if (typeof props === "function") {
|
|
316
|
+
if (props.constructor.name === "AsyncFunction") {
|
|
317
|
+
if (!this.isEnabledFor("warning")) return Promise.resolve();
|
|
318
|
+
return props().then((resolvedProps) => {
|
|
319
|
+
this.log("warning", message, resolvedProps);
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
const result = props();
|
|
323
|
+
if (result instanceof Promise) {
|
|
324
|
+
if (!this.isEnabledFor("warning")) return Promise.resolve();
|
|
325
|
+
return result.then((resolvedProps) => {
|
|
326
|
+
this.log("warning", message, resolvedProps);
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
this.log("warning", message, result);
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
this.log("warning", message, props ?? {});
|
|
333
|
+
} else if (typeof message === "function") this.logLazily("warning", message);
|
|
234
334
|
else if (!Array.isArray(message)) this.log("warning", "{*}", message);
|
|
235
335
|
else this.logTemplate("warning", message, values);
|
|
236
336
|
}
|
|
237
337
|
error(message, ...values) {
|
|
238
338
|
if (message instanceof Error) this.log("error", "{error.message}", { error: message });
|
|
239
339
|
else if (typeof message === "string" && values[0] instanceof Error) this.log("error", message, { error: values[0] });
|
|
240
|
-
else if (typeof message === "string")
|
|
241
|
-
|
|
340
|
+
else if (typeof message === "string") {
|
|
341
|
+
const props = values[0];
|
|
342
|
+
if (typeof props === "function") {
|
|
343
|
+
if (props.constructor.name === "AsyncFunction") {
|
|
344
|
+
if (!this.isEnabledFor("error")) return Promise.resolve();
|
|
345
|
+
return props().then((resolvedProps) => {
|
|
346
|
+
this.log("error", message, resolvedProps);
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
const result = props();
|
|
350
|
+
if (result instanceof Promise) {
|
|
351
|
+
if (!this.isEnabledFor("error")) return Promise.resolve();
|
|
352
|
+
return result.then((resolvedProps) => {
|
|
353
|
+
this.log("error", message, resolvedProps);
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
this.log("error", message, result);
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
this.log("error", message, props ?? {});
|
|
360
|
+
} else if (typeof message === "function") this.logLazily("error", message);
|
|
242
361
|
else if (!Array.isArray(message)) this.log("error", "{*}", message);
|
|
243
362
|
else this.logTemplate("error", message, values);
|
|
244
363
|
}
|
|
245
364
|
fatal(message, ...values) {
|
|
246
365
|
if (message instanceof Error) this.log("fatal", "{error.message}", { error: message });
|
|
247
366
|
else if (typeof message === "string" && values[0] instanceof Error) this.log("fatal", message, { error: values[0] });
|
|
248
|
-
else if (typeof message === "string")
|
|
249
|
-
|
|
367
|
+
else if (typeof message === "string") {
|
|
368
|
+
const props = values[0];
|
|
369
|
+
if (typeof props === "function") {
|
|
370
|
+
if (props.constructor.name === "AsyncFunction") {
|
|
371
|
+
if (!this.isEnabledFor("fatal")) return Promise.resolve();
|
|
372
|
+
return props().then((resolvedProps) => {
|
|
373
|
+
this.log("fatal", message, resolvedProps);
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
const result = props();
|
|
377
|
+
if (result instanceof Promise) {
|
|
378
|
+
if (!this.isEnabledFor("fatal")) return Promise.resolve();
|
|
379
|
+
return result.then((resolvedProps) => {
|
|
380
|
+
this.log("fatal", message, resolvedProps);
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
this.log("fatal", message, result);
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
this.log("fatal", message, props ?? {});
|
|
387
|
+
} else if (typeof message === "function") this.logLazily("fatal", message);
|
|
250
388
|
else if (!Array.isArray(message)) this.log("fatal", "{*}", message);
|
|
251
389
|
else this.logTemplate("fatal", message, values);
|
|
252
390
|
}
|
|
@@ -303,53 +441,189 @@ var LoggerCtx = class LoggerCtx {
|
|
|
303
441
|
};
|
|
304
442
|
this.logger.emit(recordWithContext);
|
|
305
443
|
}
|
|
444
|
+
isEnabledFor(level) {
|
|
445
|
+
return this.logger.isEnabledFor(level);
|
|
446
|
+
}
|
|
306
447
|
trace(message, ...values) {
|
|
307
|
-
if (typeof message === "string")
|
|
308
|
-
|
|
448
|
+
if (typeof message === "string") {
|
|
449
|
+
const props = values[0];
|
|
450
|
+
if (typeof props === "function") {
|
|
451
|
+
if (props.constructor.name === "AsyncFunction") {
|
|
452
|
+
if (!this.isEnabledFor("trace")) return Promise.resolve();
|
|
453
|
+
return props().then((resolvedProps) => {
|
|
454
|
+
this.log("trace", message, resolvedProps);
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
const result = props();
|
|
458
|
+
if (result instanceof Promise) {
|
|
459
|
+
if (!this.isEnabledFor("trace")) return Promise.resolve();
|
|
460
|
+
return result.then((resolvedProps) => {
|
|
461
|
+
this.log("trace", message, resolvedProps);
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
this.log("trace", message, result);
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
this.log("trace", message, props ?? {});
|
|
468
|
+
} else if (typeof message === "function") this.logLazily("trace", message);
|
|
309
469
|
else if (!Array.isArray(message)) this.log("trace", "{*}", message);
|
|
310
470
|
else this.logTemplate("trace", message, values);
|
|
311
471
|
}
|
|
312
472
|
debug(message, ...values) {
|
|
313
|
-
if (typeof message === "string")
|
|
314
|
-
|
|
473
|
+
if (typeof message === "string") {
|
|
474
|
+
const props = values[0];
|
|
475
|
+
if (typeof props === "function") {
|
|
476
|
+
if (props.constructor.name === "AsyncFunction") {
|
|
477
|
+
if (!this.isEnabledFor("debug")) return Promise.resolve();
|
|
478
|
+
return props().then((resolvedProps) => {
|
|
479
|
+
this.log("debug", message, resolvedProps);
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
const result = props();
|
|
483
|
+
if (result instanceof Promise) {
|
|
484
|
+
if (!this.isEnabledFor("debug")) return Promise.resolve();
|
|
485
|
+
return result.then((resolvedProps) => {
|
|
486
|
+
this.log("debug", message, resolvedProps);
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
this.log("debug", message, result);
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
this.log("debug", message, props ?? {});
|
|
493
|
+
} else if (typeof message === "function") this.logLazily("debug", message);
|
|
315
494
|
else if (!Array.isArray(message)) this.log("debug", "{*}", message);
|
|
316
495
|
else this.logTemplate("debug", message, values);
|
|
317
496
|
}
|
|
318
497
|
info(message, ...values) {
|
|
319
|
-
if (typeof message === "string")
|
|
320
|
-
|
|
498
|
+
if (typeof message === "string") {
|
|
499
|
+
const props = values[0];
|
|
500
|
+
if (typeof props === "function") {
|
|
501
|
+
if (props.constructor.name === "AsyncFunction") {
|
|
502
|
+
if (!this.isEnabledFor("info")) return Promise.resolve();
|
|
503
|
+
return props().then((resolvedProps) => {
|
|
504
|
+
this.log("info", message, resolvedProps);
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
const result = props();
|
|
508
|
+
if (result instanceof Promise) {
|
|
509
|
+
if (!this.isEnabledFor("info")) return Promise.resolve();
|
|
510
|
+
return result.then((resolvedProps) => {
|
|
511
|
+
this.log("info", message, resolvedProps);
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
this.log("info", message, result);
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
this.log("info", message, props ?? {});
|
|
518
|
+
} else if (typeof message === "function") this.logLazily("info", message);
|
|
321
519
|
else if (!Array.isArray(message)) this.log("info", "{*}", message);
|
|
322
520
|
else this.logTemplate("info", message, values);
|
|
323
521
|
}
|
|
324
522
|
warn(message, ...values) {
|
|
325
523
|
if (message instanceof Error) this.log("warning", "{error.message}", { error: message });
|
|
326
524
|
else if (typeof message === "string" && values[0] instanceof Error) this.log("warning", message, { error: values[0] });
|
|
327
|
-
else if (typeof message === "string")
|
|
328
|
-
|
|
525
|
+
else if (typeof message === "string") {
|
|
526
|
+
const props = values[0];
|
|
527
|
+
if (typeof props === "function") {
|
|
528
|
+
if (props.constructor.name === "AsyncFunction") {
|
|
529
|
+
if (!this.isEnabledFor("warning")) return Promise.resolve();
|
|
530
|
+
return props().then((resolvedProps) => {
|
|
531
|
+
this.log("warning", message, resolvedProps);
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
const result = props();
|
|
535
|
+
if (result instanceof Promise) {
|
|
536
|
+
if (!this.isEnabledFor("warning")) return Promise.resolve();
|
|
537
|
+
return result.then((resolvedProps) => {
|
|
538
|
+
this.log("warning", message, resolvedProps);
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
this.log("warning", message, result);
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
this.log("warning", message, props ?? {});
|
|
545
|
+
} else if (typeof message === "function") this.logLazily("warning", message);
|
|
329
546
|
else if (!Array.isArray(message)) this.log("warning", "{*}", message);
|
|
330
547
|
else this.logTemplate("warning", message, values);
|
|
331
548
|
}
|
|
332
549
|
warning(message, ...values) {
|
|
333
550
|
if (message instanceof Error) this.log("warning", "{error.message}", { error: message });
|
|
334
551
|
else if (typeof message === "string" && values[0] instanceof Error) this.log("warning", message, { error: values[0] });
|
|
335
|
-
else if (typeof message === "string")
|
|
336
|
-
|
|
552
|
+
else if (typeof message === "string") {
|
|
553
|
+
const props = values[0];
|
|
554
|
+
if (typeof props === "function") {
|
|
555
|
+
if (props.constructor.name === "AsyncFunction") {
|
|
556
|
+
if (!this.isEnabledFor("warning")) return Promise.resolve();
|
|
557
|
+
return props().then((resolvedProps) => {
|
|
558
|
+
this.log("warning", message, resolvedProps);
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
const result = props();
|
|
562
|
+
if (result instanceof Promise) {
|
|
563
|
+
if (!this.isEnabledFor("warning")) return Promise.resolve();
|
|
564
|
+
return result.then((resolvedProps) => {
|
|
565
|
+
this.log("warning", message, resolvedProps);
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
this.log("warning", message, result);
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
this.log("warning", message, props ?? {});
|
|
572
|
+
} else if (typeof message === "function") this.logLazily("warning", message);
|
|
337
573
|
else if (!Array.isArray(message)) this.log("warning", "{*}", message);
|
|
338
574
|
else this.logTemplate("warning", message, values);
|
|
339
575
|
}
|
|
340
576
|
error(message, ...values) {
|
|
341
577
|
if (message instanceof Error) this.log("error", "{error.message}", { error: message });
|
|
342
578
|
else if (typeof message === "string" && values[0] instanceof Error) this.log("error", message, { error: values[0] });
|
|
343
|
-
else if (typeof message === "string")
|
|
344
|
-
|
|
579
|
+
else if (typeof message === "string") {
|
|
580
|
+
const props = values[0];
|
|
581
|
+
if (typeof props === "function") {
|
|
582
|
+
if (props.constructor.name === "AsyncFunction") {
|
|
583
|
+
if (!this.isEnabledFor("error")) return Promise.resolve();
|
|
584
|
+
return props().then((resolvedProps) => {
|
|
585
|
+
this.log("error", message, resolvedProps);
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
const result = props();
|
|
589
|
+
if (result instanceof Promise) {
|
|
590
|
+
if (!this.isEnabledFor("error")) return Promise.resolve();
|
|
591
|
+
return result.then((resolvedProps) => {
|
|
592
|
+
this.log("error", message, resolvedProps);
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
this.log("error", message, result);
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
this.log("error", message, props ?? {});
|
|
599
|
+
} else if (typeof message === "function") this.logLazily("error", message);
|
|
345
600
|
else if (!Array.isArray(message)) this.log("error", "{*}", message);
|
|
346
601
|
else this.logTemplate("error", message, values);
|
|
347
602
|
}
|
|
348
603
|
fatal(message, ...values) {
|
|
349
604
|
if (message instanceof Error) this.log("fatal", "{error.message}", { error: message });
|
|
350
605
|
else if (typeof message === "string" && values[0] instanceof Error) this.log("fatal", message, { error: values[0] });
|
|
351
|
-
else if (typeof message === "string")
|
|
352
|
-
|
|
606
|
+
else if (typeof message === "string") {
|
|
607
|
+
const props = values[0];
|
|
608
|
+
if (typeof props === "function") {
|
|
609
|
+
if (props.constructor.name === "AsyncFunction") {
|
|
610
|
+
if (!this.isEnabledFor("fatal")) return Promise.resolve();
|
|
611
|
+
return props().then((resolvedProps) => {
|
|
612
|
+
this.log("fatal", message, resolvedProps);
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
const result = props();
|
|
616
|
+
if (result instanceof Promise) {
|
|
617
|
+
if (!this.isEnabledFor("fatal")) return Promise.resolve();
|
|
618
|
+
return result.then((resolvedProps) => {
|
|
619
|
+
this.log("fatal", message, resolvedProps);
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
this.log("fatal", message, result);
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
this.log("fatal", message, props ?? {});
|
|
626
|
+
} else if (typeof message === "function") this.logLazily("fatal", message);
|
|
353
627
|
else if (!Array.isArray(message)) this.log("fatal", "{*}", message);
|
|
354
628
|
else this.logTemplate("fatal", message, values);
|
|
355
629
|
}
|
package/dist/logger.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LogLevel } from "./level.cjs";
|
|
1
2
|
import { LogRecord } from "./record.cjs";
|
|
2
3
|
|
|
3
4
|
//#region src/logger.d.ts
|
|
@@ -110,6 +111,26 @@ interface Logger {
|
|
|
110
111
|
* @since 0.12.0
|
|
111
112
|
*/
|
|
112
113
|
trace(message: string, properties?: Record<string, unknown> | (() => Record<string, unknown>)): void;
|
|
114
|
+
/**
|
|
115
|
+
* Log a trace message with properties computed asynchronously.
|
|
116
|
+
*
|
|
117
|
+
* Use this when the properties require async operations to compute:
|
|
118
|
+
*
|
|
119
|
+
* ```typescript
|
|
120
|
+
* await logger.trace(
|
|
121
|
+
* 'A trace message with {value}.',
|
|
122
|
+
* async () => ({ value: await fetchValue() })
|
|
123
|
+
* );
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* @param message The message template. Placeholders to be replaced with
|
|
127
|
+
* `values` are indicated by keys in curly braces (e.g.,
|
|
128
|
+
* `{value}`).
|
|
129
|
+
* @param properties An async callback that returns the properties.
|
|
130
|
+
* @returns A promise that resolves when the log is written.
|
|
131
|
+
* @since 1.4.0
|
|
132
|
+
*/
|
|
133
|
+
trace(message: string, properties: () => Promise<Record<string, unknown>>): Promise<void>;
|
|
113
134
|
/**
|
|
114
135
|
* Log a trace values with no message. This is useful when you
|
|
115
136
|
* want to log properties without a message, e.g., when you want to log
|
|
@@ -189,6 +210,26 @@ interface Logger {
|
|
|
189
210
|
* properties.
|
|
190
211
|
*/
|
|
191
212
|
debug(message: string, properties?: Record<string, unknown> | (() => Record<string, unknown>)): void;
|
|
213
|
+
/**
|
|
214
|
+
* Log a debug message with properties computed asynchronously.
|
|
215
|
+
*
|
|
216
|
+
* Use this when the properties require async operations to compute:
|
|
217
|
+
*
|
|
218
|
+
* ```typescript
|
|
219
|
+
* await logger.debug(
|
|
220
|
+
* 'A debug message with {value}.',
|
|
221
|
+
* async () => ({ value: await fetchValue() })
|
|
222
|
+
* );
|
|
223
|
+
* ```
|
|
224
|
+
*
|
|
225
|
+
* @param message The message template. Placeholders to be replaced with
|
|
226
|
+
* `values` are indicated by keys in curly braces (e.g.,
|
|
227
|
+
* `{value}`).
|
|
228
|
+
* @param properties An async callback that returns the properties.
|
|
229
|
+
* @returns A promise that resolves when the log is written.
|
|
230
|
+
* @since 1.4.0
|
|
231
|
+
*/
|
|
232
|
+
debug(message: string, properties: () => Promise<Record<string, unknown>>): Promise<void>;
|
|
192
233
|
/**
|
|
193
234
|
* Log a debug values with no message. This is useful when you
|
|
194
235
|
* want to log properties without a message, e.g., when you want to log
|
|
@@ -267,6 +308,26 @@ interface Logger {
|
|
|
267
308
|
* properties.
|
|
268
309
|
*/
|
|
269
310
|
info(message: string, properties?: Record<string, unknown> | (() => Record<string, unknown>)): void;
|
|
311
|
+
/**
|
|
312
|
+
* Log an informational message with properties computed asynchronously.
|
|
313
|
+
*
|
|
314
|
+
* Use this when the properties require async operations to compute:
|
|
315
|
+
*
|
|
316
|
+
* ```typescript
|
|
317
|
+
* await logger.info(
|
|
318
|
+
* 'An info message with {value}.',
|
|
319
|
+
* async () => ({ value: await fetchValue() })
|
|
320
|
+
* );
|
|
321
|
+
* ```
|
|
322
|
+
*
|
|
323
|
+
* @param message The message template. Placeholders to be replaced with
|
|
324
|
+
* `values` are indicated by keys in curly braces (e.g.,
|
|
325
|
+
* `{value}`).
|
|
326
|
+
* @param properties An async callback that returns the properties.
|
|
327
|
+
* @returns A promise that resolves when the log is written.
|
|
328
|
+
* @since 1.4.0
|
|
329
|
+
*/
|
|
330
|
+
info(message: string, properties: () => Promise<Record<string, unknown>>): Promise<void>;
|
|
270
331
|
/**
|
|
271
332
|
* Log an informational values with no message. This is useful when you
|
|
272
333
|
* want to log properties without a message, e.g., when you want to log
|
|
@@ -376,6 +437,26 @@ interface Logger {
|
|
|
376
437
|
* properties.
|
|
377
438
|
*/
|
|
378
439
|
warn(message: string, properties?: Record<string, unknown> | (() => Record<string, unknown>)): void;
|
|
440
|
+
/**
|
|
441
|
+
* Log a warning message with properties computed asynchronously.
|
|
442
|
+
*
|
|
443
|
+
* Use this when the properties require async operations to compute:
|
|
444
|
+
*
|
|
445
|
+
* ```typescript
|
|
446
|
+
* await logger.warn(
|
|
447
|
+
* 'A warning message with {value}.',
|
|
448
|
+
* async () => ({ value: await fetchValue() })
|
|
449
|
+
* );
|
|
450
|
+
* ```
|
|
451
|
+
*
|
|
452
|
+
* @param message The message template. Placeholders to be replaced with
|
|
453
|
+
* `values` are indicated by keys in curly braces (e.g.,
|
|
454
|
+
* `{value}`).
|
|
455
|
+
* @param properties An async callback that returns the properties.
|
|
456
|
+
* @returns A promise that resolves when the log is written.
|
|
457
|
+
* @since 1.4.0
|
|
458
|
+
*/
|
|
459
|
+
warn(message: string, properties: () => Promise<Record<string, unknown>>): Promise<void>;
|
|
379
460
|
/**
|
|
380
461
|
* Log a warning values with no message. This is useful when you
|
|
381
462
|
* want to log properties without a message, e.g., when you want to log
|
|
@@ -487,6 +568,26 @@ interface Logger {
|
|
|
487
568
|
* @since 0.12.0
|
|
488
569
|
*/
|
|
489
570
|
warning(message: string, properties?: Record<string, unknown> | (() => Record<string, unknown>)): void;
|
|
571
|
+
/**
|
|
572
|
+
* Log a warning message with properties computed asynchronously.
|
|
573
|
+
*
|
|
574
|
+
* Use this when the properties require async operations to compute:
|
|
575
|
+
*
|
|
576
|
+
* ```typescript
|
|
577
|
+
* await logger.warning(
|
|
578
|
+
* 'A warning message with {value}.',
|
|
579
|
+
* async () => ({ value: await fetchValue() })
|
|
580
|
+
* );
|
|
581
|
+
* ```
|
|
582
|
+
*
|
|
583
|
+
* @param message The message template. Placeholders to be replaced with
|
|
584
|
+
* `values` are indicated by keys in curly braces (e.g.,
|
|
585
|
+
* `{value}`).
|
|
586
|
+
* @param properties An async callback that returns the properties.
|
|
587
|
+
* @returns A promise that resolves when the log is written.
|
|
588
|
+
* @since 1.4.0
|
|
589
|
+
*/
|
|
590
|
+
warning(message: string, properties: () => Promise<Record<string, unknown>>): Promise<void>;
|
|
490
591
|
/**
|
|
491
592
|
* Log a warning values with no message. This is useful when you
|
|
492
593
|
* want to log properties without a message, e.g., when you want to log
|
|
@@ -597,6 +698,26 @@ interface Logger {
|
|
|
597
698
|
* properties.
|
|
598
699
|
*/
|
|
599
700
|
error(message: string, properties?: Record<string, unknown> | (() => Record<string, unknown>)): void;
|
|
701
|
+
/**
|
|
702
|
+
* Log an error message with properties computed asynchronously.
|
|
703
|
+
*
|
|
704
|
+
* Use this when the properties require async operations to compute:
|
|
705
|
+
*
|
|
706
|
+
* ```typescript
|
|
707
|
+
* await logger.error(
|
|
708
|
+
* 'An error message with {value}.',
|
|
709
|
+
* async () => ({ value: await fetchValue() })
|
|
710
|
+
* );
|
|
711
|
+
* ```
|
|
712
|
+
*
|
|
713
|
+
* @param message The message template. Placeholders to be replaced with
|
|
714
|
+
* `values` are indicated by keys in curly braces (e.g.,
|
|
715
|
+
* `{value}`).
|
|
716
|
+
* @param properties An async callback that returns the properties.
|
|
717
|
+
* @returns A promise that resolves when the log is written.
|
|
718
|
+
* @since 1.4.0
|
|
719
|
+
*/
|
|
720
|
+
error(message: string, properties: () => Promise<Record<string, unknown>>): Promise<void>;
|
|
600
721
|
/**
|
|
601
722
|
* Log an error values with no message. This is useful when you
|
|
602
723
|
* want to log properties without a message, e.g., when you want to log
|
|
@@ -706,6 +827,26 @@ interface Logger {
|
|
|
706
827
|
* properties.
|
|
707
828
|
*/
|
|
708
829
|
fatal(message: string, properties?: Record<string, unknown> | (() => Record<string, unknown>)): void;
|
|
830
|
+
/**
|
|
831
|
+
* Log a fatal error message with properties computed asynchronously.
|
|
832
|
+
*
|
|
833
|
+
* Use this when the properties require async operations to compute:
|
|
834
|
+
*
|
|
835
|
+
* ```typescript
|
|
836
|
+
* await logger.fatal(
|
|
837
|
+
* 'A fatal error message with {value}.',
|
|
838
|
+
* async () => ({ value: await fetchValue() })
|
|
839
|
+
* );
|
|
840
|
+
* ```
|
|
841
|
+
*
|
|
842
|
+
* @param message The message template. Placeholders to be replaced with
|
|
843
|
+
* `values` are indicated by keys in curly braces (e.g.,
|
|
844
|
+
* `{value}`).
|
|
845
|
+
* @param properties An async callback that returns the properties.
|
|
846
|
+
* @returns A promise that resolves when the log is written.
|
|
847
|
+
* @since 1.4.0
|
|
848
|
+
*/
|
|
849
|
+
fatal(message: string, properties: () => Promise<Record<string, unknown>>): Promise<void>;
|
|
709
850
|
/**
|
|
710
851
|
* Log a fatal error values with no message. This is useful when you
|
|
711
852
|
* want to log properties without a message, e.g., when you want to log
|
|
@@ -779,6 +920,27 @@ interface Logger {
|
|
|
779
920
|
* @since 1.1.0
|
|
780
921
|
*/
|
|
781
922
|
emit(record: Omit<LogRecord, "category">): void;
|
|
923
|
+
/**
|
|
924
|
+
* Check if a message of the given severity level would be processed by
|
|
925
|
+
* this logger.
|
|
926
|
+
*
|
|
927
|
+
* This is useful for conditionally executing expensive computations
|
|
928
|
+
* before logging, particularly for async operations where lazy
|
|
929
|
+
* evaluation callbacks cannot be used:
|
|
930
|
+
*
|
|
931
|
+
* ```typescript
|
|
932
|
+
* if (logger.isEnabledFor("debug")) {
|
|
933
|
+
* const result = await expensiveAsync();
|
|
934
|
+
* logger.debug("Result: {result}", { result });
|
|
935
|
+
* }
|
|
936
|
+
* ```
|
|
937
|
+
*
|
|
938
|
+
* @param level The log level to check.
|
|
939
|
+
* @returns `true` if a message of the given level would be logged,
|
|
940
|
+
* `false` otherwise.
|
|
941
|
+
* @since 1.4.0
|
|
942
|
+
*/
|
|
943
|
+
isEnabledFor(level: LogLevel): boolean;
|
|
782
944
|
}
|
|
783
945
|
/**
|
|
784
946
|
* A logging callback function. It is used to defer the computation of a
|
|
@@ -816,6 +978,16 @@ interface LogMethod {
|
|
|
816
978
|
* properties.
|
|
817
979
|
*/
|
|
818
980
|
(message: string, properties?: Record<string, unknown> | (() => Record<string, unknown>)): void;
|
|
981
|
+
/**
|
|
982
|
+
* Log a message with the given level with properties computed asynchronously.
|
|
983
|
+
* @param message The message template. Placeholders to be replaced with
|
|
984
|
+
* `values` are indicated by keys in curly braces (e.g.,
|
|
985
|
+
* `{value}`).
|
|
986
|
+
* @param properties An async callback that returns the properties.
|
|
987
|
+
* @returns A promise that resolves when the log is written.
|
|
988
|
+
* @since 1.4.0
|
|
989
|
+
*/
|
|
990
|
+
(message: string, properties: () => Promise<Record<string, unknown>>): Promise<void>;
|
|
819
991
|
/**
|
|
820
992
|
* Log a message with the given level with no message.
|
|
821
993
|
* @param properties The values to log. Note that this does not take
|
package/dist/logger.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.cts","names":[],"sources":["../src/logger.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.d.cts","names":[],"sources":["../src/logger.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;AA4OiB,UApNA,MAAA,CAoNA;EAAM;;;EAwBM,SACxB,QAAA,EAAA,SAAA,MAAA,EAAA;EAAO;;;;EAoFW,SAA2B,MAAA,EAvT/B,MAuT+B,GAAA,IAAA;EAAM;;;;;;;;;;;;;;;;;;EAiQjB,QA6BtB,CAAA,WAAA,EAAA,MAAA,GAAA,SAAA,CAAA,MAAA,CAAA,GAAA,SAAA,CAAA,MAAA,EAAA,GAAA,MAAA,EAAA,CAAA,CAAA,EA/jBZ,MA+jBY;EAAM;;;;;;;;;;;;;;;;;;;;;;;;;;EAmWM,IA+BT,CAAA,UAAA,EAr6BD,MAq6BC,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA,EAr6ByB,MAq6BzB;EAAS;;AAsBC;AAS9B;AASA;AASA;;;;;;EAoCoC,KAAd,CAAA,OAAA,EA7+BL,oBA6+BK,EAAA,GAAA,MAAA,EAAA,SAAA,OAAA,EAAA,CAAA,EAAA,IAAA;EAAO;;;AAeL;AAexB;;;;;;;;;;;;;;;;;;;;;sCA9+BiB,iCAAiC;;;;;;;;;;;;;;;;;;;;2CAwB5B,QAAQ,2BACzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBA+Be;;;;;;;;;;;;;kBAcF;;;;;;;;;;;iBAYD;;;;;;;;;;;;;;;;;;;;;;;;;sCA4BA,iCAAiC;;;;;;;;;;;;;;;;;;;;2CAwB5B,QAAQ,2BACzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBA+Be;;;;;;;;;;;;kBAaF;;;;;;;;;;;gBAYF;;;;;;;;;;;;;;;;;;;;;;;;;qCA4BC,iCAAiC;;;;;;;;;;;;;;;;;;;;0CAwB5B,QAAQ,2BACzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA+Bc;;;;;;;;;;;;;iBAcF;;;;;;;;;;;;;;;;;;cAmBH;;;;;;;;;;;;+BAaiB;;;;;;;;;;;gBAYf;;;;;;;;;;;;;;;;;;;;;;;;;qCA4BC,iCAAiC;;;;;;;;;;;;;;;;;;;;0CAwB5B,QAAQ,2BACzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA+Bc;;;;;;;;;;;;;iBAcF;;;;;;;;;;;;;;;;;;iBAmBA;;;;;;;;;;;;kCAaiB;;;;;;;;;;;;mBAaf;;;;;;;;;;;;;;;;;;;;;;;;;;wCA6BF,iCAAiC;;;;;;;;;;;;;;;;;;;;6CAwB5B,QAAQ,2BACzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA+BiB;;;;;;;;;;;;;;oBAeF;;;;;;;;;;;;;;;;;;eAmBL;;;;;;;;;;;;gCAaiB;;;;;;;;;;;iBAYf;;;;;;;;;;;;;;;;;;;;;;;;;sCA4BA,iCAAiC;;;;;;;;;;;;;;;;;;;;2CAwB5B,QAAQ,2BACzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBA+Be;;;;;;;;;;;;;kBAcF;;;;;;;;;;;;;;;;;;eAmBH;;;;;;;;;;;;gCAaiB;;;;;;;;;;;iBAYf;;;;;;;;;;;;;;;;;;;;;;;;;sCA4BA,iCAAiC;;;;;;;;;;;;;;;;;;;;2CAwB5B,QAAQ,2BACzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBA+Be;;;;;;;;;;;;;kBAcF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA+BH,KAAK;;;;;;;;;;;;;;;;;;;;;sBAsBE;;;;;;;;KASV,WAAA,YAAuB;;;;;;;;KASvB,iBAAA,aACD;;;;;UAQM,SAAA;;;;;;YAOJ;;;;;;;;;;iCAeI,iCAAiC;;;;;;;;;;sCAc5B,QAAQ,2BACzB;;;;;;eAOU;;;;;;aAOF;;;;;;;;;;;;;;iBAeG,SAAA,yCAAsD"}
|