@logtape/logtape 2.1.0-dev.501 → 2.1.0-dev.517

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 CHANGED
@@ -57,6 +57,23 @@ function resolveProperties(properties) {
57
57
  }
58
58
  return resolved;
59
59
  }
60
+ function isPromiseObject(value) {
61
+ if (value instanceof Promise) return true;
62
+ return Object.prototype.toString.call(value) === "[object Promise]" && typeof value.then === "function";
63
+ }
64
+ function logStringMessage(logger, level, message, props) {
65
+ if (typeof props !== "function") {
66
+ const properties = props ?? {};
67
+ logger.log(level, message, properties);
68
+ return;
69
+ }
70
+ if (!logger.isEnabledFor(level)) return Promise.resolve();
71
+ const result = props();
72
+ if (isPromiseObject(result)) return Promise.resolve(result).then((resolvedProps) => {
73
+ logger.log(level, message, resolvedProps);
74
+ });
75
+ logger.log(level, message, result);
76
+ }
60
77
  /**
61
78
  * Get a logger with the given category.
62
79
  *
@@ -261,185 +278,73 @@ var LoggerImpl = class LoggerImpl {
261
278
  });
262
279
  }
263
280
  trace(message, ...values) {
264
- if (typeof message === "string") {
265
- const props = values[0];
266
- if (typeof props === "function") {
267
- if (props.constructor.name === "AsyncFunction") {
268
- if (!this.isEnabledFor("trace")) return Promise.resolve();
269
- return props().then((resolvedProps) => {
270
- this.log("trace", message, resolvedProps);
271
- });
272
- }
273
- const result = props();
274
- if (result instanceof Promise) {
275
- if (!this.isEnabledFor("trace")) return Promise.resolve();
276
- return result.then((resolvedProps) => {
277
- this.log("trace", message, resolvedProps);
278
- });
279
- }
280
- this.log("trace", message, result);
281
- return;
282
- }
283
- this.log("trace", message, props ?? {});
284
- } else if (typeof message === "function") this.logLazily("trace", message);
281
+ if (typeof message === "string") return logStringMessage(this, "trace", message, values[0]);
282
+ else if (typeof message === "function") this.logLazily("trace", message);
285
283
  else if (!Array.isArray(message)) this.log("trace", "{*}", message);
286
284
  else this.logTemplate("trace", message, values);
287
285
  }
288
286
  debug(message, ...values) {
289
- if (typeof message === "string") {
290
- const props = values[0];
291
- if (typeof props === "function") {
292
- if (props.constructor.name === "AsyncFunction") {
293
- if (!this.isEnabledFor("debug")) return Promise.resolve();
294
- return props().then((resolvedProps) => {
295
- this.log("debug", message, resolvedProps);
296
- });
297
- }
298
- const result = props();
299
- if (result instanceof Promise) {
300
- if (!this.isEnabledFor("debug")) return Promise.resolve();
301
- return result.then((resolvedProps) => {
302
- this.log("debug", message, resolvedProps);
303
- });
304
- }
305
- this.log("debug", message, result);
306
- return;
307
- }
308
- this.log("debug", message, props ?? {});
309
- } else if (typeof message === "function") this.logLazily("debug", message);
287
+ if (typeof message === "string") return logStringMessage(this, "debug", message, values[0]);
288
+ else if (typeof message === "function") this.logLazily("debug", message);
310
289
  else if (!Array.isArray(message)) this.log("debug", "{*}", message);
311
290
  else this.logTemplate("debug", message, values);
312
291
  }
313
292
  info(message, ...values) {
314
- if (typeof message === "string") {
315
- const props = values[0];
316
- if (typeof props === "function") {
317
- if (props.constructor.name === "AsyncFunction") {
318
- if (!this.isEnabledFor("info")) return Promise.resolve();
319
- return props().then((resolvedProps) => {
320
- this.log("info", message, resolvedProps);
321
- });
322
- }
323
- const result = props();
324
- if (result instanceof Promise) {
325
- if (!this.isEnabledFor("info")) return Promise.resolve();
326
- return result.then((resolvedProps) => {
327
- this.log("info", message, resolvedProps);
328
- });
329
- }
330
- this.log("info", message, result);
331
- return;
332
- }
333
- this.log("info", message, props ?? {});
334
- } else if (typeof message === "function") this.logLazily("info", message);
293
+ if (typeof message === "string") return logStringMessage(this, "info", message, values[0]);
294
+ else if (typeof message === "function") this.logLazily("info", message);
335
295
  else if (!Array.isArray(message)) this.log("info", "{*}", message);
336
296
  else this.logTemplate("info", message, values);
337
297
  }
298
+ logError(level, error, props) {
299
+ if (typeof props !== "function") {
300
+ this.log(level, "{error.message}", {
301
+ ...props,
302
+ error
303
+ });
304
+ return;
305
+ }
306
+ if (!this.isEnabledFor(level)) return Promise.resolve();
307
+ const result = props();
308
+ if (result instanceof Promise) return result.then((resolved) => {
309
+ this.log(level, "{error.message}", {
310
+ ...resolved,
311
+ error
312
+ });
313
+ });
314
+ this.log(level, "{error.message}", {
315
+ ...result,
316
+ error
317
+ });
318
+ }
338
319
  warn(message, ...values) {
339
- if (message instanceof Error) this.log("warning", "{error.message}", { error: message });
320
+ if (message instanceof Error) return this.logError("warning", message, values[0]);
340
321
  else if (typeof message === "string" && values[0] instanceof Error) this.log("warning", message, { error: values[0] });
341
- else if (typeof message === "string") {
342
- const props = values[0];
343
- if (typeof props === "function") {
344
- if (props.constructor.name === "AsyncFunction") {
345
- if (!this.isEnabledFor("warning")) return Promise.resolve();
346
- return props().then((resolvedProps) => {
347
- this.log("warning", message, resolvedProps);
348
- });
349
- }
350
- const result = props();
351
- if (result instanceof Promise) {
352
- if (!this.isEnabledFor("warning")) return Promise.resolve();
353
- return result.then((resolvedProps) => {
354
- this.log("warning", message, resolvedProps);
355
- });
356
- }
357
- this.log("warning", message, result);
358
- return;
359
- }
360
- this.log("warning", message, props ?? {});
361
- } else if (typeof message === "function") this.logLazily("warning", message);
322
+ else if (typeof message === "string") return logStringMessage(this, "warning", message, values[0]);
323
+ else if (typeof message === "function") this.logLazily("warning", message);
362
324
  else if (!Array.isArray(message)) this.log("warning", "{*}", message);
363
325
  else this.logTemplate("warning", message, values);
364
326
  }
365
327
  warning(message, ...values) {
366
- if (message instanceof Error) this.log("warning", "{error.message}", { error: message });
328
+ if (message instanceof Error) return this.logError("warning", message, values[0]);
367
329
  else if (typeof message === "string" && values[0] instanceof Error) this.log("warning", message, { error: values[0] });
368
- else if (typeof message === "string") {
369
- const props = values[0];
370
- if (typeof props === "function") {
371
- if (props.constructor.name === "AsyncFunction") {
372
- if (!this.isEnabledFor("warning")) return Promise.resolve();
373
- return props().then((resolvedProps) => {
374
- this.log("warning", message, resolvedProps);
375
- });
376
- }
377
- const result = props();
378
- if (result instanceof Promise) {
379
- if (!this.isEnabledFor("warning")) return Promise.resolve();
380
- return result.then((resolvedProps) => {
381
- this.log("warning", message, resolvedProps);
382
- });
383
- }
384
- this.log("warning", message, result);
385
- return;
386
- }
387
- this.log("warning", message, props ?? {});
388
- } else if (typeof message === "function") this.logLazily("warning", message);
330
+ else if (typeof message === "string") return logStringMessage(this, "warning", message, values[0]);
331
+ else if (typeof message === "function") this.logLazily("warning", message);
389
332
  else if (!Array.isArray(message)) this.log("warning", "{*}", message);
390
333
  else this.logTemplate("warning", message, values);
391
334
  }
392
335
  error(message, ...values) {
393
- if (message instanceof Error) this.log("error", "{error.message}", { error: message });
336
+ if (message instanceof Error) return this.logError("error", message, values[0]);
394
337
  else if (typeof message === "string" && values[0] instanceof Error) this.log("error", message, { error: values[0] });
395
- else if (typeof message === "string") {
396
- const props = values[0];
397
- if (typeof props === "function") {
398
- if (props.constructor.name === "AsyncFunction") {
399
- if (!this.isEnabledFor("error")) return Promise.resolve();
400
- return props().then((resolvedProps) => {
401
- this.log("error", message, resolvedProps);
402
- });
403
- }
404
- const result = props();
405
- if (result instanceof Promise) {
406
- if (!this.isEnabledFor("error")) return Promise.resolve();
407
- return result.then((resolvedProps) => {
408
- this.log("error", message, resolvedProps);
409
- });
410
- }
411
- this.log("error", message, result);
412
- return;
413
- }
414
- this.log("error", message, props ?? {});
415
- } else if (typeof message === "function") this.logLazily("error", message);
338
+ else if (typeof message === "string") return logStringMessage(this, "error", message, values[0]);
339
+ else if (typeof message === "function") this.logLazily("error", message);
416
340
  else if (!Array.isArray(message)) this.log("error", "{*}", message);
417
341
  else this.logTemplate("error", message, values);
418
342
  }
419
343
  fatal(message, ...values) {
420
- if (message instanceof Error) this.log("fatal", "{error.message}", { error: message });
344
+ if (message instanceof Error) return this.logError("fatal", message, values[0]);
421
345
  else if (typeof message === "string" && values[0] instanceof Error) this.log("fatal", message, { error: values[0] });
422
- else if (typeof message === "string") {
423
- const props = values[0];
424
- if (typeof props === "function") {
425
- if (props.constructor.name === "AsyncFunction") {
426
- if (!this.isEnabledFor("fatal")) return Promise.resolve();
427
- return props().then((resolvedProps) => {
428
- this.log("fatal", message, resolvedProps);
429
- });
430
- }
431
- const result = props();
432
- if (result instanceof Promise) {
433
- if (!this.isEnabledFor("fatal")) return Promise.resolve();
434
- return result.then((resolvedProps) => {
435
- this.log("fatal", message, resolvedProps);
436
- });
437
- }
438
- this.log("fatal", message, result);
439
- return;
440
- }
441
- this.log("fatal", message, props ?? {});
442
- } else if (typeof message === "function") this.logLazily("fatal", message);
346
+ else if (typeof message === "string") return logStringMessage(this, "fatal", message, values[0]);
347
+ else if (typeof message === "function") this.logLazily("fatal", message);
443
348
  else if (!Array.isArray(message)) this.log("fatal", "{*}", message);
444
349
  else this.logTemplate("fatal", message, values);
445
350
  }
@@ -501,185 +406,73 @@ var LoggerCtx = class LoggerCtx {
501
406
  return this.logger.isEnabledFor(level);
502
407
  }
503
408
  trace(message, ...values) {
504
- if (typeof message === "string") {
505
- const props = values[0];
506
- if (typeof props === "function") {
507
- if (props.constructor.name === "AsyncFunction") {
508
- if (!this.isEnabledFor("trace")) return Promise.resolve();
509
- return props().then((resolvedProps) => {
510
- this.log("trace", message, resolvedProps);
511
- });
512
- }
513
- const result = props();
514
- if (result instanceof Promise) {
515
- if (!this.isEnabledFor("trace")) return Promise.resolve();
516
- return result.then((resolvedProps) => {
517
- this.log("trace", message, resolvedProps);
518
- });
519
- }
520
- this.log("trace", message, result);
521
- return;
522
- }
523
- this.log("trace", message, props ?? {});
524
- } else if (typeof message === "function") this.logLazily("trace", message);
409
+ if (typeof message === "string") return logStringMessage(this, "trace", message, values[0]);
410
+ else if (typeof message === "function") this.logLazily("trace", message);
525
411
  else if (!Array.isArray(message)) this.log("trace", "{*}", message);
526
412
  else this.logTemplate("trace", message, values);
527
413
  }
528
414
  debug(message, ...values) {
529
- if (typeof message === "string") {
530
- const props = values[0];
531
- if (typeof props === "function") {
532
- if (props.constructor.name === "AsyncFunction") {
533
- if (!this.isEnabledFor("debug")) return Promise.resolve();
534
- return props().then((resolvedProps) => {
535
- this.log("debug", message, resolvedProps);
536
- });
537
- }
538
- const result = props();
539
- if (result instanceof Promise) {
540
- if (!this.isEnabledFor("debug")) return Promise.resolve();
541
- return result.then((resolvedProps) => {
542
- this.log("debug", message, resolvedProps);
543
- });
544
- }
545
- this.log("debug", message, result);
546
- return;
547
- }
548
- this.log("debug", message, props ?? {});
549
- } else if (typeof message === "function") this.logLazily("debug", message);
415
+ if (typeof message === "string") return logStringMessage(this, "debug", message, values[0]);
416
+ else if (typeof message === "function") this.logLazily("debug", message);
550
417
  else if (!Array.isArray(message)) this.log("debug", "{*}", message);
551
418
  else this.logTemplate("debug", message, values);
552
419
  }
553
420
  info(message, ...values) {
554
- if (typeof message === "string") {
555
- const props = values[0];
556
- if (typeof props === "function") {
557
- if (props.constructor.name === "AsyncFunction") {
558
- if (!this.isEnabledFor("info")) return Promise.resolve();
559
- return props().then((resolvedProps) => {
560
- this.log("info", message, resolvedProps);
561
- });
562
- }
563
- const result = props();
564
- if (result instanceof Promise) {
565
- if (!this.isEnabledFor("info")) return Promise.resolve();
566
- return result.then((resolvedProps) => {
567
- this.log("info", message, resolvedProps);
568
- });
569
- }
570
- this.log("info", message, result);
571
- return;
572
- }
573
- this.log("info", message, props ?? {});
574
- } else if (typeof message === "function") this.logLazily("info", message);
421
+ if (typeof message === "string") return logStringMessage(this, "info", message, values[0]);
422
+ else if (typeof message === "function") this.logLazily("info", message);
575
423
  else if (!Array.isArray(message)) this.log("info", "{*}", message);
576
424
  else this.logTemplate("info", message, values);
577
425
  }
426
+ logError(level, error, props) {
427
+ if (typeof props !== "function") {
428
+ this.log(level, "{error.message}", {
429
+ ...props,
430
+ error
431
+ });
432
+ return;
433
+ }
434
+ if (!this.isEnabledFor(level)) return Promise.resolve();
435
+ const result = props();
436
+ if (result instanceof Promise) return result.then((resolved) => {
437
+ this.log(level, "{error.message}", {
438
+ ...resolved,
439
+ error
440
+ });
441
+ });
442
+ this.log(level, "{error.message}", {
443
+ ...result,
444
+ error
445
+ });
446
+ }
578
447
  warn(message, ...values) {
579
- if (message instanceof Error) this.log("warning", "{error.message}", { error: message });
448
+ if (message instanceof Error) return this.logError("warning", message, values[0]);
580
449
  else if (typeof message === "string" && values[0] instanceof Error) this.log("warning", message, { error: values[0] });
581
- else if (typeof message === "string") {
582
- const props = values[0];
583
- if (typeof props === "function") {
584
- if (props.constructor.name === "AsyncFunction") {
585
- if (!this.isEnabledFor("warning")) return Promise.resolve();
586
- return props().then((resolvedProps) => {
587
- this.log("warning", message, resolvedProps);
588
- });
589
- }
590
- const result = props();
591
- if (result instanceof Promise) {
592
- if (!this.isEnabledFor("warning")) return Promise.resolve();
593
- return result.then((resolvedProps) => {
594
- this.log("warning", message, resolvedProps);
595
- });
596
- }
597
- this.log("warning", message, result);
598
- return;
599
- }
600
- this.log("warning", message, props ?? {});
601
- } else if (typeof message === "function") this.logLazily("warning", message);
450
+ else if (typeof message === "string") return logStringMessage(this, "warning", message, values[0]);
451
+ else if (typeof message === "function") this.logLazily("warning", message);
602
452
  else if (!Array.isArray(message)) this.log("warning", "{*}", message);
603
453
  else this.logTemplate("warning", message, values);
604
454
  }
605
455
  warning(message, ...values) {
606
- if (message instanceof Error) this.log("warning", "{error.message}", { error: message });
456
+ if (message instanceof Error) return this.logError("warning", message, values[0]);
607
457
  else if (typeof message === "string" && values[0] instanceof Error) this.log("warning", message, { error: values[0] });
608
- else if (typeof message === "string") {
609
- const props = values[0];
610
- if (typeof props === "function") {
611
- if (props.constructor.name === "AsyncFunction") {
612
- if (!this.isEnabledFor("warning")) return Promise.resolve();
613
- return props().then((resolvedProps) => {
614
- this.log("warning", message, resolvedProps);
615
- });
616
- }
617
- const result = props();
618
- if (result instanceof Promise) {
619
- if (!this.isEnabledFor("warning")) return Promise.resolve();
620
- return result.then((resolvedProps) => {
621
- this.log("warning", message, resolvedProps);
622
- });
623
- }
624
- this.log("warning", message, result);
625
- return;
626
- }
627
- this.log("warning", message, props ?? {});
628
- } else if (typeof message === "function") this.logLazily("warning", message);
458
+ else if (typeof message === "string") return logStringMessage(this, "warning", message, values[0]);
459
+ else if (typeof message === "function") this.logLazily("warning", message);
629
460
  else if (!Array.isArray(message)) this.log("warning", "{*}", message);
630
461
  else this.logTemplate("warning", message, values);
631
462
  }
632
463
  error(message, ...values) {
633
- if (message instanceof Error) this.log("error", "{error.message}", { error: message });
464
+ if (message instanceof Error) return this.logError("error", message, values[0]);
634
465
  else if (typeof message === "string" && values[0] instanceof Error) this.log("error", message, { error: values[0] });
635
- else if (typeof message === "string") {
636
- const props = values[0];
637
- if (typeof props === "function") {
638
- if (props.constructor.name === "AsyncFunction") {
639
- if (!this.isEnabledFor("error")) return Promise.resolve();
640
- return props().then((resolvedProps) => {
641
- this.log("error", message, resolvedProps);
642
- });
643
- }
644
- const result = props();
645
- if (result instanceof Promise) {
646
- if (!this.isEnabledFor("error")) return Promise.resolve();
647
- return result.then((resolvedProps) => {
648
- this.log("error", message, resolvedProps);
649
- });
650
- }
651
- this.log("error", message, result);
652
- return;
653
- }
654
- this.log("error", message, props ?? {});
655
- } else if (typeof message === "function") this.logLazily("error", message);
466
+ else if (typeof message === "string") return logStringMessage(this, "error", message, values[0]);
467
+ else if (typeof message === "function") this.logLazily("error", message);
656
468
  else if (!Array.isArray(message)) this.log("error", "{*}", message);
657
469
  else this.logTemplate("error", message, values);
658
470
  }
659
471
  fatal(message, ...values) {
660
- if (message instanceof Error) this.log("fatal", "{error.message}", { error: message });
472
+ if (message instanceof Error) return this.logError("fatal", message, values[0]);
661
473
  else if (typeof message === "string" && values[0] instanceof Error) this.log("fatal", message, { error: values[0] });
662
- else if (typeof message === "string") {
663
- const props = values[0];
664
- if (typeof props === "function") {
665
- if (props.constructor.name === "AsyncFunction") {
666
- if (!this.isEnabledFor("fatal")) return Promise.resolve();
667
- return props().then((resolvedProps) => {
668
- this.log("fatal", message, resolvedProps);
669
- });
670
- }
671
- const result = props();
672
- if (result instanceof Promise) {
673
- if (!this.isEnabledFor("fatal")) return Promise.resolve();
674
- return result.then((resolvedProps) => {
675
- this.log("fatal", message, resolvedProps);
676
- });
677
- }
678
- this.log("fatal", message, result);
679
- return;
680
- }
681
- this.log("fatal", message, props ?? {});
682
- } else if (typeof message === "function") this.logLazily("fatal", message);
474
+ else if (typeof message === "string") return logStringMessage(this, "fatal", message, values[0]);
475
+ else if (typeof message === "function") this.logLazily("fatal", message);
683
476
  else if (!Array.isArray(message)) this.log("fatal", "{*}", message);
684
477
  else this.logTemplate("fatal", message, values);
685
478
  }
package/dist/logger.d.cts CHANGED
@@ -60,6 +60,13 @@ declare function lazy<T>(getter: () => T): Lazy<T>;
60
60
  * logger.error `An error message with ${value}.`;
61
61
  * logger.fatal `A fatal error message with ${value}.`;
62
62
  * ```
63
+ *
64
+ * Callback-based string-message overloads should be treated as
65
+ * fire-and-forget. Async callbacks return `Promise<void>`, and when a
66
+ * callback is filtered out because the level is disabled an implementation may
67
+ * still return an already-resolved promise so the async path remains awaitable
68
+ * without invoking the callback. Call sites should not branch on these
69
+ * return values.
63
70
  */
64
71
  interface Logger {
65
72
  /**
@@ -433,6 +440,30 @@ interface Logger {
433
440
  * @since 2.0.0
434
441
  */
435
442
  warn(error: Error): void;
443
+ /**
444
+ * Log a warning with additional properties.
445
+ *
446
+ * This overload is a shorthand for logging an {@link Error} instance as a
447
+ * structured property while also adding extra properties.
448
+ *
449
+ * ```typescript
450
+ * logger.warn(new Error("Oops"), { requestId });
451
+ * ```
452
+ *
453
+ * @param error The error to log.
454
+ * @param properties Additional properties to log alongside the error.
455
+ * @since 2.1.0
456
+ */
457
+ warn(error: Error, properties?: Record<string, unknown> | (() => Record<string, unknown>)): void;
458
+ /**
459
+ * Log a warning with additional properties computed asynchronously.
460
+ *
461
+ * @param error The error to log.
462
+ * @param properties An async callback that returns the properties.
463
+ * @returns A promise that resolves when the log is written.
464
+ * @since 2.1.0
465
+ */
466
+ warn(error: Error, properties: () => Promise<Record<string, unknown>>): Promise<void>;
436
467
  /**
437
468
  * Log a warning message with an {@link Error}.
438
469
  *
@@ -562,6 +593,30 @@ interface Logger {
562
593
  * @since 2.0.0
563
594
  */
564
595
  warning(error: Error): void;
596
+ /**
597
+ * Log a warning with additional properties.
598
+ *
599
+ * This overload is a shorthand for logging an {@link Error} instance as a
600
+ * structured property while also adding extra properties.
601
+ *
602
+ * ```typescript
603
+ * logger.warning(new Error("Oops"), { requestId });
604
+ * ```
605
+ *
606
+ * @param error The error to log.
607
+ * @param properties Additional properties to log alongside the error.
608
+ * @since 2.1.0
609
+ */
610
+ warning(error: Error, properties?: Record<string, unknown> | (() => Record<string, unknown>)): void;
611
+ /**
612
+ * Log a warning with additional properties computed asynchronously.
613
+ *
614
+ * @param error The error to log.
615
+ * @param properties An async callback that returns the properties.
616
+ * @returns A promise that resolves when the log is written.
617
+ * @since 2.1.0
618
+ */
619
+ warning(error: Error, properties: () => Promise<Record<string, unknown>>): Promise<void>;
565
620
  /**
566
621
  * Log a warning message with an {@link Error}.
567
622
  *
@@ -694,6 +749,49 @@ interface Logger {
694
749
  * @since 2.0.0
695
750
  */
696
751
  error(error: Error): void;
752
+ /**
753
+ * Log an error with additional properties.
754
+ *
755
+ * This overload is a shorthand for logging an {@link Error} instance as a
756
+ * structured property while also adding extra properties.
757
+ *
758
+ * ```typescript
759
+ * logger.error(new Error("Oops"), { requestId });
760
+ * ```
761
+ *
762
+ * If the properties are expensive to compute, you can pass a callback that
763
+ * returns the properties:
764
+ *
765
+ * ```typescript
766
+ * logger.error(
767
+ * new Error("Oops"),
768
+ * () => ({ requestId: expensiveLookup() })
769
+ * );
770
+ * ```
771
+ *
772
+ * @param error The error to log.
773
+ * @param properties Additional properties to log alongside the error.
774
+ * @since 2.1.0
775
+ */
776
+ error(error: Error, properties?: Record<string, unknown> | (() => Record<string, unknown>)): void;
777
+ /**
778
+ * Log an error with additional properties computed asynchronously.
779
+ *
780
+ * Use this when the properties require async operations to compute:
781
+ *
782
+ * ```typescript
783
+ * await logger.error(
784
+ * new Error("Oops"),
785
+ * async () => ({ requestId: await fetchRequestId() })
786
+ * );
787
+ * ```
788
+ *
789
+ * @param error The error to log.
790
+ * @param properties An async callback that returns the properties.
791
+ * @returns A promise that resolves when the log is written.
792
+ * @since 2.1.0
793
+ */
794
+ error(error: Error, properties: () => Promise<Record<string, unknown>>): Promise<void>;
697
795
  /**
698
796
  * Log an error message with an {@link Error}.
699
797
  *
@@ -823,6 +921,30 @@ interface Logger {
823
921
  * @since 2.0.0
824
922
  */
825
923
  fatal(error: Error): void;
924
+ /**
925
+ * Log a fatal error with additional properties.
926
+ *
927
+ * This overload is a shorthand for logging an {@link Error} instance as a
928
+ * structured property while also adding extra properties.
929
+ *
930
+ * ```typescript
931
+ * logger.fatal(new Error("Oops"), { requestId });
932
+ * ```
933
+ *
934
+ * @param error The error to log.
935
+ * @param properties Additional properties to log alongside the error.
936
+ * @since 2.1.0
937
+ */
938
+ fatal(error: Error, properties?: Record<string, unknown> | (() => Record<string, unknown>)): void;
939
+ /**
940
+ * Log a fatal error with additional properties computed asynchronously.
941
+ *
942
+ * @param error The error to log.
943
+ * @param properties An async callback that returns the properties.
944
+ * @returns A promise that resolves when the log is written.
945
+ * @since 2.1.0
946
+ */
947
+ fatal(error: Error, properties: () => Promise<Record<string, unknown>>): Promise<void>;
826
948
  /**
827
949
  * Log a fatal error message with an {@link Error}.
828
950
  *
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.cts","names":[],"sources":["../src/logger.ts"],"sourcesContent":[],"mappings":";;;;;AAqBA;;;cARM,UAUmB,EAAA,OAAA,MAAA;AAAC;AAU1B;AA4BA;;;;AAA0C,UAxCzB,IAwCyB,CAAA,CAAA,CAAA,CAAA;EAAI,UAvClC,UAAA,CAuCkC,EAAA,IAAA;EAmC7B,SAAM,MAAA,EAAA,GAAA,GAzEE,CAyEF;;;;;;;;;AA8HO,iBA7Ld,MAAA,CA6Lc,KAAA,EAAA,OAAA,CAAA,EAAA,KAAA,IA7LmB,IA6LnB,CAAA,OAAA,CAAA;;;;;;;;;;;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