lograil 0.1.0 → 0.1.4

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.
Files changed (149) hide show
  1. package/CHANGELOG.md +105 -1
  2. package/README.md +3 -1
  3. package/dist/cjs/context/async-context.browser.d.ts +1 -7
  4. package/dist/cjs/context/async-context.browser.d.ts.map +1 -1
  5. package/dist/cjs/context/async-context.browser.js +4 -1
  6. package/dist/cjs/context/async-context.browser.js.map +1 -1
  7. package/dist/cjs/context/context.js +1 -1
  8. package/dist/cjs/context/context.js.map +1 -1
  9. package/dist/cjs/core/logger.d.ts +20 -16
  10. package/dist/cjs/core/logger.d.ts.map +1 -1
  11. package/dist/cjs/core/logger.js +115 -48
  12. package/dist/cjs/core/logger.js.map +1 -1
  13. package/dist/cjs/pipeline/formatter.d.ts.map +1 -1
  14. package/dist/cjs/pipeline/formatter.js +64 -31
  15. package/dist/cjs/pipeline/formatter.js.map +1 -1
  16. package/dist/cjs/pipeline/pipeline.d.ts.map +1 -1
  17. package/dist/cjs/pipeline/pipeline.js +2 -1
  18. package/dist/cjs/pipeline/pipeline.js.map +1 -1
  19. package/dist/cjs/pipeline/processor.d.ts.map +1 -1
  20. package/dist/cjs/pipeline/processor.js +18 -6
  21. package/dist/cjs/pipeline/processor.js.map +1 -1
  22. package/dist/cjs/pipeline/sampler.d.ts.map +1 -1
  23. package/dist/cjs/pipeline/sampler.js +5 -0
  24. package/dist/cjs/pipeline/sampler.js.map +1 -1
  25. package/dist/cjs/plugin/manager.d.ts.map +1 -1
  26. package/dist/cjs/plugin/manager.js +9 -1
  27. package/dist/cjs/plugin/manager.js.map +1 -1
  28. package/dist/cjs/plugin/otel-trace.d.ts.map +1 -1
  29. package/dist/cjs/plugin/otel-trace.js +4 -7
  30. package/dist/cjs/plugin/otel-trace.js.map +1 -1
  31. package/dist/cjs/runtime/electron-binding.d.ts +4 -0
  32. package/dist/cjs/runtime/electron-binding.d.ts.map +1 -1
  33. package/dist/cjs/runtime/electron-binding.js +24 -2
  34. package/dist/cjs/runtime/electron-binding.js.map +1 -1
  35. package/dist/cjs/runtime/electron.d.ts.map +1 -1
  36. package/dist/cjs/runtime/electron.js +7 -1
  37. package/dist/cjs/runtime/electron.js.map +1 -1
  38. package/dist/cjs/runtime/process-lifecycle.d.ts.map +1 -1
  39. package/dist/cjs/runtime/process-lifecycle.js +11 -0
  40. package/dist/cjs/runtime/process-lifecycle.js.map +1 -1
  41. package/dist/cjs/transport/cluster-ipc.d.ts +2 -0
  42. package/dist/cjs/transport/cluster-ipc.d.ts.map +1 -1
  43. package/dist/cjs/transport/cluster-ipc.js +53 -5
  44. package/dist/cjs/transport/cluster-ipc.js.map +1 -1
  45. package/dist/cjs/transport/console.d.ts.map +1 -1
  46. package/dist/cjs/transport/console.js +10 -9
  47. package/dist/cjs/transport/console.js.map +1 -1
  48. package/dist/cjs/transport/electron-ipc.d.ts +4 -17
  49. package/dist/cjs/transport/electron-ipc.d.ts.map +1 -1
  50. package/dist/cjs/transport/electron-ipc.js +42 -73
  51. package/dist/cjs/transport/electron-ipc.js.map +1 -1
  52. package/dist/cjs/transport/file.d.ts +10 -4
  53. package/dist/cjs/transport/file.d.ts.map +1 -1
  54. package/dist/cjs/transport/file.js +28 -8
  55. package/dist/cjs/transport/file.js.map +1 -1
  56. package/dist/cjs/transport/live.d.ts +2 -1
  57. package/dist/cjs/transport/live.d.ts.map +1 -1
  58. package/dist/cjs/transport/live.js +4 -1
  59. package/dist/cjs/transport/live.js.map +1 -1
  60. package/dist/cjs/transport/otlp.d.ts +1 -1
  61. package/dist/cjs/transport/otlp.d.ts.map +1 -1
  62. package/dist/cjs/transport/otlp.js +24 -21
  63. package/dist/cjs/transport/otlp.js.map +1 -1
  64. package/dist/cjs/transport/worker-ipc.d.ts +3 -0
  65. package/dist/cjs/transport/worker-ipc.d.ts.map +1 -1
  66. package/dist/cjs/transport/worker-ipc.js +76 -8
  67. package/dist/cjs/transport/worker-ipc.js.map +1 -1
  68. package/dist/cjs/types.d.ts +16 -5
  69. package/dist/cjs/types.d.ts.map +1 -1
  70. package/dist/cjs/types.js +5 -1
  71. package/dist/cjs/types.js.map +1 -1
  72. package/dist/esm/context/async-context.browser.d.ts +1 -7
  73. package/dist/esm/context/async-context.browser.d.ts.map +1 -1
  74. package/dist/esm/context/async-context.browser.js +4 -1
  75. package/dist/esm/context/async-context.browser.js.map +1 -1
  76. package/dist/esm/context/context.js +1 -1
  77. package/dist/esm/context/context.js.map +1 -1
  78. package/dist/esm/core/logger.d.ts +20 -16
  79. package/dist/esm/core/logger.d.ts.map +1 -1
  80. package/dist/esm/core/logger.js +115 -48
  81. package/dist/esm/core/logger.js.map +1 -1
  82. package/dist/esm/pipeline/formatter.d.ts.map +1 -1
  83. package/dist/esm/pipeline/formatter.js +64 -31
  84. package/dist/esm/pipeline/formatter.js.map +1 -1
  85. package/dist/esm/pipeline/pipeline.d.ts.map +1 -1
  86. package/dist/esm/pipeline/pipeline.js +2 -1
  87. package/dist/esm/pipeline/pipeline.js.map +1 -1
  88. package/dist/esm/pipeline/processor.d.ts.map +1 -1
  89. package/dist/esm/pipeline/processor.js +18 -6
  90. package/dist/esm/pipeline/processor.js.map +1 -1
  91. package/dist/esm/pipeline/sampler.d.ts.map +1 -1
  92. package/dist/esm/pipeline/sampler.js +5 -0
  93. package/dist/esm/pipeline/sampler.js.map +1 -1
  94. package/dist/esm/plugin/manager.d.ts.map +1 -1
  95. package/dist/esm/plugin/manager.js +9 -1
  96. package/dist/esm/plugin/manager.js.map +1 -1
  97. package/dist/esm/plugin/otel-trace.d.ts.map +1 -1
  98. package/dist/esm/plugin/otel-trace.js +4 -7
  99. package/dist/esm/plugin/otel-trace.js.map +1 -1
  100. package/dist/esm/runtime/electron-binding.d.ts +4 -0
  101. package/dist/esm/runtime/electron-binding.d.ts.map +1 -1
  102. package/dist/esm/runtime/electron-binding.js +24 -2
  103. package/dist/esm/runtime/electron-binding.js.map +1 -1
  104. package/dist/esm/runtime/electron.d.ts.map +1 -1
  105. package/dist/esm/runtime/electron.js +7 -1
  106. package/dist/esm/runtime/electron.js.map +1 -1
  107. package/dist/esm/runtime/process-lifecycle.d.ts.map +1 -1
  108. package/dist/esm/runtime/process-lifecycle.js +11 -0
  109. package/dist/esm/runtime/process-lifecycle.js.map +1 -1
  110. package/dist/esm/transport/cluster-ipc.d.ts +2 -0
  111. package/dist/esm/transport/cluster-ipc.d.ts.map +1 -1
  112. package/dist/esm/transport/cluster-ipc.js +52 -5
  113. package/dist/esm/transport/cluster-ipc.js.map +1 -1
  114. package/dist/esm/transport/console.d.ts.map +1 -1
  115. package/dist/esm/transport/console.js +10 -9
  116. package/dist/esm/transport/console.js.map +1 -1
  117. package/dist/esm/transport/electron-ipc.d.ts +4 -17
  118. package/dist/esm/transport/electron-ipc.d.ts.map +1 -1
  119. package/dist/esm/transport/electron-ipc.js +42 -71
  120. package/dist/esm/transport/electron-ipc.js.map +1 -1
  121. package/dist/esm/transport/file.d.ts +10 -4
  122. package/dist/esm/transport/file.d.ts.map +1 -1
  123. package/dist/esm/transport/file.js +28 -8
  124. package/dist/esm/transport/file.js.map +1 -1
  125. package/dist/esm/transport/live.d.ts +2 -1
  126. package/dist/esm/transport/live.d.ts.map +1 -1
  127. package/dist/esm/transport/live.js +4 -1
  128. package/dist/esm/transport/live.js.map +1 -1
  129. package/dist/esm/transport/otlp.d.ts +1 -1
  130. package/dist/esm/transport/otlp.d.ts.map +1 -1
  131. package/dist/esm/transport/otlp.js +24 -21
  132. package/dist/esm/transport/otlp.js.map +1 -1
  133. package/dist/esm/transport/worker-ipc.d.ts +3 -0
  134. package/dist/esm/transport/worker-ipc.d.ts.map +1 -1
  135. package/dist/esm/transport/worker-ipc.js +75 -8
  136. package/dist/esm/transport/worker-ipc.js.map +1 -1
  137. package/dist/esm/types.d.ts +16 -5
  138. package/dist/esm/types.d.ts.map +1 -1
  139. package/dist/esm/types.js +5 -1
  140. package/dist/esm/types.js.map +1 -1
  141. package/package.json +12 -3
  142. package/dist/cjs/transport/rotating-file.d.ts +0 -67
  143. package/dist/cjs/transport/rotating-file.d.ts.map +0 -1
  144. package/dist/cjs/transport/rotating-file.js +0 -179
  145. package/dist/cjs/transport/rotating-file.js.map +0 -1
  146. package/dist/esm/transport/rotating-file.d.ts +0 -67
  147. package/dist/esm/transport/rotating-file.d.ts.map +0 -1
  148. package/dist/esm/transport/rotating-file.js +0 -175
  149. package/dist/esm/transport/rotating-file.js.map +0 -1
@@ -8,9 +8,12 @@ export type LogLevelName = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fata
8
8
  export type LogLevelValue = number;
9
9
  /**
10
10
  * Ordered by severity. Higher value means more severe.
11
+ * @internal
11
12
  */
12
13
  export declare const LOG_LEVELS: Record<LogLevelName, LogLevelValue>;
14
+ /** @internal */
13
15
  export declare const LOG_LEVEL_NAMES: LogLevelName[];
16
+ /** @internal */
14
17
  export declare function isLogLevelName(value: unknown): value is LogLevelName;
15
18
  /**
16
19
  * A single structured log record produced by the Logger.
@@ -35,7 +38,10 @@ export interface LogEntry {
35
38
  message: string;
36
39
  /** Extra positional arguments passed to the log call. */
37
40
  args: unknown[];
38
- /** Epoch milliseconds when the entry was created. */
41
+ /**
42
+ * Epoch milliseconds when the entry was created. Internal — prefer `time`
43
+ * (ISO string) for display.
44
+ */
39
45
  timestamp: number;
40
46
  /** Coarse ISO timestamp for display / serialization. */
41
47
  time: string;
@@ -47,26 +53,31 @@ export interface LogEntry {
47
53
  context: Record<string, unknown>;
48
54
  /** One-off metadata attached to this entry only. */
49
55
  metadata: Record<string, unknown>;
50
- /** Error object when the entry was created from one. */
51
- error?: Error;
56
+ /** Error-like object when the entry was created from one. Supports both
57
+ * standard `Error` instances and arbitrary values (e.g. string messages) so
58
+ * callers can log non-Error exceptions without type casting. */
59
+ error?: unknown;
52
60
  }
53
61
  export type LogFn = (message: unknown, ...args: unknown[]) => void;
54
62
  export interface LoggerMethods {
55
63
  trace: LogFn;
56
64
  debug: LogFn;
57
65
  info: LogFn;
66
+ /** Alias for {@link info}. */
67
+ log: LogFn;
58
68
  warn: LogFn;
59
69
  error: LogFn;
60
70
  fatal: LogFn;
61
71
  }
62
72
  export type LogLevelInput = LogLevelName | LogLevelValue;
73
+ /** @internal */
63
74
  export declare function normalizeLevel(input: LogLevelInput): LogLevelValue;
64
- /** Cross-process command sent over IPC to change log level. */
75
+ /** @internal Cross-process command sent over IPC to change log level. */
65
76
  export interface LogLevelCommand {
66
77
  __lograilCmd: true;
67
78
  __lograilCmdType: 'setLevel';
68
79
  level: LogLevelName | LogLevelValue;
69
80
  }
70
- /** Returns true when the value is a {@link LogLevelCommand}. */
81
+ /** @internal Returns true when the value is a {@link LogLevelCommand}. */
71
82
  export declare function isLogLevelCommand(value: unknown): value is LogLevelCommand;
72
83
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAEnF,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,YAAY,EAAE,aAAa,CAO1D,CAAC;AAEF,eAAO,MAAM,eAAe,EAA8B,YAAY,EAAE,CAAC;AAEzE,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAEpE;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,QAAQ;IACvB,gDAAgD;IAChD,KAAK,EAAE,aAAa,CAAC;IACrB,iCAAiC;IACjC,SAAS,EAAE,YAAY,CAAC;IACxB,4BAA4B;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,yDAAyD;IACzD,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,qDAAqD;IACrD,SAAS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CAAC;IACb,KAAK,EAAE,KAAK,CAAC;CACd;AAED,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,aAAa,CAAC;AAEzD,gBAAgB;AAChB,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CASlE;AAED,yEAAyE;AACzE,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,IAAI,CAAC;IACnB,gBAAgB,EAAE,UAAU,CAAC;IAC7B,KAAK,EAAE,YAAY,GAAG,aAAa,CAAC;CACrC;AAED,0EAA0E;AAC1E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAO1E"}
package/dist/cjs/types.js CHANGED
@@ -12,6 +12,7 @@ exports.normalizeLevel = normalizeLevel;
12
12
  exports.isLogLevelCommand = isLogLevelCommand;
13
13
  /**
14
14
  * Ordered by severity. Higher value means more severe.
15
+ * @internal
15
16
  */
16
17
  exports.LOG_LEVELS = {
17
18
  trace: 10,
@@ -21,10 +22,13 @@ exports.LOG_LEVELS = {
21
22
  error: 50,
22
23
  fatal: 60,
23
24
  };
25
+ /** @internal */
24
26
  exports.LOG_LEVEL_NAMES = Object.keys(exports.LOG_LEVELS);
27
+ /** @internal */
25
28
  function isLogLevelName(value) {
26
29
  return typeof value === 'string' && value in exports.LOG_LEVELS;
27
30
  }
31
+ /** @internal */
28
32
  function normalizeLevel(input) {
29
33
  if (typeof input === 'number') {
30
34
  return input;
@@ -35,7 +39,7 @@ function normalizeLevel(input) {
35
39
  }
36
40
  return value;
37
41
  }
38
- /** Returns true when the value is a {@link LogLevelCommand}. */
42
+ /** @internal Returns true when the value is a {@link LogLevelCommand}. */
39
43
  function isLogLevelCommand(value) {
40
44
  return (typeof value === 'object' &&
41
45
  value !== null &&
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAoBH,wCAEC;AAsDD,wCASC;AAUD,8CA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AAE;CACV,CAAC;AAEF,gBAAgB;AACH,QAAA,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,kBAAU,CAAmB,CAAC;AAEzE,gBAAgB;AAChB,SAAgB,cAAc,CAAC,KAAc;IAC3C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,IAAI,kBAAU,CAAC;AAC1D,CAAC;AA6DD,gBAAgB;AAChB,SAAgB,cAAc,CAAC,KAAoB;IACjD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,KAAK,GAAG,kBAAU,CAAC,KAAK,CAAC,CAAC;IAChC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,sBAAsB,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AASD,0EAA0E;AAC1E,SAAgB,iBAAiB,CAAC,KAAc;IAC9C,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACb,KAAiC,CAAC,YAAY,KAAK,IAAI;QACvD,KAAiC,CAAC,gBAAgB,KAAK,UAAU,CACnE,CAAC;AACJ,CAAC"}
@@ -1,10 +1,4 @@
1
- export type AmbientContext = Record<string, unknown>;
2
- /**
3
- * Browser / non-Node stub. `AsyncLocalStorage` is unavailable here, so ambient
4
- * context is a no-op — logs are unaffected and no context propagates. The real
5
- * implementation (`async-context.ts`) is selected over this file in Node builds
6
- * via the `browser` field in `package.json`.
7
- */
1
+ import type { AmbientContext } from './async-context.js';
8
2
  export declare const asyncContext: {
9
3
  run<T>(fn: () => T, _context: AmbientContext): T;
10
4
  runAsync<T>(fn: () => Promise<T>, _context: AmbientContext): Promise<T>;
@@ -1 +1 @@
1
- {"version":3,"file":"async-context.browser.d.ts","sourceRoot":"","sources":["../../../src/context/async-context.browser.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAErD;;;;;GAKG;AACH,eAAO,MAAM,YAAY;QACnB,CAAC,MAAM,MAAM,CAAC,YAAY,cAAc,GAAG,CAAC;aAGvC,CAAC,MAAM,MAAM,OAAO,CAAC,CAAC,CAAC,YAAY,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;WAGhE,cAAc;iBAGR,OAAO;CAGrB,CAAC;AAEF,0FAA0F;AAC1F,wBAAgB,cAAc,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,cAAc,GAAG,CAAC,CAE1E"}
1
+ {"version":3,"file":"async-context.browser.d.ts","sourceRoot":"","sources":["../../../src/context/async-context.browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAWzD,eAAO,MAAM,YAAY;QACnB,CAAC,MAAM,MAAM,CAAC,YAAY,cAAc,GAAG,CAAC;aAGvC,CAAC,MAAM,MAAM,OAAO,CAAC,CAAC,CAAC,YAAY,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;WAGhE,cAAc;iBAGR,OAAO;CAGrB,CAAC;AAEF,0FAA0F;AAC1F,wBAAgB,cAAc,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,cAAc,GAAG,CAAC,CAE1E"}
@@ -4,6 +4,9 @@
4
4
  * implementation (`async-context.ts`) is selected over this file in Node builds
5
5
  * via the `browser` field in `package.json`.
6
6
  */
7
+ // Shared frozen empty object returned when no async store is active, so the
8
+ // common (no ambient context) path allocates nothing on every `get()`.
9
+ const EMPTY_AMBIENT = Object.freeze({});
7
10
  export const asyncContext = {
8
11
  run(fn, _context) {
9
12
  return fn();
@@ -12,7 +15,7 @@ export const asyncContext = {
12
15
  return fn();
13
16
  },
14
17
  get() {
15
- return {};
18
+ return EMPTY_AMBIENT;
16
19
  },
17
20
  supported() {
18
21
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"async-context.browser.js","sourceRoot":"","sources":["../../../src/context/async-context.browser.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,GAAG,CAAI,EAAW,EAAE,QAAwB;QAC1C,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;IACD,QAAQ,CAAI,EAAoB,EAAE,QAAwB;QACxD,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;IACD,GAAG;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,SAAS;QACP,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC;AAEF,0FAA0F;AAC1F,MAAM,UAAU,cAAc,CAAI,EAAW,EAAE,QAAwB;IACrE,OAAO,EAAE,EAAE,CAAC;AACd,CAAC"}
1
+ {"version":3,"file":"async-context.browser.js","sourceRoot":"","sources":["../../../src/context/async-context.browser.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,4EAA4E;AAC5E,uEAAuE;AACvE,MAAM,aAAa,GAAmB,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACxD,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,GAAG,CAAI,EAAW,EAAE,QAAwB;QAC1C,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;IACD,QAAQ,CAAI,EAAoB,EAAE,QAAwB;QACxD,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;IACD,GAAG;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;IACD,SAAS;QACP,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC;AAEF,0FAA0F;AAC1F,MAAM,UAAU,cAAc,CAAI,EAAW,EAAE,QAAwB;IACrE,OAAO,EAAE,EAAE,CAAC;AACd,CAAC"}
@@ -27,7 +27,7 @@ export function createContextStore(initial) {
27
27
  // Avoid cloning (and allocating) when the store is empty — the shared
28
28
  // frozen object can never be mutated by callers.
29
29
  for (const _k in data)
30
- return { ...data };
30
+ return Object.assign({}, data);
31
31
  return EMPTY_CONTEXT;
32
32
  },
33
33
  set(key, value) {
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/context/context.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiBH,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,CAA4B,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC;AAE1C,uDAAuD;AACvD,MAAM,UAAU,aAAa,CAAC,CAA0B;IACtD,KAAK,MAAM,EAAE,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IACjC,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,OAAiC;IAClE,IAAI,IAAI,GAA4B,EAAE,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,CAAC;IAE3D,MAAM,KAAK,GAAiB;QAC1B,GAAG;YACD,sEAAsE;YACtE,iDAAiD;YACjD,KAAK,MAAM,EAAE,IAAI,IAAI;gBAAE,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;YAC1C,OAAO,aAAa,CAAC;QACvB,CAAC;QACD,GAAG,CAAC,GAAG,EAAE,KAAK;YACZ,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACpB,CAAC;QACD,KAAK,CAAC,MAAM;YACV,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,CAAC,GAAG;YACR,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;QACD,KAAK;YACH,IAAI,GAAG,EAAE,CAAC;QACZ,CAAC;QACD,KAAK;YACH,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAClC,CAAC;KACF,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC"}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/context/context.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiBH,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,CAA4B,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC;AAE1C,uDAAuD;AACvD,MAAM,UAAU,aAAa,CAAC,CAA0B;IACtD,KAAK,MAAM,EAAE,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IACjC,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,OAAiC;IAClE,IAAI,IAAI,GAA4B,EAAE,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,CAAC;IAE3D,MAAM,KAAK,GAAiB;QAC1B,GAAG;YACD,sEAAsE;YACtE,iDAAiD;YACjD,KAAK,MAAM,EAAE,IAAI,IAAI;gBAAE,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;YACtD,OAAO,aAAa,CAAC;QACvB,CAAC;QACD,GAAG,CAAC,GAAG,EAAE,KAAK;YACZ,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACpB,CAAC;QACD,KAAK,CAAC,MAAM;YACV,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,CAAC,GAAG;YACR,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;QACD,KAAK;YACH,IAAI,GAAG,EAAE,CAAC;QACZ,CAAC;QACD,KAAK;YACH,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAClC,CAAC;KACF,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -42,9 +42,9 @@ export interface LoggerOptions {
42
42
  /**
43
43
  * Maximum time (ms) to spend flushing on process exit (`beforeExit`,
44
44
  * `SIGINT`, `SIGTERM`) before giving up and letting the process exit, so a
45
- * stalled transport flush can never hang shutdown. Default `2000`.
45
+ * stalled transport flush can never hang shutdown. Default `2000`.\
46
46
  */
47
- exitFlushTimeoutMs?: number;
47
+ flushTimeoutMs?: number;
48
48
  /** Optional scope / namespace for this logger. */
49
49
  scope?: string;
50
50
  /** Runtime adapter. Auto-detected when omitted. */
@@ -69,17 +69,17 @@ export interface LoggerOptions {
69
69
  */
70
70
  levelEnvVar?: string | null;
71
71
  /**
72
- * Scope/namespace filter. A comma- or space-separated list of glob patterns
72
+ * Scope filter. A comma- or space-separated list of glob patterns
73
73
  * (with `*` wildcards); a leading `-` excludes. Only entries whose `scope`
74
- * matches are emitted. Read automatically from `namespaceEnvVar` when omitted.
74
+ * matches are emitted. Read automatically from `scopeFilterEnvVar` when omitted.
75
75
  */
76
- namespaceFilter?: string | string[];
76
+ scopeFilter?: string | string[];
77
77
  /**
78
- * Environment variable whose value supplies the namespace filter when
79
- * `namespaceFilter` is not set. Defaults to `"LOGRAIL_DEBUG"`. Set to `null`
78
+ * Environment variable whose value supplies the scope filter when
79
+ * `scopeFilter` is not set. Defaults to `"LOGRAIL_DEBUG"`. Set to `null`
80
80
  * to disable.
81
81
  */
82
- namespaceEnvVar?: string | null;
82
+ scopeFilterEnvVar?: string | null;
83
83
  }
84
84
  /**
85
85
  * Internal options passed by `scope`/`child` to build a **lightweight** child
@@ -115,12 +115,14 @@ export declare class Logger implements LoggerMethods {
115
115
  private parent?;
116
116
  private levelOverride?;
117
117
  /**
118
- * Sequences the async plugin-interception step so entries are processed in
119
- * emit order. Transport writes fan out to their own per-transport queues
120
- * (see `transportQueues`), so a slow/blocked transport can never stall the
121
- * others or this front queue.
118
+ * Bounded async queue for plugin interception. Tracks in-flight entries so
119
+ * `flush()` and `destroy()` know when all interceptions are done without
120
+ * letting the dispatch chain grow unboundedly (each push would append a
121
+ * `.then()` to an ever-longer Promise chain).
122
122
  */
123
- private dispatchQueue;
123
+ private dispatchInflight;
124
+ private dispatchDrain;
125
+ private dispatchDrainResolve;
124
126
  /** Independent async-write queue per transport. */
125
127
  private transportQueues;
126
128
  private destroyed;
@@ -130,9 +132,9 @@ export declare class Logger implements LoggerMethods {
130
132
  private removeProcessHandlers?;
131
133
  private onLoggerError?;
132
134
  private writeTimeoutMs;
133
- private exitFlushTimeoutMs;
135
+ private flushTimeoutMs;
134
136
  private _exiting;
135
- private namespaceFilter?;
137
+ private scopeFilter?;
136
138
  /** True for loggers created via `scope`/`child` (share the parent's plumbing). */
137
139
  private isChild;
138
140
  /** Cached peer process level. When set, takes precedence over local `level` in `getLevel()`. */
@@ -209,6 +211,8 @@ export declare class Logger implements LoggerMethods {
209
211
  trace: LogFn;
210
212
  debug: LogFn;
211
213
  info: LogFn;
214
+ /** Alias for {@link info}. */
215
+ log: LogFn;
212
216
  warn: LogFn;
213
217
  error: LogFn;
214
218
  fatal: LogFn;
@@ -241,7 +245,7 @@ export declare class Logger implements LoggerMethods {
241
245
  * exit the process) without risking a hang on a stalled transport.
242
246
  */
243
247
  private flushWithTimeout;
244
- /** Set the max time (ms) to flush on process exit before giving up. */
248
+ /** Set the max time (ms) to flush before process exit before giving up. */
245
249
  setExitFlushTimeout(ms: number): this;
246
250
  /** Get the current exit-flush timeout (ms). */
247
251
  getExitFlushTimeout(): number;
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/core/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE,aAAa,EAAgB,MAAM,aAAa,CAAC;AAE/F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAGnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA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ad(TIME_DATE.getUTCFullYear(), 4)}-${pad(TIME_DATE.getUTCMonth() + 1, 2)}-${pad(TIME_DATE.getUTCDate(), 2)}T${pad(TIME_DATE.getUTCHours(), 2)}:${pad(TIME_DATE.getUTCMinutes(), 2)}:${pad(TIME_DATE.getUTCSeconds(), 2)}.${pad(TIME_DATE.getUTCMilliseconds(), 3)}Z`;
31
31
  }
32
+ /** Cache compiled namespace filters by normalized input to avoid recompiling regexes on every call. */
33
+ const nsFilterCache = new Map();
34
+ function serializeNsInput(input) {
35
+ if (!input)
36
+ return '';
37
+ if (Array.isArray(input))
38
+ return input.join(',');
39
+ return input;
40
+ }
32
41
  function escapeRegex(s) {
33
42
  return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
34
43
  }
@@ -45,22 +54,34 @@ function toPattern(token) {
45
54
  * `undefined` (no filtering).
46
55
  */
47
56
  function compileNamespaceFilter(input) {
48
- if (!input || (Array.isArray(input) && input.length === 0))
49
- return undefined;
50
- const tokens = (Array.isArray(input) ? input : input.split(/[ ,]+/))
51
- .map((t) => t.trim())
52
- .filter(Boolean);
53
- if (tokens.length === 0)
54
- return undefined;
55
- const includes = [];
56
- const excludes = [];
57
- for (const token of tokens) {
58
- if (token.startsWith('-'))
59
- excludes.push(toPattern(token.slice(1)));
60
- else
61
- includes.push(toPattern(token));
57
+ const key = serializeNsInput(input);
58
+ if (nsFilterCache.has(key))
59
+ return nsFilterCache.get(key);
60
+ let result;
61
+ if (!input || (Array.isArray(input) && input.length === 0)) {
62
+ result = undefined;
63
+ }
64
+ else {
65
+ const tokens = (Array.isArray(input) ? input : input.split(/[ ,]+/))
66
+ .map((t) => t.trim())
67
+ .filter(Boolean);
68
+ if (tokens.length === 0) {
69
+ result = undefined;
70
+ }
71
+ else {
72
+ const includes = [];
73
+ const excludes = [];
74
+ for (const token of tokens) {
75
+ if (token.startsWith('-'))
76
+ excludes.push(toPattern(token.slice(1)));
77
+ else
78
+ includes.push(toPattern(token));
79
+ }
80
+ result = { includes, excludes };
81
+ }
62
82
  }
63
- return { includes, excludes };
83
+ nsFilterCache.set(key, result);
84
+ return result;
64
85
  }
65
86
  function matchesNamespace(scope, filter) {
66
87
  if (!filter)
@@ -103,12 +124,14 @@ function getNodeProcess() {
103
124
  export class Logger {
104
125
  constructor(options = {}) {
105
126
  /**
106
- * Sequences the async plugin-interception step so entries are processed in
107
- * emit order. Transport writes fan out to their own per-transport queues
108
- * (see `transportQueues`), so a slow/blocked transport can never stall the
109
- * others or this front queue.
127
+ * Bounded async queue for plugin interception. Tracks in-flight entries so
128
+ * `flush()` and `destroy()` know when all interceptions are done without
129
+ * letting the dispatch chain grow unboundedly (each push would append a
130
+ * `.then()` to an ever-longer Promise chain).
110
131
  */
111
- this.dispatchQueue = Promise.resolve();
132
+ this.dispatchInflight = 0;
133
+ this.dispatchDrain = null;
134
+ this.dispatchDrainResolve = undefined;
112
135
  /** Independent async-write queue per transport. */
113
136
  this.transportQueues = new Map();
114
137
  this.destroyed = false;
@@ -123,6 +146,8 @@ export class Logger {
123
146
  this.trace = (message, ...args) => this.emit('trace', message, args);
124
147
  this.debug = (message, ...args) => this.emit('debug', message, args);
125
148
  this.info = (message, ...args) => this.emit('info', message, args);
149
+ /** Alias for {@link info}. */
150
+ this.log = (message, ...args) => this.emit('info', message, args);
126
151
  this.warn = (message, ...args) => this.emit('warn', message, args);
127
152
  this.error = (message, ...args) => this.emit('error', message, args);
128
153
  this.fatal = (message, ...args) => this.emit('fatal', message, args);
@@ -150,11 +175,11 @@ export class Logger {
150
175
  this.level = normalizeLevel(levelInput);
151
176
  this.originalLevel = this.level;
152
177
  this.scopeName = options.scope;
153
- const nsInput = options.namespaceFilter ??
154
- (options.namespaceEnvVar === null
178
+ const nsInput = options.scopeFilter ??
179
+ (options.scopeFilterEnvVar === null
155
180
  ? undefined
156
- : readEnvVar(options.namespaceEnvVar ?? 'LOGRAIL_DEBUG'));
157
- this.namespaceFilter = compileNamespaceFilter(nsInput);
181
+ : readEnvVar(options.scopeFilterEnvVar ?? 'LOGRAIL_DEBUG'));
182
+ this.scopeFilter = compileNamespaceFilter(nsInput);
158
183
  // On the Electron main process, receive renderer logs over IPC.
159
184
  if (this.runtime.attachReceiver) {
160
185
  this.detachReceiver = this.runtime.attachReceiver((entry) => this.ingestEntry(entry));
@@ -166,7 +191,7 @@ export class Logger {
166
191
  this.attachExitHandlers();
167
192
  this.onLoggerError = options.onError;
168
193
  this.writeTimeoutMs = options.writeTimeoutMs ?? 5000;
169
- this.exitFlushTimeoutMs = options.exitFlushTimeoutMs ?? 2000;
194
+ this.flushTimeoutMs = options.flushTimeoutMs ?? 2000;
170
195
  // Wire the pipeline/plugin error sinks into the unified handler.
171
196
  this.pipeline.onError = (err, info) => this.reportError(info.phase, err, info.entry);
172
197
  this.plugins.onError = (name, err, entry) => this.reportError('plugin', err, entry, name);
@@ -184,13 +209,13 @@ export class Logger {
184
209
  this.pipeline = parent.pipeline;
185
210
  this.plugins = parent.plugins;
186
211
  this.transports = parent.transports;
187
- this.namespaceFilter = parent.namespaceFilter;
212
+ this.scopeFilter = parent.scopeFilter;
188
213
  this.context = opts.context ?? createContextStore();
189
214
  this.scopeName = opts.scope;
190
215
  // Only a root logger owns the shared plugin error sink; children inherit it.
191
216
  this.onLoggerError = parent.onLoggerError;
192
217
  this.writeTimeoutMs = parent.writeTimeoutMs;
193
- this.exitFlushTimeoutMs = parent.exitFlushTimeoutMs;
218
+ this.flushTimeoutMs = parent.flushTimeoutMs;
194
219
  if (opts.levelOverride !== undefined)
195
220
  this.levelOverride = opts.levelOverride;
196
221
  }
@@ -204,7 +229,7 @@ export class Logger {
204
229
  return;
205
230
  if (entry.level < this.getLevel())
206
231
  return;
207
- if (!matchesNamespace(entry.scope, this.namespaceFilter))
232
+ if (!matchesNamespace(entry.scope, this.scopeFilter))
208
233
  return;
209
234
  this.dispatch(entry);
210
235
  }
@@ -255,9 +280,22 @@ export class Logger {
255
280
  }
256
281
  removeTransport(name) {
257
282
  const removed = this.transports.filter((t) => t.name === name);
258
- for (const t of removed)
259
- this.transportQueues.delete(t);
260
283
  this.transports = this.transports.filter((t) => t.name !== name);
284
+ for (const transport of removed) {
285
+ const prev = this.transportQueues.get(transport) ?? Promise.resolve();
286
+ const teardown = prev
287
+ .then(async () => {
288
+ if (transport.flush)
289
+ await this.guardFlush(transport.flush.bind(transport));
290
+ if (transport.close)
291
+ await Promise.resolve(transport.close());
292
+ })
293
+ .catch((err) => this.reportError('transport', err, undefined, transport.name))
294
+ .finally(() => {
295
+ this.transportQueues.delete(transport);
296
+ });
297
+ this.transportQueues.set(transport, teardown);
298
+ }
261
299
  }
262
300
  /** Unregister a plugin by name at runtime. */
263
301
  unregisterPlugin(name) {
@@ -345,7 +383,7 @@ export class Logger {
345
383
  const levelValue = LOG_LEVELS[levelName];
346
384
  if (levelValue < this.getLevel())
347
385
  return;
348
- if (!matchesNamespace(this.scopeName, this.namespaceFilter))
386
+ if (!matchesNamespace(this.scopeName, this.scopeFilter))
349
387
  return;
350
388
  const entry = this.buildEntry(levelName, levelValue, message, args);
351
389
  const processed = this.pipeline.process(entry);
@@ -361,13 +399,29 @@ export class Logger {
361
399
  */
362
400
  dispatch(entry) {
363
401
  if (this.plugins.hasEntryInterceptors()) {
364
- const p = this.plugins.intercept(entry).then((intercepted) => {
402
+ // Create or reset the drain promise eagerly so that `flush()` callers
403
+ // always have a non-null promise to await, even if they arrive before
404
+ // the current batch of in-flight interceptions completes.
405
+ this.dispatchDrain = new Promise((resolve) => {
406
+ this.dispatchDrainResolve = resolve;
407
+ });
408
+ this.dispatchInflight++;
409
+ this.plugins
410
+ .intercept(entry)
411
+ .then((intercepted) => {
365
412
  if (intercepted)
366
413
  this.writeToTransports(intercepted);
414
+ })
415
+ .catch((err) => this.reportError('plugin', err))
416
+ .finally(() => {
417
+ this.dispatchInflight--;
418
+ if (this.dispatchInflight === 0) {
419
+ const resolve = this.dispatchDrainResolve;
420
+ this.dispatchDrain = null;
421
+ this.dispatchDrainResolve = undefined;
422
+ resolve?.();
423
+ }
367
424
  });
368
- this.dispatchQueue = this.dispatchQueue
369
- .then(() => p)
370
- .catch((err) => this.reportError('plugin', err));
371
425
  return;
372
426
  }
373
427
  this.writeToTransports(entry);
@@ -413,7 +467,9 @@ export class Logger {
413
467
  rest = [message, ...args];
414
468
  }
415
469
  if (!error) {
416
- error = rest.find((a) => a instanceof Error);
470
+ error =
471
+ rest.find((a) => a instanceof Error) ??
472
+ rest.find((a) => typeof a === 'string' && a.length > 0);
417
473
  }
418
474
  const now = this.runtime.now();
419
475
  const ts = typeof now === 'number' ? now : new Date(now).getTime();
@@ -500,7 +556,7 @@ export class Logger {
500
556
  }
501
557
  /** Await a transport's async `flush`, but never let it stall teardown. */
502
558
  guardFlush(p) {
503
- if (!this.writeTimeoutMs)
559
+ if (!this.flushTimeoutMs)
504
560
  return Promise.resolve();
505
561
  const result = p();
506
562
  if (!result || typeof result.then !== 'function')
@@ -518,7 +574,8 @@ export class Logger {
518
574
  async flush() {
519
575
  // Let in-flight interception finish so every scheduled write has been
520
576
  // enqueued onto its transport's own queue.
521
- await this.dispatchQueue;
577
+ if (this.dispatchInflight > 0)
578
+ await this.dispatchDrain;
522
579
  // Aggregate all per-transport async-write queues. `allSettled` means a
523
580
  // rejected/errored transport queue never rejects flush; a stalled one is
524
581
  // bounded by `writeTimeoutMs` via `guardWrite`.
@@ -549,15 +606,15 @@ export class Logger {
549
606
  this.flush().then(done, done);
550
607
  });
551
608
  }
552
- /** Set the max time (ms) to flush on process exit before giving up. */
609
+ /** Set the max time (ms) to flush before process exit before giving up. */
553
610
  setExitFlushTimeout(ms) {
554
611
  if (Number.isFinite(ms) && ms >= 0)
555
- this.exitFlushTimeoutMs = ms;
612
+ this.flushTimeoutMs = ms;
556
613
  return this;
557
614
  }
558
615
  /** Get the current exit-flush timeout (ms). */
559
616
  getExitFlushTimeout() {
560
- return this.exitFlushTimeoutMs;
617
+ return this.flushTimeoutMs;
561
618
  }
562
619
  // ---- Process integration ----
563
620
  /**
@@ -574,7 +631,7 @@ export class Logger {
574
631
  // adapters that don't supply lifecycle hooks (e.g. custom test runtimes).
575
632
  const lc = this.runtime.lifecycle;
576
633
  if (lc) {
577
- const ms = this.exitFlushTimeoutMs;
634
+ const ms = this.flushTimeoutMs;
578
635
  const detach = lc.onFlushBeforeExit(() => {
579
636
  void this.flushWithTimeout(ms);
580
637
  });
@@ -589,7 +646,7 @@ export class Logger {
589
646
  const proc = getNodeProcess();
590
647
  if (!proc)
591
648
  return;
592
- const ms = this.exitFlushTimeoutMs;
649
+ const ms = this.flushTimeoutMs;
593
650
  // On normal exit the event loop is about to empty: flush pending writes.
594
651
  // `beforeExit` re-fires as long as async writes keep the loop alive, so the
595
652
  // queue keeps draining until empty (bounded by `ms` if a sink stalls).
@@ -616,6 +673,14 @@ export class Logger {
616
673
  proc.on('beforeExit', onBeforeExit);
617
674
  proc.on('SIGINT', onSigInt);
618
675
  proc.on('SIGTERM', onSigTerm);
676
+ // Windows does not emit `SIGTERM`. Register `SIGBREAK` (Ctrl+Break) as a
677
+ // best-effort fallback so `autoFlushOnExit` has a signal hook on that
678
+ // platform. In practice taskkill / OS shutdown kills without emitting any
679
+ // Node signal, so no handler can cover that path — the `beforeExit` hook
680
+ // is the only portable shutdown flush mechanism.
681
+ if (process.platform === 'win32') {
682
+ proc.on('SIGBREAK', onSigInt);
683
+ }
619
684
  this.processHandlersAttached = true;
620
685
  const prev = this.removeProcessHandlers;
621
686
  this.removeProcessHandlers = () => {
@@ -640,7 +705,7 @@ export class Logger {
640
705
  // fall back to the direct `process` binding below, which is a no-op there.
641
706
  const lc = this.runtime.lifecycle;
642
707
  if (lc?.onUncaughtError) {
643
- const ms = this.exitFlushTimeoutMs;
708
+ const ms = this.flushTimeoutMs;
644
709
  const detach = lc.onUncaughtError((err) => {
645
710
  this.fatal(err);
646
711
  return this.flushWithTimeout(ms);
@@ -658,11 +723,11 @@ export class Logger {
658
723
  return;
659
724
  const onUncaught = (err) => {
660
725
  this.fatal(err);
661
- void this.flushWithTimeout(this.exitFlushTimeoutMs).finally(() => proc.exit(1));
726
+ void this.flushWithTimeout(this.flushTimeoutMs).finally(() => proc.exit(1));
662
727
  };
663
728
  const onRejection = (reason) => {
664
729
  this.fatal(reason);
665
- void this.flushWithTimeout(this.exitFlushTimeoutMs).finally(() => proc.exit(1));
730
+ void this.flushWithTimeout(this.flushTimeoutMs).finally(() => proc.exit(1));
666
731
  };
667
732
  proc.on('uncaughtException', onUncaught);
668
733
  proc.on('unhandledRejection', onRejection);
@@ -727,7 +792,7 @@ export class Logger {
727
792
  // Flush pending writes before tearing down transports, so buffered logs
728
793
  // are not lost. Bounded by the exit-flush timeout so a stalled sink can
729
794
  // never hang teardown.
730
- await this.flushWithTimeout(this.exitFlushTimeoutMs).catch(() => { });
795
+ await this.flushWithTimeout(this.flushTimeoutMs).catch(() => { });
731
796
  await this.plugins.destroy().catch(() => { });
732
797
  this.detachReceiver?.();
733
798
  this.peerLevel = undefined;
@@ -741,7 +806,9 @@ export class Logger {
741
806
  }
742
807
  }
743
808
  this.transportQueues.clear();
744
- this.dispatchQueue = Promise.resolve();
809
+ this.dispatchInflight = 0;
810
+ this.dispatchDrain = null;
811
+ this.dispatchDrainResolve = undefined;
745
812
  }
746
813
  }
747
814
  //# sourceMappingURL=logger.js.map