@logtape/logtape 2.3.0-dev.793 → 2.3.0-dev.795

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/config.cjs CHANGED
@@ -9,6 +9,7 @@ const require_sink = require('./sink.cjs');
9
9
  */
10
10
  let currentConfig = null;
11
11
  let activeScopedConfigCount = 0;
12
+ let globalConfigMutationInProgress = false;
12
13
  /**
13
14
  * Strong references to the loggers.
14
15
  * This is to prevent the loggers from being garbage collected so that their
@@ -39,7 +40,7 @@ function isLoggerConfigMeta(cfg) {
39
40
  return category.length === 0 || category.length === 1 && category[0] === "logtape" || category.length === 2 && category[0] === "logtape" && category[1] === "meta";
40
41
  }
41
42
  function registerDisposeHook(allowAsync) {
42
- const handler = allowAsync ? dispose : disposeSync;
43
+ const handler = allowAsync ? disposeInternal : disposeSyncInternal;
43
44
  if (typeof globalThis.EdgeRuntime !== "string" && "process" in globalThis && !("Deno" in globalThis)) {
44
45
  const proc = globalThis.process;
45
46
  const onMethod = proc?.["on"];
@@ -93,15 +94,20 @@ function registerDisposeHook(allowAsync) {
93
94
  * @param config The configuration.
94
95
  */
95
96
  async function configure(config) {
96
- assertNoScopedConfig("configure()");
97
- if (currentConfig != null && !config.reset) throw new ConfigError("Already configured; if you want to reset, turn on the reset flag.");
98
- await reset();
99
- try {
100
- configureInternal(config, true);
101
- } catch (e) {
102
- if (e instanceof ConfigError) await reset();
103
- throw e;
104
- }
97
+ await runGlobalConfigMutation("configure()", async () => {
98
+ if (currentConfig != null && !config.reset) throw new ConfigError("Already configured; if you want to reset, turn on the reset flag.");
99
+ await disposeInternal();
100
+ resetInternal();
101
+ try {
102
+ configureInternal(config, true);
103
+ } catch (e) {
104
+ if (e instanceof ConfigError) {
105
+ await disposeInternal();
106
+ resetInternal();
107
+ }
108
+ throw e;
109
+ }
110
+ });
105
111
  }
106
112
  /**
107
113
  * Configure sync loggers with the specified configuration.
@@ -137,16 +143,21 @@ async function configure(config) {
137
143
  * @since 0.9.0
138
144
  */
139
145
  function configureSync(config) {
140
- assertNoScopedConfig("configureSync()");
141
- if (currentConfig != null && !config.reset) throw new ConfigError("Already configured; if you want to reset, turn on the reset flag.");
142
- if (asyncFilterDisposables.size > 0 || asyncSinkDisposables.size > 0) throw new ConfigError("Previously configured async disposables are still active. Use configure() instead or explicitly dispose them using dispose().");
143
- resetSync();
144
- try {
145
- configureInternal(config, false);
146
- } catch (e) {
147
- if (e instanceof ConfigError) resetSync();
148
- throw e;
149
- }
146
+ runGlobalConfigMutationSync("configureSync()", () => {
147
+ if (currentConfig != null && !config.reset) throw new ConfigError("Already configured; if you want to reset, turn on the reset flag.");
148
+ if (asyncFilterDisposables.size > 0 || asyncSinkDisposables.size > 0) throw new ConfigError("Previously configured async disposables are still active. Use configure() instead or explicitly dispose them using dispose().");
149
+ disposeSyncInternal();
150
+ resetInternal();
151
+ try {
152
+ configureInternal(config, false);
153
+ } catch (e) {
154
+ if (e instanceof ConfigError) {
155
+ disposeSyncInternal();
156
+ resetInternal();
157
+ }
158
+ throw e;
159
+ }
160
+ });
150
161
  }
151
162
  /**
152
163
  * Runs a callback with a LogTape configuration scoped to the current execution
@@ -289,9 +300,10 @@ function getConfig() {
289
300
  * Reset the configuration. Mostly for testing purposes.
290
301
  */
291
302
  async function reset() {
292
- assertNoScopedConfig("reset()");
293
- await dispose();
294
- resetInternal();
303
+ await runGlobalConfigMutation("reset()", async () => {
304
+ await disposeInternal();
305
+ resetInternal();
306
+ });
295
307
  }
296
308
  /**
297
309
  * Reset the configuration. Mostly for testing purposes. Will not clear async
@@ -299,9 +311,10 @@ async function reset() {
299
311
  * @since 0.9.0
300
312
  */
301
313
  function resetSync() {
302
- assertNoScopedConfig("resetSync()");
303
- disposeSync();
304
- resetInternal();
314
+ runGlobalConfigMutationSync("resetSync()", () => {
315
+ disposeSyncInternal();
316
+ resetInternal();
317
+ });
305
318
  }
306
319
  function resetInternal() {
307
320
  const rootLogger = require_logger.LoggerImpl.getLogger([]);
@@ -314,7 +327,9 @@ function resetInternal() {
314
327
  * Dispose of the disposables.
315
328
  */
316
329
  async function dispose() {
317
- assertNoScopedConfig("dispose()");
330
+ await runGlobalConfigMutation("dispose()", disposeInternal);
331
+ }
332
+ async function disposeInternal() {
318
333
  const errors = [];
319
334
  try {
320
335
  disposeSyncFilters();
@@ -344,7 +359,9 @@ async function dispose() {
344
359
  * @since 0.9.0
345
360
  */
346
361
  function disposeSync() {
347
- assertNoScopedConfig("disposeSync()");
362
+ runGlobalConfigMutationSync("disposeSync()", disposeSyncInternal);
363
+ }
364
+ function disposeSyncInternal() {
348
365
  const errors = [];
349
366
  try {
350
367
  disposeSyncFilters();
@@ -359,11 +376,34 @@ function disposeSync() {
359
376
  throwDisposeErrors(errors);
360
377
  }
361
378
  function getConfiguredContextLocalStorage(functionName) {
379
+ if (globalConfigMutationInProgress) throw new ConfigError(`${functionName} cannot be called while LogTape is being reconfigured.`);
362
380
  if (currentConfig == null) throw new ConfigError(`${functionName} requires LogTape to be configured first.`);
363
381
  const contextLocalStorage = require_logger.LoggerImpl.getLogger().contextLocalStorage;
364
382
  if (contextLocalStorage == null) throw new ConfigError(`${functionName} requires Config.contextLocalStorage to be configured.`);
365
383
  return contextLocalStorage;
366
384
  }
385
+ async function runGlobalConfigMutation(functionName, callback) {
386
+ assertCanMutateGlobalConfig(functionName);
387
+ globalConfigMutationInProgress = true;
388
+ try {
389
+ return await callback();
390
+ } finally {
391
+ globalConfigMutationInProgress = false;
392
+ }
393
+ }
394
+ function runGlobalConfigMutationSync(functionName, callback) {
395
+ assertCanMutateGlobalConfig(functionName);
396
+ globalConfigMutationInProgress = true;
397
+ try {
398
+ return callback();
399
+ } finally {
400
+ globalConfigMutationInProgress = false;
401
+ }
402
+ }
403
+ function assertCanMutateGlobalConfig(functionName) {
404
+ if (globalConfigMutationInProgress) throw new ConfigError(`${functionName} cannot be called while LogTape is being reconfigured.`);
405
+ assertNoScopedConfig(functionName);
406
+ }
367
407
  function assertNoScopedConfig(functionName) {
368
408
  if (activeScopedConfigCount > 0) throw new ConfigError(`${functionName} cannot be called while a scoped configuration is active. Use nested withConfig() instead.`);
369
409
  }
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.cts","names":[],"sources":["../src/config.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAiBA;AAAuB,UAAN,MAAM,CAAA,gBAAA,MAAA,EAAA,kBAAA,MAAA,CAAA,CAAA;EAAA;;;;EAUK,KAAE,EALrB,MAKqB,CALd,OAKc,EALL,IAKK,CAAA;EAAU;;;;EAKjB,OAMqB,CAAA,EAXhC,MAWgC,CAXzB,SAWyB,EAXd,UAWc,CAAA;EAAM;AAAP;AAkB3C;EAAwB,OAAA,EAxBb,YAwBa,CAxBA,OAwBA,EAxBS,SAwBT,CAAA,EAAA;EAAA;;;AACN;EAEb,mBAAA,CAAA,EArBmB,mBAqBD,CArBqB,MAqBrB,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA;EAAA;;;EAAuC,KAC1D,CAAA,EAAA,OAAA;AAAO;AAKX;;;;;AAoCwB;AAyHxB;;;;AAGU,KAzKE,YAyKF,CAAA,gBAAA,MAAA,EAAA,kBAAA,MAAA,CAAA,GAxKR,gBAwKQ,CAxKS,OAwKT,EAxKkB,SAwKlB,CAAA;KAtKL,kBAsKkC,CAAA,OAAA,CAAA,GAtKJ,OAsKI,SAtKY,WAsKZ,CAAA,OAAA,CAAA,GAAA,KAAA,GArKnC,OAqKmC;AAAO;AAiD9C;;AACiB,UAlNA,YAkNA,CAAA,gBAAA,MAAA,EAAA,kBAAA,MAAA,CAAA,CAAA;EAAO;;AAAR;AAoChB;EAAgC,QAAA,EAAA,MAAA,GAAA,MAAA,EAAA;EAAA;;;EAKV,KACJ,CAAA,EA/OR,OA+OQ,EAAA;EAAO;;;AACf;AAiDV;;;;;EAKsB,WACe,CAAA,EAAA,SAAA,GAAA,UAAA;EAAO;;;EACvB,OAAA,CAAA,EAxRT,SAwRS,EAAA;EAyJL;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AO;;;EACvB,OAAA,CAAA,EAnST,SAmSS,EAAA;EAyJL;AAOhB;AAYA;AAkBA;AAkCA;EAoKa,WAAA,CAAA,EAhqBG,QAgqBS,GAAQ,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAtiBX,oEAGZ,OAAO,SAAS,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsDvB,wEACN,OAAO,SAAS;;;;;;;;;;;;;;iBAyCJ,8EAKZ,aAAa,SAAS,4BACd,UACf,QAAQ,QAAQ;;;;;;;;;;;;iBAiDH,kFAKN,aAAa,SAAS,4BACd,mBAAmB,WAClC,mBAAmB;;;;;iBAyJN,SAAA,CAAA,GAAa;;;;iBAOP,KAAA,CAAA,GAAS;;;;;;iBAYf,SAAA,CAAA;;;;iBAkBM,OAAA,CAAA,GAAW;;;;;;iBAkCjB,WAAA,CAAA;;;;cAoKH,WAAA,SAAoB,KAAK"}
package/dist/config.js CHANGED
@@ -9,6 +9,7 @@ import { getConsoleSink } from "./sink.js";
9
9
  */
10
10
  let currentConfig = null;
11
11
  let activeScopedConfigCount = 0;
12
+ let globalConfigMutationInProgress = false;
12
13
  /**
13
14
  * Strong references to the loggers.
14
15
  * This is to prevent the loggers from being garbage collected so that their
@@ -39,7 +40,7 @@ function isLoggerConfigMeta(cfg) {
39
40
  return category.length === 0 || category.length === 1 && category[0] === "logtape" || category.length === 2 && category[0] === "logtape" && category[1] === "meta";
40
41
  }
41
42
  function registerDisposeHook(allowAsync) {
42
- const handler = allowAsync ? dispose : disposeSync;
43
+ const handler = allowAsync ? disposeInternal : disposeSyncInternal;
43
44
  if (typeof globalThis.EdgeRuntime !== "string" && "process" in globalThis && !("Deno" in globalThis)) {
44
45
  const proc = globalThis.process;
45
46
  const onMethod = proc?.["on"];
@@ -93,15 +94,20 @@ function registerDisposeHook(allowAsync) {
93
94
  * @param config The configuration.
94
95
  */
95
96
  async function configure(config) {
96
- assertNoScopedConfig("configure()");
97
- if (currentConfig != null && !config.reset) throw new ConfigError("Already configured; if you want to reset, turn on the reset flag.");
98
- await reset();
99
- try {
100
- configureInternal(config, true);
101
- } catch (e) {
102
- if (e instanceof ConfigError) await reset();
103
- throw e;
104
- }
97
+ await runGlobalConfigMutation("configure()", async () => {
98
+ if (currentConfig != null && !config.reset) throw new ConfigError("Already configured; if you want to reset, turn on the reset flag.");
99
+ await disposeInternal();
100
+ resetInternal();
101
+ try {
102
+ configureInternal(config, true);
103
+ } catch (e) {
104
+ if (e instanceof ConfigError) {
105
+ await disposeInternal();
106
+ resetInternal();
107
+ }
108
+ throw e;
109
+ }
110
+ });
105
111
  }
106
112
  /**
107
113
  * Configure sync loggers with the specified configuration.
@@ -137,16 +143,21 @@ async function configure(config) {
137
143
  * @since 0.9.0
138
144
  */
139
145
  function configureSync(config) {
140
- assertNoScopedConfig("configureSync()");
141
- if (currentConfig != null && !config.reset) throw new ConfigError("Already configured; if you want to reset, turn on the reset flag.");
142
- if (asyncFilterDisposables.size > 0 || asyncSinkDisposables.size > 0) throw new ConfigError("Previously configured async disposables are still active. Use configure() instead or explicitly dispose them using dispose().");
143
- resetSync();
144
- try {
145
- configureInternal(config, false);
146
- } catch (e) {
147
- if (e instanceof ConfigError) resetSync();
148
- throw e;
149
- }
146
+ runGlobalConfigMutationSync("configureSync()", () => {
147
+ if (currentConfig != null && !config.reset) throw new ConfigError("Already configured; if you want to reset, turn on the reset flag.");
148
+ if (asyncFilterDisposables.size > 0 || asyncSinkDisposables.size > 0) throw new ConfigError("Previously configured async disposables are still active. Use configure() instead or explicitly dispose them using dispose().");
149
+ disposeSyncInternal();
150
+ resetInternal();
151
+ try {
152
+ configureInternal(config, false);
153
+ } catch (e) {
154
+ if (e instanceof ConfigError) {
155
+ disposeSyncInternal();
156
+ resetInternal();
157
+ }
158
+ throw e;
159
+ }
160
+ });
150
161
  }
151
162
  /**
152
163
  * Runs a callback with a LogTape configuration scoped to the current execution
@@ -289,9 +300,10 @@ function getConfig() {
289
300
  * Reset the configuration. Mostly for testing purposes.
290
301
  */
291
302
  async function reset() {
292
- assertNoScopedConfig("reset()");
293
- await dispose();
294
- resetInternal();
303
+ await runGlobalConfigMutation("reset()", async () => {
304
+ await disposeInternal();
305
+ resetInternal();
306
+ });
295
307
  }
296
308
  /**
297
309
  * Reset the configuration. Mostly for testing purposes. Will not clear async
@@ -299,9 +311,10 @@ async function reset() {
299
311
  * @since 0.9.0
300
312
  */
301
313
  function resetSync() {
302
- assertNoScopedConfig("resetSync()");
303
- disposeSync();
304
- resetInternal();
314
+ runGlobalConfigMutationSync("resetSync()", () => {
315
+ disposeSyncInternal();
316
+ resetInternal();
317
+ });
305
318
  }
306
319
  function resetInternal() {
307
320
  const rootLogger = LoggerImpl.getLogger([]);
@@ -314,7 +327,9 @@ function resetInternal() {
314
327
  * Dispose of the disposables.
315
328
  */
316
329
  async function dispose() {
317
- assertNoScopedConfig("dispose()");
330
+ await runGlobalConfigMutation("dispose()", disposeInternal);
331
+ }
332
+ async function disposeInternal() {
318
333
  const errors = [];
319
334
  try {
320
335
  disposeSyncFilters();
@@ -344,7 +359,9 @@ async function dispose() {
344
359
  * @since 0.9.0
345
360
  */
346
361
  function disposeSync() {
347
- assertNoScopedConfig("disposeSync()");
362
+ runGlobalConfigMutationSync("disposeSync()", disposeSyncInternal);
363
+ }
364
+ function disposeSyncInternal() {
348
365
  const errors = [];
349
366
  try {
350
367
  disposeSyncFilters();
@@ -359,11 +376,34 @@ function disposeSync() {
359
376
  throwDisposeErrors(errors);
360
377
  }
361
378
  function getConfiguredContextLocalStorage(functionName) {
379
+ if (globalConfigMutationInProgress) throw new ConfigError(`${functionName} cannot be called while LogTape is being reconfigured.`);
362
380
  if (currentConfig == null) throw new ConfigError(`${functionName} requires LogTape to be configured first.`);
363
381
  const contextLocalStorage = LoggerImpl.getLogger().contextLocalStorage;
364
382
  if (contextLocalStorage == null) throw new ConfigError(`${functionName} requires Config.contextLocalStorage to be configured.`);
365
383
  return contextLocalStorage;
366
384
  }
385
+ async function runGlobalConfigMutation(functionName, callback) {
386
+ assertCanMutateGlobalConfig(functionName);
387
+ globalConfigMutationInProgress = true;
388
+ try {
389
+ return await callback();
390
+ } finally {
391
+ globalConfigMutationInProgress = false;
392
+ }
393
+ }
394
+ function runGlobalConfigMutationSync(functionName, callback) {
395
+ assertCanMutateGlobalConfig(functionName);
396
+ globalConfigMutationInProgress = true;
397
+ try {
398
+ return callback();
399
+ } finally {
400
+ globalConfigMutationInProgress = false;
401
+ }
402
+ }
403
+ function assertCanMutateGlobalConfig(functionName) {
404
+ if (globalConfigMutationInProgress) throw new ConfigError(`${functionName} cannot be called while LogTape is being reconfigured.`);
405
+ assertNoScopedConfig(functionName);
406
+ }
367
407
  function assertNoScopedConfig(functionName) {
368
408
  if (activeScopedConfigCount > 0) throw new ConfigError(`${functionName} cannot be called while a scoped configuration is active. Use nested withConfig() instead.`);
369
409
  }
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":["currentConfig: Config<string, string> | null","strongRefs: Set<LoggerImpl>","filterDisposables: Set<Disposable>","sinkDisposables: Set<Disposable>","asyncFilterDisposables: Set<AsyncDisposable>","asyncSinkDisposables: Set<AsyncDisposable>","cfg: LoggerConfig<TSinkId, TFilterId>","allowAsync: boolean","config: Config<TSinkId, TFilterId>","config: ScopedConfig<TSinkId, TFilterId>","callback: () => TResult","result: Awaited<TResult>","callbackError: unknown","callback: () => SyncCallbackResult<TResult>","result: SyncCallbackResult<TResult>","value: unknown","errors: unknown[]","functionName: string","disposables: Set<Disposable>","disposables: Set<AsyncDisposable>","promises: PromiseLike<void>[]","promises: readonly PromiseLike<void>[]","errors: readonly unknown[]","message: string"],"sources":["../src/config.ts"],"sourcesContent":["import type { ContextLocalStorage } from \"./context.ts\";\nimport { type FilterLike, toFilter } from \"./filter.ts\";\nimport type { LogLevel } from \"./level.ts\";\nimport { LoggerImpl } from \"./logger.ts\";\nimport {\n compileScopedConfig,\n disposeScopedConfig,\n disposeScopedConfigSync,\n runWithScopedConfig,\n type ScopedConfigLike,\n throwCombinedErrors,\n} from \"./scoped-config.ts\";\nimport { getConsoleSink, type Sink } from \"./sink.ts\";\n\n/**\n * A configuration for the loggers.\n */\nexport interface Config<TSinkId extends string, TFilterId extends string> {\n /**\n * The sinks to use. The keys are the sink identifiers, and the values are\n * {@link Sink}s.\n */\n sinks: Record<TSinkId, Sink>;\n /**\n * The filters to use. The keys are the filter identifiers, and the values\n * are either {@link Filter}s or {@link LogLevel}s.\n */\n filters?: Record<TFilterId, FilterLike>;\n\n /**\n * The loggers to configure.\n */\n loggers: LoggerConfig<TSinkId, TFilterId>[];\n\n /**\n * The context-local storage to use for implicit contexts.\n * @since 0.7.0\n */\n contextLocalStorage?: ContextLocalStorage<Record<string, unknown>>;\n\n /**\n * Whether to reset the configuration before applying this one.\n */\n reset?: boolean;\n}\n\n/**\n * A scoped configuration for the current execution context.\n *\n * Unlike {@link Config}, this type does not include `reset` or\n * `contextLocalStorage`. Scoped configuration changes only the logging policy\n * for a callback; the context-local storage must already be initialized by the\n * process-global configuration.\n *\n * @since 2.3.0\n */\nexport type ScopedConfig<TSinkId extends string, TFilterId extends string> =\n ScopedConfigLike<TSinkId, TFilterId>;\n\ntype SyncCallbackResult<TResult> = TResult extends PromiseLike<unknown> ? never\n : TResult;\n\n/**\n * A logger configuration.\n */\nexport interface LoggerConfig<\n TSinkId extends string,\n TFilterId extends string,\n> {\n /**\n * The category of the logger. If a string, it is equivalent to an array\n * with one element.\n */\n category: string | string[];\n\n /**\n * The sink identifiers to use.\n */\n sinks?: TSinkId[];\n\n /**\n * Whether to inherit the parent's sinks. If `inherit`, the parent's sinks\n * are used along with the specified sinks. If `override`, the parent's\n * sinks are not used, and only the specified sinks are used.\n *\n * The default is `inherit`.\n * @default `\"inherit\"\n * @since 0.6.0\n */\n parentSinks?: \"inherit\" | \"override\";\n\n /**\n * The filter identifiers to use.\n */\n filters?: TFilterId[];\n\n /**\n * The lowest log level to accept. If `null`, the logger will reject all\n * records.\n * @since 0.8.0\n */\n lowestLevel?: LogLevel | null;\n}\n\n/**\n * The current configuration, if any. Otherwise, `null`.\n */\nlet currentConfig: Config<string, string> | null = null;\nlet activeScopedConfigCount = 0;\n\n/**\n * Strong references to the loggers.\n * This is to prevent the loggers from being garbage collected so that their\n * sinks and filters are not removed.\n */\nconst strongRefs: Set<LoggerImpl> = new Set();\n\n/**\n * Sync filter disposables to dispose when resetting the configuration.\n */\nconst filterDisposables: Set<Disposable> = new Set();\n\n/**\n * Sync sink disposables to dispose when resetting the configuration.\n */\nconst sinkDisposables: Set<Disposable> = new Set();\n\n/**\n * Async filter disposables to dispose when resetting the configuration.\n */\nconst asyncFilterDisposables: Set<AsyncDisposable> = new Set();\n\n/**\n * Async sink disposables to dispose when resetting the configuration.\n */\nconst asyncSinkDisposables: Set<AsyncDisposable> = new Set();\n\n/**\n * Check if a config is for the meta logger.\n */\nfunction isLoggerConfigMeta<TSinkId extends string, TFilterId extends string>(\n cfg: LoggerConfig<TSinkId, TFilterId>,\n): boolean {\n const category = Array.isArray(cfg.category) ? cfg.category : [cfg.category];\n return category.length === 0 ||\n (category.length === 1 && category[0] === \"logtape\") ||\n (category.length === 2 &&\n category[0] === \"logtape\" &&\n category[1] === \"meta\");\n}\n\nfunction registerDisposeHook(allowAsync: boolean): void {\n const handler = allowAsync ? dispose : disposeSync;\n\n if (\n // deno-lint-ignore no-explicit-any\n typeof (globalThis as any).EdgeRuntime !== \"string\" &&\n \"process\" in globalThis &&\n !(\"Deno\" in globalThis)\n ) {\n // deno-lint-ignore no-explicit-any\n const proc = (globalThis as any).process;\n // Use bracket notation to avoid static analysis detection in Edge Runtime.\n const onMethod = proc?.[\"on\"];\n if (typeof onMethod === \"function\") {\n onMethod.call(proc, \"exit\", handler);\n return;\n }\n }\n\n // Some edge runtimes expose neither process.on() nor addEventListener().\n // In those environments users can still call dispose()/disposeSync() manually.\n // deno-lint-ignore no-explicit-any\n const addEventListenerMethod = (globalThis as any).addEventListener;\n if (typeof addEventListenerMethod !== \"function\") return;\n\n if (\"Deno\" in globalThis) {\n addEventListenerMethod.call(globalThis, \"unload\", handler);\n } else {\n addEventListenerMethod.call(globalThis, \"pagehide\", handler);\n }\n}\n\n/**\n * Configure the loggers with the specified configuration.\n *\n * Note that if the given sinks or filters are disposable, they will be\n * disposed when the configuration is reset, or when the process exits.\n *\n * @example\n * ```typescript\n * await configure({\n * sinks: {\n * console: getConsoleSink(),\n * },\n * filters: {\n * slow: (log) =>\n * \"duration\" in log.properties &&\n * log.properties.duration as number > 1000,\n * },\n * loggers: [\n * {\n * category: \"my-app\",\n * sinks: [\"console\"],\n * lowestLevel: \"info\",\n * },\n * {\n * category: [\"my-app\", \"sql\"],\n * filters: [\"slow\"],\n * lowestLevel: \"debug\",\n * },\n * {\n * category: \"logtape\",\n * sinks: [\"console\"],\n * lowestLevel: \"error\",\n * },\n * ],\n * });\n * ```\n *\n * @param config The configuration.\n */\nexport async function configure<\n TSinkId extends string,\n TFilterId extends string,\n>(config: Config<TSinkId, TFilterId>): Promise<void> {\n assertNoScopedConfig(\"configure()\");\n if (currentConfig != null && !config.reset) {\n throw new ConfigError(\n \"Already configured; if you want to reset, turn on the reset flag.\",\n );\n }\n await reset();\n try {\n configureInternal(config, true);\n } catch (e) {\n if (e instanceof ConfigError) await reset();\n throw e;\n }\n}\n\n/**\n * Configure sync loggers with the specified configuration.\n *\n * Note that if the given sinks or filters are disposable, they will be\n * disposed when the configuration is reset, or when the process exits.\n *\n * Also note that passing async sinks or filters will throw. If\n * necessary use {@link resetSync} or {@link disposeSync}.\n *\n * @example\n * ```typescript\n * configureSync({\n * sinks: {\n * console: getConsoleSink(),\n * },\n * loggers: [\n * {\n * category: \"my-app\",\n * sinks: [\"console\"],\n * lowestLevel: \"info\",\n * },\n * {\n * category: \"logtape\",\n * sinks: [\"console\"],\n * lowestLevel: \"error\",\n * },\n * ],\n * });\n * ```\n *\n * @param config The configuration.\n * @since 0.9.0\n */\nexport function configureSync<TSinkId extends string, TFilterId extends string>(\n config: Config<TSinkId, TFilterId>,\n): void {\n assertNoScopedConfig(\"configureSync()\");\n if (currentConfig != null && !config.reset) {\n throw new ConfigError(\n \"Already configured; if you want to reset, turn on the reset flag.\",\n );\n }\n if (asyncFilterDisposables.size > 0 || asyncSinkDisposables.size > 0) {\n throw new ConfigError(\n \"Previously configured async disposables are still active. \" +\n \"Use configure() instead or explicitly dispose them using dispose().\",\n );\n }\n resetSync();\n try {\n configureInternal(config, false);\n } catch (e) {\n if (e instanceof ConfigError) resetSync();\n throw e;\n }\n}\n\n/**\n * Runs a callback with a LogTape configuration scoped to the current execution\n * context.\n *\n * The process-global configuration must already provide\n * `contextLocalStorage`. The scoped configuration fully overrides global\n * logger routing while the callback and its async work run.\n *\n * @param config The scoped configuration.\n * @param callback The callback to run.\n * @returns The callback's resolved return value.\n * @since 2.3.0\n */\nexport async function withConfig<\n TSinkId extends string,\n TFilterId extends string,\n TResult,\n>(\n config: ScopedConfig<TSinkId, TFilterId>,\n callback: () => TResult,\n): Promise<Awaited<TResult>> {\n const contextLocalStorage = getConfiguredContextLocalStorage(\"withConfig()\");\n const scopedConfig = compileScopedConfig(\n config,\n true,\n (message) => new ConfigError(message),\n );\n\n let result: Awaited<TResult>;\n let callbackError: unknown;\n let callbackFailed = false;\n activeScopedConfigCount++;\n try {\n result = await runWithScopedConfig(\n contextLocalStorage,\n scopedConfig,\n callback,\n );\n } catch (error) {\n callbackFailed = true;\n callbackError = error;\n }\n\n try {\n await disposeScopedConfig(scopedConfig);\n } catch (disposeError) {\n if (callbackFailed) {\n throwCombinedErrors(callbackError, disposeError);\n }\n throw disposeError;\n } finally {\n activeScopedConfigCount--;\n }\n\n if (callbackFailed) throw callbackError;\n return result!;\n}\n\n/**\n * Runs a synchronous callback with a LogTape configuration scoped to the\n * current execution context.\n *\n * The scoped configuration must not contain async disposable sinks or filters.\n *\n * @param config The scoped configuration.\n * @param callback The callback to run.\n * @returns The callback's return value.\n * @since 2.3.0\n */\nexport function withConfigSync<\n TSinkId extends string,\n TFilterId extends string,\n TResult,\n>(\n config: ScopedConfig<TSinkId, TFilterId>,\n callback: () => SyncCallbackResult<TResult>,\n): SyncCallbackResult<TResult> {\n const contextLocalStorage = getConfiguredContextLocalStorage(\n \"withConfigSync()\",\n );\n const scopedConfig = compileScopedConfig(\n config,\n false,\n (message) => new ConfigError(message),\n );\n\n let result: SyncCallbackResult<TResult>;\n let callbackError: unknown;\n let callbackFailed = false;\n activeScopedConfigCount++;\n try {\n result = runWithScopedConfig(contextLocalStorage, scopedConfig, callback);\n if (isThenable(result)) {\n void Promise.resolve(result).catch(() => {});\n callbackFailed = true;\n callbackError = new ConfigError(\n \"withConfigSync() callback must not return a promise. \" +\n \"Use withConfig() for async callbacks.\",\n );\n }\n } catch (error) {\n callbackFailed = true;\n callbackError = error;\n }\n\n try {\n disposeScopedConfigSync(scopedConfig);\n } catch (disposeError) {\n if (callbackFailed) {\n throwCombinedErrors(callbackError, disposeError);\n }\n throw disposeError;\n } finally {\n activeScopedConfigCount--;\n }\n\n if (callbackFailed) throw callbackError;\n return result!;\n}\n\nfunction isThenable(value: unknown): value is PromiseLike<unknown> {\n return value != null &&\n (typeof value === \"object\" || typeof value === \"function\") &&\n \"then\" in value &&\n typeof value.then === \"function\";\n}\n\nfunction configureInternal<\n TSinkId extends string,\n TFilterId extends string,\n>(config: Config<TSinkId, TFilterId>, allowAsync: boolean): void {\n currentConfig = config;\n\n let metaConfigured = false;\n const configuredCategories = new Set<string>();\n\n for (const cfg of config.loggers) {\n if (isLoggerConfigMeta(cfg)) {\n metaConfigured = true;\n }\n\n // Check for duplicate logger categories\n const categoryKey = Array.isArray(cfg.category)\n ? JSON.stringify(cfg.category)\n : JSON.stringify([cfg.category]);\n if (configuredCategories.has(categoryKey)) {\n throw new ConfigError(\n `Duplicate logger configuration for category: ${categoryKey}. ` +\n `Each category can only be configured once.`,\n );\n }\n configuredCategories.add(categoryKey);\n\n const logger = LoggerImpl.getLogger(cfg.category);\n for (const sinkId of cfg.sinks ?? []) {\n const sink = config.sinks[sinkId];\n if (!sink) {\n throw new ConfigError(`Sink not found: ${sinkId}.`);\n }\n logger.sinks.push(sink);\n }\n logger.parentSinks = cfg.parentSinks ?? \"inherit\";\n if (cfg.lowestLevel !== undefined) {\n logger.lowestLevel = cfg.lowestLevel;\n }\n for (const filterId of cfg.filters ?? []) {\n const filter = config.filters?.[filterId];\n if (filter === undefined) {\n throw new ConfigError(`Filter not found: ${filterId}.`);\n }\n logger.filters.push(toFilter(filter));\n }\n strongRefs.add(logger);\n }\n\n LoggerImpl.getLogger().contextLocalStorage = config.contextLocalStorage;\n\n for (const sink of Object.values<Sink>(config.sinks)) {\n if (Symbol.asyncDispose in sink) {\n if (allowAsync) asyncSinkDisposables.add(sink as AsyncDisposable);\n else {\n throw new ConfigError(\n \"Async disposables cannot be used with configureSync().\",\n );\n }\n }\n if (Symbol.dispose in sink) sinkDisposables.add(sink as Disposable);\n }\n\n for (const filter of Object.values<FilterLike>(config.filters ?? {})) {\n if (filter == null || typeof filter === \"string\") continue;\n if (Symbol.asyncDispose in filter) {\n if (allowAsync) asyncFilterDisposables.add(filter as AsyncDisposable);\n else {\n throw new ConfigError(\n \"Async disposables cannot be used with configureSync().\",\n );\n }\n asyncSinkDisposables.delete(filter as AsyncDisposable);\n }\n if (Symbol.dispose in filter) {\n filterDisposables.add(filter as Disposable);\n sinkDisposables.delete(filter as Disposable);\n }\n }\n\n registerDisposeHook(allowAsync);\n const meta = LoggerImpl.getLogger([\"logtape\", \"meta\"]);\n if (!metaConfigured) {\n meta.sinks.push(getConsoleSink());\n }\n\n meta.info(\n \"LogTape loggers are configured. Note that LogTape itself uses the meta \" +\n \"logger, which has category {metaLoggerCategory}. The meta logger is \" +\n \"used to log internal diagnostics such as sink exceptions. \" +\n \"It's recommended to configure the meta logger with a separate sink \" +\n \"so that you can easily notice if logging itself fails or is \" +\n \"misconfigured. To turn off this message, configure the meta logger \" +\n \"with higher log levels than {dismissLevel}. See also \" +\n \"<https://logtape.org/manual/categories#meta-logger>.\",\n { metaLoggerCategory: [\"logtape\", \"meta\"], dismissLevel: \"info\" },\n );\n}\n\n/**\n * Get the current configuration, if any. Otherwise, `null`.\n * @returns The current configuration, if any. Otherwise, `null`.\n */\nexport function getConfig(): Config<string, string> | null {\n return currentConfig;\n}\n\n/**\n * Reset the configuration. Mostly for testing purposes.\n */\nexport async function reset(): Promise<void> {\n assertNoScopedConfig(\"reset()\");\n await dispose();\n resetInternal();\n}\n\n/**\n * Reset the configuration. Mostly for testing purposes. Will not clear async\n * sinks, only use with sync sinks. Use {@link reset} if you have async sinks.\n * @since 0.9.0\n */\nexport function resetSync(): void {\n assertNoScopedConfig(\"resetSync()\");\n disposeSync();\n resetInternal();\n}\n\nfunction resetInternal(): void {\n const rootLogger = LoggerImpl.getLogger([]);\n rootLogger.resetDescendants();\n delete rootLogger.contextLocalStorage;\n strongRefs.clear();\n currentConfig = null;\n}\n\n/**\n * Dispose of the disposables.\n */\nexport async function dispose(): Promise<void> {\n assertNoScopedConfig(\"dispose()\");\n const errors: unknown[] = [];\n try {\n disposeSyncFilters();\n } catch (error) {\n errors.push(error);\n }\n try {\n await disposeAsyncFilters();\n } catch (error) {\n errors.push(error);\n }\n try {\n disposeSyncSinks();\n } catch (error) {\n errors.push(error);\n }\n try {\n await disposeAsyncSinks();\n } catch (error) {\n errors.push(error);\n }\n throwDisposeErrors(errors);\n}\n\n/**\n * Dispose of the sync disposables. Async disposables will be untouched,\n * use {@link dispose} if you have async sinks.\n * @since 0.9.0\n */\nexport function disposeSync(): void {\n assertNoScopedConfig(\"disposeSync()\");\n const errors: unknown[] = [];\n try {\n disposeSyncFilters();\n } catch (error) {\n errors.push(error);\n }\n try {\n disposeSyncSinks();\n } catch (error) {\n errors.push(error);\n }\n throwDisposeErrors(errors);\n}\n\nfunction getConfiguredContextLocalStorage(\n functionName: string,\n): ContextLocalStorage<Record<string, unknown>> {\n if (currentConfig == null) {\n throw new ConfigError(\n `${functionName} requires LogTape to be configured first.`,\n );\n }\n const contextLocalStorage = LoggerImpl.getLogger().contextLocalStorage;\n if (contextLocalStorage == null) {\n throw new ConfigError(\n `${functionName} requires Config.contextLocalStorage to be configured.`,\n );\n }\n return contextLocalStorage;\n}\n\nfunction assertNoScopedConfig(functionName: string): void {\n if (activeScopedConfigCount > 0) {\n throw new ConfigError(\n `${functionName} cannot be called while a scoped configuration is ` +\n \"active. Use nested withConfig() instead.\",\n );\n }\n}\n\nfunction disposeSyncFilters(): void {\n disposeSyncDisposables(filterDisposables);\n}\n\nfunction disposeSyncSinks(): void {\n disposeSyncDisposables(sinkDisposables);\n}\n\nfunction disposeSyncDisposables(disposables: Set<Disposable>): void {\n const errors: unknown[] = [];\n try {\n for (const disposable of disposables) {\n try {\n disposable[Symbol.dispose]();\n } catch (error) {\n errors.push(error);\n } finally {\n disposables.delete(disposable);\n }\n }\n } finally {\n disposables.clear();\n }\n throwDisposeErrors(errors);\n}\n\nasync function disposeAsyncFilters(): Promise<void> {\n await disposeAsyncDisposables(asyncFilterDisposables);\n}\n\nasync function disposeAsyncSinks(): Promise<void> {\n await disposeAsyncDisposables(asyncSinkDisposables);\n}\n\nasync function disposeAsyncDisposables(\n disposables: Set<AsyncDisposable>,\n): Promise<void> {\n const promises: PromiseLike<void>[] = [];\n try {\n for (const disposable of disposables) {\n try {\n promises.push(Promise.resolve(disposable[Symbol.asyncDispose]()));\n } catch (error) {\n promises.push(Promise.reject(error));\n } finally {\n disposables.delete(disposable);\n }\n }\n } finally {\n disposables.clear();\n }\n await settleDisposePromises(promises);\n}\n\nasync function settleDisposePromises(\n promises: readonly PromiseLike<void>[],\n): Promise<void> {\n const results = await Promise.allSettled(promises);\n throwDisposeErrors(\n results\n .filter((result): result is PromiseRejectedResult =>\n result.status === \"rejected\"\n )\n .map((result) => result.reason),\n );\n}\n\nfunction throwDisposeErrors(errors: readonly unknown[]): void {\n if (errors.length < 1) return;\n if (errors.length === 1) throw errors[0];\n throw new AggregateError(\n errors,\n \"Multiple errors occurred while disposing LogTape resources.\",\n );\n}\n\n/**\n * A configuration error.\n */\nexport class ConfigError extends Error {\n /**\n * Constructs a new configuration error.\n * @param message The error message.\n */\n constructor(message: string) {\n super(message);\n this.name = \"ConfigError\";\n }\n}\n"],"mappings":";;;;;;;;;AA2GA,IAAIA,gBAA+C;AACnD,IAAI,0BAA0B;;;;;;AAO9B,MAAMC,6BAA8B,IAAI;;;;AAKxC,MAAMC,oCAAqC,IAAI;;;;AAK/C,MAAMC,kCAAmC,IAAI;;;;AAK7C,MAAMC,yCAA+C,IAAI;;;;AAKzD,MAAMC,uCAA6C,IAAI;;;;AAKvD,SAAS,mBACPC,KACS;CACT,MAAM,WAAW,MAAM,QAAQ,IAAI,SAAS,GAAG,IAAI,WAAW,CAAC,IAAI,QAAS;AAC5E,QAAO,SAAS,WAAW,KACxB,SAAS,WAAW,KAAK,SAAS,OAAO,aACzC,SAAS,WAAW,KACnB,SAAS,OAAO,aAChB,SAAS,OAAO;AACrB;AAED,SAAS,oBAAoBC,YAA2B;CACtD,MAAM,UAAU,aAAa,UAAU;AAEvC,YAEU,WAAmB,gBAAgB,YAC3C,aAAa,gBACX,UAAU,aACZ;EAEA,MAAM,OAAQ,WAAmB;EAEjC,MAAM,WAAW,OAAO;AACxB,aAAW,aAAa,YAAY;AAClC,YAAS,KAAK,MAAM,QAAQ,QAAQ;AACpC;EACD;CACF;CAKD,MAAM,yBAA0B,WAAmB;AACnD,YAAW,2BAA2B,WAAY;AAElD,KAAI,UAAU,WACZ,wBAAuB,KAAK,YAAY,UAAU,QAAQ;KAE1D,wBAAuB,KAAK,YAAY,YAAY,QAAQ;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCD,eAAsB,UAGpBC,QAAmD;AACnD,sBAAqB,cAAc;AACnC,KAAI,iBAAiB,SAAS,OAAO,MACnC,OAAM,IAAI,YACR;AAGJ,OAAM,OAAO;AACb,KAAI;AACF,oBAAkB,Q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;AAED,eAAe,sBAAqC;AAClD,OAAM,wBAAwB,uBAAuB;AACtD;AAED,eAAe,oBAAmC;AAChD,OAAM,wBAAwB,qBAAqB;AACpD;AAED,eAAe,wBACbG,aACe;CACf,MAAMC,WAAgC,CAAE;AACxC,KAAI;AACF,OAAK,MAAM,cAAc,YACvB,KAAI;AACF,YAAS,KAAK,QAAQ,QAAQ,WAAW,OAAO,eAAe,CAAC,CAAC;EAClE,SAAQ,OAAO;AACd,YAAS,KAAK,QAAQ,OAAO,MAAM,CAAC;EACrC,UAAS;AACR,eAAY,OAAO,WAAW;EAC/B;CAEJ,UAAS;AACR,cAAY,OAAO;CACpB;AACD,OAAM,sBAAsB,SAAS;AACtC;AAED,eAAe,sBACbC,UACe;CACf,MAAM,UAAU,MAAM,QAAQ,WAAW,SAAS;AAClD,oBACE,QACG,OAAO,CAAC,WACP,OAAO,WAAW,WACnB,CACA,IAAI,CAAC,WAAW,OAAO,OAAO,CAClC;AACF;AAED,SAAS,mBAAmBC,QAAkC;AAC5D,KAAI,OAAO,SAAS,EAAG;AACvB,KAAI,OAAO,WAAW,EAAG,OAAM,OAAO;AACtC,OAAM,IAAI,eACR,QACA;AAEH;;;;AAKD,IAAa,cAAb,cAAiC,MAAM;;;;;CAKrC,YAAYC,SAAiB;AAC3B,QAAM,QAAQ;AACd,OAAK,OAAO;CACb;AACF"}
1
+ {"version":3,"file":"config.js","names":["currentConfig: Config<string, string> | null","strongRefs: Set<LoggerImpl>","filterDisposables: Set<Disposable>","sinkDisposables: Set<Disposable>","asyncFilterDisposables: Set<AsyncDisposable>","asyncSinkDisposables: Set<AsyncDisposable>","cfg: LoggerConfig<TSinkId, TFilterId>","allowAsync: boolean","config: Config<TSinkId, TFilterId>","config: ScopedConfig<TSinkId, TFilterId>","callback: () => TResult","result: Awaited<TResult>","callbackError: unknown","callback: () => SyncCallbackResult<TResult>","result: SyncCallbackResult<TResult>","value: unknown","errors: unknown[]","functionName: string","callback: () => Promise<T>","callback: () => T","disposables: Set<Disposable>","disposables: Set<AsyncDisposable>","promises: PromiseLike<void>[]","promises: readonly PromiseLike<void>[]","errors: readonly unknown[]","message: string"],"sources":["../src/config.ts"],"sourcesContent":["import type { ContextLocalStorage } from \"./context.ts\";\nimport { type FilterLike, toFilter } from \"./filter.ts\";\nimport type { LogLevel } from \"./level.ts\";\nimport { LoggerImpl } from \"./logger.ts\";\nimport {\n compileScopedConfig,\n disposeScopedConfig,\n disposeScopedConfigSync,\n runWithScopedConfig,\n type ScopedConfigLike,\n throwCombinedErrors,\n} from \"./scoped-config.ts\";\nimport { getConsoleSink, type Sink } from \"./sink.ts\";\n\n/**\n * A configuration for the loggers.\n */\nexport interface Config<TSinkId extends string, TFilterId extends string> {\n /**\n * The sinks to use. The keys are the sink identifiers, and the values are\n * {@link Sink}s.\n */\n sinks: Record<TSinkId, Sink>;\n /**\n * The filters to use. The keys are the filter identifiers, and the values\n * are either {@link Filter}s or {@link LogLevel}s.\n */\n filters?: Record<TFilterId, FilterLike>;\n\n /**\n * The loggers to configure.\n */\n loggers: LoggerConfig<TSinkId, TFilterId>[];\n\n /**\n * The context-local storage to use for implicit contexts.\n * @since 0.7.0\n */\n contextLocalStorage?: ContextLocalStorage<Record<string, unknown>>;\n\n /**\n * Whether to reset the configuration before applying this one.\n */\n reset?: boolean;\n}\n\n/**\n * A scoped configuration for the current execution context.\n *\n * Unlike {@link Config}, this type does not include `reset` or\n * `contextLocalStorage`. Scoped configuration changes only the logging policy\n * for a callback; the context-local storage must already be initialized by the\n * process-global configuration.\n *\n * @since 2.3.0\n */\nexport type ScopedConfig<TSinkId extends string, TFilterId extends string> =\n ScopedConfigLike<TSinkId, TFilterId>;\n\ntype SyncCallbackResult<TResult> = TResult extends PromiseLike<unknown> ? never\n : TResult;\n\n/**\n * A logger configuration.\n */\nexport interface LoggerConfig<\n TSinkId extends string,\n TFilterId extends string,\n> {\n /**\n * The category of the logger. If a string, it is equivalent to an array\n * with one element.\n */\n category: string | string[];\n\n /**\n * The sink identifiers to use.\n */\n sinks?: TSinkId[];\n\n /**\n * Whether to inherit the parent's sinks. If `inherit`, the parent's sinks\n * are used along with the specified sinks. If `override`, the parent's\n * sinks are not used, and only the specified sinks are used.\n *\n * The default is `inherit`.\n * @default `\"inherit\"\n * @since 0.6.0\n */\n parentSinks?: \"inherit\" | \"override\";\n\n /**\n * The filter identifiers to use.\n */\n filters?: TFilterId[];\n\n /**\n * The lowest log level to accept. If `null`, the logger will reject all\n * records.\n * @since 0.8.0\n */\n lowestLevel?: LogLevel | null;\n}\n\n/**\n * The current configuration, if any. Otherwise, `null`.\n */\nlet currentConfig: Config<string, string> | null = null;\nlet activeScopedConfigCount = 0;\nlet globalConfigMutationInProgress = false;\n\n/**\n * Strong references to the loggers.\n * This is to prevent the loggers from being garbage collected so that their\n * sinks and filters are not removed.\n */\nconst strongRefs: Set<LoggerImpl> = new Set();\n\n/**\n * Sync filter disposables to dispose when resetting the configuration.\n */\nconst filterDisposables: Set<Disposable> = new Set();\n\n/**\n * Sync sink disposables to dispose when resetting the configuration.\n */\nconst sinkDisposables: Set<Disposable> = new Set();\n\n/**\n * Async filter disposables to dispose when resetting the configuration.\n */\nconst asyncFilterDisposables: Set<AsyncDisposable> = new Set();\n\n/**\n * Async sink disposables to dispose when resetting the configuration.\n */\nconst asyncSinkDisposables: Set<AsyncDisposable> = new Set();\n\n/**\n * Check if a config is for the meta logger.\n */\nfunction isLoggerConfigMeta<TSinkId extends string, TFilterId extends string>(\n cfg: LoggerConfig<TSinkId, TFilterId>,\n): boolean {\n const category = Array.isArray(cfg.category) ? cfg.category : [cfg.category];\n return category.length === 0 ||\n (category.length === 1 && category[0] === \"logtape\") ||\n (category.length === 2 &&\n category[0] === \"logtape\" &&\n category[1] === \"meta\");\n}\n\nfunction registerDisposeHook(allowAsync: boolean): void {\n const handler = allowAsync ? disposeInternal : disposeSyncInternal;\n\n if (\n // deno-lint-ignore no-explicit-any\n typeof (globalThis as any).EdgeRuntime !== \"string\" &&\n \"process\" in globalThis &&\n !(\"Deno\" in globalThis)\n ) {\n // deno-lint-ignore no-explicit-any\n const proc = (globalThis as any).process;\n // Use bracket notation to avoid static analysis detection in Edge Runtime.\n const onMethod = proc?.[\"on\"];\n if (typeof onMethod === \"function\") {\n onMethod.call(proc, \"exit\", handler);\n return;\n }\n }\n\n // Some edge runtimes expose neither process.on() nor addEventListener().\n // In those environments users can still call dispose()/disposeSync() manually.\n // deno-lint-ignore no-explicit-any\n const addEventListenerMethod = (globalThis as any).addEventListener;\n if (typeof addEventListenerMethod !== \"function\") return;\n\n if (\"Deno\" in globalThis) {\n addEventListenerMethod.call(globalThis, \"unload\", handler);\n } else {\n addEventListenerMethod.call(globalThis, \"pagehide\", handler);\n }\n}\n\n/**\n * Configure the loggers with the specified configuration.\n *\n * Note that if the given sinks or filters are disposable, they will be\n * disposed when the configuration is reset, or when the process exits.\n *\n * @example\n * ```typescript\n * await configure({\n * sinks: {\n * console: getConsoleSink(),\n * },\n * filters: {\n * slow: (log) =>\n * \"duration\" in log.properties &&\n * log.properties.duration as number > 1000,\n * },\n * loggers: [\n * {\n * category: \"my-app\",\n * sinks: [\"console\"],\n * lowestLevel: \"info\",\n * },\n * {\n * category: [\"my-app\", \"sql\"],\n * filters: [\"slow\"],\n * lowestLevel: \"debug\",\n * },\n * {\n * category: \"logtape\",\n * sinks: [\"console\"],\n * lowestLevel: \"error\",\n * },\n * ],\n * });\n * ```\n *\n * @param config The configuration.\n */\nexport async function configure<\n TSinkId extends string,\n TFilterId extends string,\n>(config: Config<TSinkId, TFilterId>): Promise<void> {\n await runGlobalConfigMutation(\"configure()\", async () => {\n if (currentConfig != null && !config.reset) {\n throw new ConfigError(\n \"Already configured; if you want to reset, turn on the reset flag.\",\n );\n }\n await disposeInternal();\n resetInternal();\n try {\n configureInternal(config, true);\n } catch (e) {\n if (e instanceof ConfigError) {\n await disposeInternal();\n resetInternal();\n }\n throw e;\n }\n });\n}\n\n/**\n * Configure sync loggers with the specified configuration.\n *\n * Note that if the given sinks or filters are disposable, they will be\n * disposed when the configuration is reset, or when the process exits.\n *\n * Also note that passing async sinks or filters will throw. If\n * necessary use {@link resetSync} or {@link disposeSync}.\n *\n * @example\n * ```typescript\n * configureSync({\n * sinks: {\n * console: getConsoleSink(),\n * },\n * loggers: [\n * {\n * category: \"my-app\",\n * sinks: [\"console\"],\n * lowestLevel: \"info\",\n * },\n * {\n * category: \"logtape\",\n * sinks: [\"console\"],\n * lowestLevel: \"error\",\n * },\n * ],\n * });\n * ```\n *\n * @param config The configuration.\n * @since 0.9.0\n */\nexport function configureSync<TSinkId extends string, TFilterId extends string>(\n config: Config<TSinkId, TFilterId>,\n): void {\n runGlobalConfigMutationSync(\"configureSync()\", () => {\n if (currentConfig != null && !config.reset) {\n throw new ConfigError(\n \"Already configured; if you want to reset, turn on the reset flag.\",\n );\n }\n if (asyncFilterDisposables.size > 0 || asyncSinkDisposables.size > 0) {\n throw new ConfigError(\n \"Previously configured async disposables are still active. \" +\n \"Use configure() instead or explicitly dispose them using dispose().\",\n );\n }\n disposeSyncInternal();\n resetInternal();\n try {\n configureInternal(config, false);\n } catch (e) {\n if (e instanceof ConfigError) {\n disposeSyncInternal();\n resetInternal();\n }\n throw e;\n }\n });\n}\n\n/**\n * Runs a callback with a LogTape configuration scoped to the current execution\n * context.\n *\n * The process-global configuration must already provide\n * `contextLocalStorage`. The scoped configuration fully overrides global\n * logger routing while the callback and its async work run.\n *\n * @param config The scoped configuration.\n * @param callback The callback to run.\n * @returns The callback's resolved return value.\n * @since 2.3.0\n */\nexport async function withConfig<\n TSinkId extends string,\n TFilterId extends string,\n TResult,\n>(\n config: ScopedConfig<TSinkId, TFilterId>,\n callback: () => TResult,\n): Promise<Awaited<TResult>> {\n const contextLocalStorage = getConfiguredContextLocalStorage(\"withConfig()\");\n const scopedConfig = compileScopedConfig(\n config,\n true,\n (message) => new ConfigError(message),\n );\n\n let result: Awaited<TResult>;\n let callbackError: unknown;\n let callbackFailed = false;\n activeScopedConfigCount++;\n try {\n result = await runWithScopedConfig(\n contextLocalStorage,\n scopedConfig,\n callback,\n );\n } catch (error) {\n callbackFailed = true;\n callbackError = error;\n }\n\n try {\n await disposeScopedConfig(scopedConfig);\n } catch (disposeError) {\n if (callbackFailed) {\n throwCombinedErrors(callbackError, disposeError);\n }\n throw disposeError;\n } finally {\n activeScopedConfigCount--;\n }\n\n if (callbackFailed) throw callbackError;\n return result!;\n}\n\n/**\n * Runs a synchronous callback with a LogTape configuration scoped to the\n * current execution context.\n *\n * The scoped configuration must not contain async disposable sinks or filters.\n *\n * @param config The scoped configuration.\n * @param callback The callback to run.\n * @returns The callback's return value.\n * @since 2.3.0\n */\nexport function withConfigSync<\n TSinkId extends string,\n TFilterId extends string,\n TResult,\n>(\n config: ScopedConfig<TSinkId, TFilterId>,\n callback: () => SyncCallbackResult<TResult>,\n): SyncCallbackResult<TResult> {\n const contextLocalStorage = getConfiguredContextLocalStorage(\n \"withConfigSync()\",\n );\n const scopedConfig = compileScopedConfig(\n config,\n false,\n (message) => new ConfigError(message),\n );\n\n let result: SyncCallbackResult<TResult>;\n let callbackError: unknown;\n let callbackFailed = false;\n activeScopedConfigCount++;\n try {\n result = runWithScopedConfig(contextLocalStorage, scopedConfig, callback);\n if (isThenable(result)) {\n void Promise.resolve(result).catch(() => {});\n callbackFailed = true;\n callbackError = new ConfigError(\n \"withConfigSync() callback must not return a promise. \" +\n \"Use withConfig() for async callbacks.\",\n );\n }\n } catch (error) {\n callbackFailed = true;\n callbackError = error;\n }\n\n try {\n disposeScopedConfigSync(scopedConfig);\n } catch (disposeError) {\n if (callbackFailed) {\n throwCombinedErrors(callbackError, disposeError);\n }\n throw disposeError;\n } finally {\n activeScopedConfigCount--;\n }\n\n if (callbackFailed) throw callbackError;\n return result!;\n}\n\nfunction isThenable(value: unknown): value is PromiseLike<unknown> {\n return value != null &&\n (typeof value === \"object\" || typeof value === \"function\") &&\n \"then\" in value &&\n typeof value.then === \"function\";\n}\n\nfunction configureInternal<\n TSinkId extends string,\n TFilterId extends string,\n>(config: Config<TSinkId, TFilterId>, allowAsync: boolean): void {\n currentConfig = config;\n\n let metaConfigured = false;\n const configuredCategories = new Set<string>();\n\n for (const cfg of config.loggers) {\n if (isLoggerConfigMeta(cfg)) {\n metaConfigured = true;\n }\n\n // Check for duplicate logger categories\n const categoryKey = Array.isArray(cfg.category)\n ? JSON.stringify(cfg.category)\n : JSON.stringify([cfg.category]);\n if (configuredCategories.has(categoryKey)) {\n throw new ConfigError(\n `Duplicate logger configuration for category: ${categoryKey}. ` +\n `Each category can only be configured once.`,\n );\n }\n configuredCategories.add(categoryKey);\n\n const logger = LoggerImpl.getLogger(cfg.category);\n for (const sinkId of cfg.sinks ?? []) {\n const sink = config.sinks[sinkId];\n if (!sink) {\n throw new ConfigError(`Sink not found: ${sinkId}.`);\n }\n logger.sinks.push(sink);\n }\n logger.parentSinks = cfg.parentSinks ?? \"inherit\";\n if (cfg.lowestLevel !== undefined) {\n logger.lowestLevel = cfg.lowestLevel;\n }\n for (const filterId of cfg.filters ?? []) {\n const filter = config.filters?.[filterId];\n if (filter === undefined) {\n throw new ConfigError(`Filter not found: ${filterId}.`);\n }\n logger.filters.push(toFilter(filter));\n }\n strongRefs.add(logger);\n }\n\n LoggerImpl.getLogger().contextLocalStorage = config.contextLocalStorage;\n\n for (const sink of Object.values<Sink>(config.sinks)) {\n if (Symbol.asyncDispose in sink) {\n if (allowAsync) asyncSinkDisposables.add(sink as AsyncDisposable);\n else {\n throw new ConfigError(\n \"Async disposables cannot be used with configureSync().\",\n );\n }\n }\n if (Symbol.dispose in sink) sinkDisposables.add(sink as Disposable);\n }\n\n for (const filter of Object.values<FilterLike>(config.filters ?? {})) {\n if (filter == null || typeof filter === \"string\") continue;\n if (Symbol.asyncDispose in filter) {\n if (allowAsync) asyncFilterDisposables.add(filter as AsyncDisposable);\n else {\n throw new ConfigError(\n \"Async disposables cannot be used with configureSync().\",\n );\n }\n asyncSinkDisposables.delete(filter as AsyncDisposable);\n }\n if (Symbol.dispose in filter) {\n filterDisposables.add(filter as Disposable);\n sinkDisposables.delete(filter as Disposable);\n }\n }\n\n registerDisposeHook(allowAsync);\n const meta = LoggerImpl.getLogger([\"logtape\", \"meta\"]);\n if (!metaConfigured) {\n meta.sinks.push(getConsoleSink());\n }\n\n meta.info(\n \"LogTape loggers are configured. Note that LogTape itself uses the meta \" +\n \"logger, which has category {metaLoggerCategory}. The meta logger is \" +\n \"used to log internal diagnostics such as sink exceptions. \" +\n \"It's recommended to configure the meta logger with a separate sink \" +\n \"so that you can easily notice if logging itself fails or is \" +\n \"misconfigured. To turn off this message, configure the meta logger \" +\n \"with higher log levels than {dismissLevel}. See also \" +\n \"<https://logtape.org/manual/categories#meta-logger>.\",\n { metaLoggerCategory: [\"logtape\", \"meta\"], dismissLevel: \"info\" },\n );\n}\n\n/**\n * Get the current configuration, if any. Otherwise, `null`.\n * @returns The current configuration, if any. Otherwise, `null`.\n */\nexport function getConfig(): Config<string, string> | null {\n return currentConfig;\n}\n\n/**\n * Reset the configuration. Mostly for testing purposes.\n */\nexport async function reset(): Promise<void> {\n await runGlobalConfigMutation(\"reset()\", async () => {\n await disposeInternal();\n resetInternal();\n });\n}\n\n/**\n * Reset the configuration. Mostly for testing purposes. Will not clear async\n * sinks, only use with sync sinks. Use {@link reset} if you have async sinks.\n * @since 0.9.0\n */\nexport function resetSync(): void {\n runGlobalConfigMutationSync(\"resetSync()\", () => {\n disposeSyncInternal();\n resetInternal();\n });\n}\n\nfunction resetInternal(): void {\n const rootLogger = LoggerImpl.getLogger([]);\n rootLogger.resetDescendants();\n delete rootLogger.contextLocalStorage;\n strongRefs.clear();\n currentConfig = null;\n}\n\n/**\n * Dispose of the disposables.\n */\nexport async function dispose(): Promise<void> {\n await runGlobalConfigMutation(\"dispose()\", disposeInternal);\n}\n\nasync function disposeInternal(): Promise<void> {\n const errors: unknown[] = [];\n try {\n disposeSyncFilters();\n } catch (error) {\n errors.push(error);\n }\n try {\n await disposeAsyncFilters();\n } catch (error) {\n errors.push(error);\n }\n try {\n disposeSyncSinks();\n } catch (error) {\n errors.push(error);\n }\n try {\n await disposeAsyncSinks();\n } catch (error) {\n errors.push(error);\n }\n throwDisposeErrors(errors);\n}\n\n/**\n * Dispose of the sync disposables. Async disposables will be untouched,\n * use {@link dispose} if you have async sinks.\n * @since 0.9.0\n */\nexport function disposeSync(): void {\n runGlobalConfigMutationSync(\"disposeSync()\", disposeSyncInternal);\n}\n\nfunction disposeSyncInternal(): void {\n const errors: unknown[] = [];\n try {\n disposeSyncFilters();\n } catch (error) {\n errors.push(error);\n }\n try {\n disposeSyncSinks();\n } catch (error) {\n errors.push(error);\n }\n throwDisposeErrors(errors);\n}\n\nfunction getConfiguredContextLocalStorage(\n functionName: string,\n): ContextLocalStorage<Record<string, unknown>> {\n if (globalConfigMutationInProgress) {\n throw new ConfigError(\n `${functionName} cannot be called while LogTape is being reconfigured.`,\n );\n }\n if (currentConfig == null) {\n throw new ConfigError(\n `${functionName} requires LogTape to be configured first.`,\n );\n }\n const contextLocalStorage = LoggerImpl.getLogger().contextLocalStorage;\n if (contextLocalStorage == null) {\n throw new ConfigError(\n `${functionName} requires Config.contextLocalStorage to be configured.`,\n );\n }\n return contextLocalStorage;\n}\n\nasync function runGlobalConfigMutation<T>(\n functionName: string,\n callback: () => Promise<T>,\n): Promise<T> {\n assertCanMutateGlobalConfig(functionName);\n globalConfigMutationInProgress = true;\n try {\n return await callback();\n } finally {\n globalConfigMutationInProgress = false;\n }\n}\n\nfunction runGlobalConfigMutationSync<T>(\n functionName: string,\n callback: () => T,\n): T {\n assertCanMutateGlobalConfig(functionName);\n globalConfigMutationInProgress = true;\n try {\n return callback();\n } finally {\n globalConfigMutationInProgress = false;\n }\n}\n\nfunction assertCanMutateGlobalConfig(functionName: string): void {\n if (globalConfigMutationInProgress) {\n throw new ConfigError(\n `${functionName} cannot be called while LogTape is being reconfigured.`,\n );\n }\n assertNoScopedConfig(functionName);\n}\n\nfunction assertNoScopedConfig(functionName: string): void {\n if (activeScopedConfigCount > 0) {\n throw new ConfigError(\n `${functionName} cannot be called while a scoped configuration is ` +\n \"active. Use nested withConfig() instead.\",\n );\n }\n}\n\nfunction disposeSyncFilters(): void {\n disposeSyncDisposables(filterDisposables);\n}\n\nfunction disposeSyncSinks(): void {\n disposeSyncDisposables(sinkDisposables);\n}\n\nfunction disposeSyncDisposables(disposables: Set<Disposable>): void {\n const errors: unknown[] = [];\n try {\n for (const disposable of disposables) {\n try {\n disposable[Symbol.dispose]();\n } catch (error) {\n errors.push(error);\n } finally {\n disposables.delete(disposable);\n }\n }\n } finally {\n disposables.clear();\n }\n throwDisposeErrors(errors);\n}\n\nasync function disposeAsyncFilters(): Promise<void> {\n await disposeAsyncDisposables(asyncFilterDisposables);\n}\n\nasync function disposeAsyncSinks(): Promise<void> {\n await disposeAsyncDisposables(asyncSinkDisposables);\n}\n\nasync function disposeAsyncDisposables(\n disposables: Set<AsyncDisposable>,\n): Promise<void> {\n const promises: PromiseLike<void>[] = [];\n try {\n for (const disposable of disposables) {\n try {\n promises.push(Promise.resolve(disposable[Symbol.asyncDispose]()));\n } catch (error) {\n promises.push(Promise.reject(error));\n } finally {\n disposables.delete(disposable);\n }\n }\n } finally {\n disposables.clear();\n }\n await settleDisposePromises(promises);\n}\n\nasync function settleDisposePromises(\n promises: readonly PromiseLike<void>[],\n): Promise<void> {\n const results = await Promise.allSettled(promises);\n throwDisposeErrors(\n results\n .filter((result): result is PromiseRejectedResult =>\n result.status === \"rejected\"\n )\n .map((result) => result.reason),\n );\n}\n\nfunction throwDisposeErrors(errors: readonly unknown[]): void {\n if (errors.length < 1) return;\n if (errors.length === 1) throw errors[0];\n throw new AggregateError(\n errors,\n \"Multiple errors occurred while disposing LogTape resources.\",\n );\n}\n\n/**\n * A configuration error.\n */\nexport class ConfigError extends Error {\n /**\n * Constructs a new configuration error.\n * @param message The error message.\n */\n constructor(message: string) {\n super(message);\n this.name = \"ConfigError\";\n }\n}\n"],"mappings":";;;;;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EH;;;;AAKD,IAAa,cAAb,cAAiC,MAAM;;;;;CAKrC,YAAYC,SAAiB;AAC3B,QAAM,QAAQ;AACd,OAAK,OAAO;CACb;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","names":["lazySymbol: unique symbol","internalStringLogRecords: WeakSet<LogRecord>","resolvedStringLogRecords: WeakSet<LogRecord>","value: unknown","getter: () => T","properties: Record<string, unknown>","resolved: Record<string, unknown>","logger: StringMessageLogger","level: LogLevel","message: string","props?: unknown","record: LogRecord","properties: unknown","sink: Sink","category: string | readonly string[]","category: readonly string[]","rootLogger: LoggerImpl | null","parent: LoggerImpl | null","#parentSinks","value: \"inherit\" | \"override\"","#lowestLevel","value: LogLevel | null","subcategory:\n | string\n | readonly [string]\n | readonly [string, ...(readonly string[])]","child: LoggerImpl | undefined","#sinkPlanCache","plan: SinkDispatchPlan","parentPlan: SinkDispatchPlan | undefined","state: SinkDispatchPlanState","firstSink: Sink | undefined","sinks: Sink[] | undefined","record: Omit<LogRecord, \"category\"> | LogRecord","bypassSinks?: Set<Sink>","snapshot: LogRecord | undefined","snapshotFailed: boolean","snapshot","snapshotFailed","rawMessage: string","properties: Record<string, unknown> | (() => Record<string, unknown>)","record","cachedProps: Record<string, unknown> | undefined","cachedMessage: readonly unknown[] | undefined","callback: LogCallback","rawMessage: TemplateStringsArray | undefined","msg: unknown[] | undefined","messageTemplate: TemplateStringsArray","values: unknown[]","message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>","level: \"warning\" | \"error\" | \"fatal\"","error: Error","message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error","logger: LoggerImpl","subcategory: string | readonly [string] | readonly [string, ...string[]]","record: Omit<LogRecord, \"category\">","key: string","obj: unknown","path: string","fromIndex: number","segment: string | number","current: unknown","template: string","message: unknown[]","prop: unknown","template: TemplateStringsArray","values: readonly unknown[]"],"sources":["../src/logger.ts"],"sourcesContent":["import {\n type ContextLocalStorage,\n getCategoryPrefix,\n getImplicitContextIfAny,\n} from \"./context.ts\";\nimport type { Filter } from \"./filter.ts\";\nimport { compareLogLevel, type LogLevel } from \"./level.ts\";\nimport type { LogRecord } from \"./record.ts\";\nimport {\n emitWithScopedConfig,\n getCurrentScopedConfig,\n scopedConfigHasSink,\n} from \"./scoped-config.ts\";\nimport type { Sink } from \"./sink.ts\";\n\n/**\n * Symbol to identify lazy values.\n */\nconst lazySymbol: unique symbol = Symbol.for(\"logtape.lazy\");\nconst throttlingSummaryRecordSymbol = Symbol.for(\n \"LogTape.throttlingSummaryRecord\",\n);\nconst immediateSinkSymbol = Symbol.for(\n \"LogTape.sinkSnapshotPolicy.immediate\",\n);\nconst internalStringLogRecords: WeakSet<LogRecord> = new WeakSet();\nconst resolvedStringLogRecords: WeakSet<LogRecord> = new WeakSet();\n\n/**\n * A lazy value that is evaluated at logging time.\n *\n * @typeParam T The type of the value.\n * @since 2.0.0\n */\nexport interface Lazy<T> {\n readonly [lazySymbol]: true;\n readonly getter: () => T;\n}\n\n/**\n * Checks if a value is a lazy value.\n *\n * @param value The value to check.\n * @returns `true` if the value is a lazy value, `false` otherwise.\n * @since 2.0.0\n */\nexport function isLazy(value: unknown): value is Lazy<unknown> {\n return value != null &&\n typeof value === \"object\" &&\n lazySymbol in value &&\n (value as Lazy<unknown>)[lazySymbol] === true;\n}\n\n/**\n * Creates a lazy value that is evaluated at logging time.\n *\n * This is useful for logging contextual properties that may change over time,\n * such as the current user or request context.\n *\n * @example\n * ```typescript\n * let currentUser: string | null = null;\n * const logger = getLogger(\"app\").with({ user: lazy(() => currentUser) });\n *\n * logger.info(\"User action\"); // logs with user: null\n * currentUser = \"alice\";\n * logger.info(\"User action\"); // logs with user: \"alice\"\n * ```\n *\n * @typeParam T The type of the value.\n * @param getter A function that returns the value.\n * @returns A lazy value.\n * @since 2.0.0\n */\nexport function lazy<T>(getter: () => T): Lazy<T> {\n return { [lazySymbol]: true, getter };\n}\n\n/**\n * Resolves lazy values in a properties object.\n *\n * @param properties The properties object with potential lazy values.\n * @returns A new object with all lazy values resolved.\n */\nfunction resolveProperties(\n properties: Record<string, unknown>,\n): Record<string, unknown> {\n const resolved: Record<string, unknown> = {};\n for (const key in properties) {\n const value = properties[key];\n resolved[key] = isLazy(value) ? value.getter() : value;\n }\n const symbolProperties = properties as Record<symbol, unknown>;\n const symbolResolved = resolved as Record<symbol, unknown>;\n if (\n Object.prototype.propertyIsEnumerable.call(\n properties,\n throttlingSummaryRecordSymbol,\n )\n ) {\n const value = symbolProperties[throttlingSummaryRecordSymbol];\n symbolResolved[throttlingSummaryRecordSymbol] = isLazy(value)\n ? value.getter()\n : value;\n }\n return resolved;\n}\n\ntype LazyPropertiesCallback = () =>\n | Record<string, unknown>\n | Promise<Record<string, unknown>>;\n\nfunction isPromiseObject<T>(value: unknown): value is Promise<T> {\n // `instanceof Promise` only works for promises created in this realm.\n // Lazy callbacks may return a promise from another realm, such as a\n // `node:vm` context or a browser iframe, so we need a fallback.\n if (value instanceof Promise) return true;\n\n // `Object.prototype.toString` recognizes native promises across realms.\n // We also require a callable `then` so an object that only spoofs\n // `Symbol.toStringTag = \"Promise\"` is not treated as an async result.\n return Object.prototype.toString.call(value) === \"[object Promise]\" &&\n typeof (value as Promise<T>).then === \"function\";\n}\n\ninterface StringMessageLogger {\n isEnabledFor(level: LogLevel): boolean;\n log(\n level: LogLevel,\n message: string,\n properties: Record<string, unknown>,\n ): void;\n}\n\n// Callback-based string-message overloads are intentionally \"fire-and-forget\".\n// When the level is filtered out, we return an already-resolved promise\n// without invoking the callback so async property callbacks remain awaitable.\n// Synchronous callback call sites are expected to ignore the return value.\nfunction logStringMessage(\n logger: StringMessageLogger,\n level: LogLevel,\n message: string,\n props?: unknown,\n): void | Promise<void> {\n if (typeof props !== \"function\") {\n const properties = (props ?? {}) as Record<string, unknown>;\n logger.log(level, message, properties);\n return;\n }\n\n if (!logger.isEnabledFor(level)) return Promise.resolve();\n\n const result = (props as LazyPropertiesCallback)();\n if (isPromiseObject<Record<string, unknown>>(result)) {\n return Promise.resolve(result).then((resolvedProps) => {\n logger.log(level, message, resolvedProps);\n });\n }\n\n logger.log(level, message, result);\n}\n\nfunction snapshotLogRecordProperties(record: LogRecord): LogRecord {\n if (resolvedStringLogRecords.has(record)) {\n // The simple string fast path already owns a per-record properties object.\n // Reusing the record avoids the snapshot allocation in the hottest path.\n return record;\n }\n const properties: Record<string, unknown> = resolveProperties(\n record.properties,\n );\n if (internalStringLogRecords.has(record)) {\n // LoggerImpl.log() creates this fixed shape. Rebuilding it directly keeps\n // lazy message rendering intact without copying property descriptors.\n return {\n category: record.category,\n level: record.level,\n get message() {\n return record.message;\n },\n rawMessage: record.rawMessage,\n timestamp: record.timestamp,\n properties,\n };\n }\n const descriptors = Object.getOwnPropertyDescriptors(record) as\n & PropertyDescriptorMap\n & { properties?: PropertyDescriptor };\n descriptors.properties = {\n value: properties,\n enumerable: true,\n configurable: true,\n };\n return Object.defineProperties({}, descriptors) as LogRecord;\n}\n\nfunction hasEnumerableProperties(properties: unknown): boolean {\n if (properties == null || typeof properties !== \"object\") return false;\n return Object.keys(properties).length > 0 ||\n Object.prototype.propertyIsEnumerable.call(\n properties,\n throttlingSummaryRecordSymbol,\n );\n}\n\nfunction shouldSnapshotForSink(sink: Sink): boolean {\n // Custom sinks are assumed to be buffering sinks. Only built-in sinks that\n // synchronously finish formatting/encoding opt into receiving the live record.\n return (sink as unknown as Record<symbol, unknown>)[immediateSinkSymbol] !==\n true;\n}\n\ntype SinkDispatchPlanState = {\n readonly localSinks: readonly Sink[];\n readonly parentSinks: \"inherit\" | \"override\";\n readonly lowestLevel: LogLevel | null;\n readonly parentPlan: SinkDispatchPlan | undefined;\n};\n\ntype SinkDispatchPlan =\n & SinkDispatchPlanState\n & (\n | { readonly kind: \"none\" }\n | {\n readonly kind: \"one\";\n readonly sink: Sink;\n }\n | {\n readonly kind: \"many\";\n readonly sinks: readonly Sink[];\n }\n );\n\n/**\n * A logger interface. It provides methods to log messages at different\n * severity levels.\n *\n * ```typescript\n * const logger = getLogger(\"category\");\n * logger.trace `A trace message with ${value}`\n * logger.debug `A debug message with ${value}.`;\n * logger.info `An info message with ${value}.`;\n * logger.warn `A warning message with ${value}.`;\n * logger.error `An error message with ${value}.`;\n * logger.fatal `A fatal error message with ${value}.`;\n * ```\n *\n * Callback-based string-message overloads should be treated as\n * fire-and-forget. Async callbacks return `Promise<void>`, and when a\n * callback is filtered out because the level is disabled an implementation may\n * still return an already-resolved promise so the async path remains awaitable\n * without invoking the callback. Call sites should not branch on these\n * return values.\n */\nexport interface Logger {\n /**\n * The category of the logger. It is an array of strings.\n */\n readonly category: readonly string[];\n\n /**\n * The logger with the supercategory of the current logger. If the current\n * logger is the root logger, this is `null`.\n */\n readonly parent: Logger | null;\n\n /**\n * Get a child logger with the given subcategory.\n *\n * ```typescript\n * const logger = getLogger(\"category\");\n * const subLogger = logger.getChild(\"sub-category\");\n * ```\n *\n * The above code is equivalent to:\n *\n * ```typescript\n * const logger = getLogger(\"category\");\n * const subLogger = getLogger([\"category\", \"sub-category\"]);\n * ```\n *\n * @param subcategory The subcategory.\n * @returns The child logger.\n */\n getChild(\n subcategory: string | readonly [string] | readonly [string, ...string[]],\n ): Logger;\n\n /**\n * Get a logger with contextual properties. This is useful for\n * log multiple messages with the shared set of properties.\n *\n * ```typescript\n * const logger = getLogger(\"category\");\n * const ctx = logger.with({ foo: 123, bar: \"abc\" });\n * ctx.info(\"A message with {foo} and {bar}.\");\n * ctx.warn(\"Another message with {foo}, {bar}, and {baz}.\", { baz: true });\n * ```\n *\n * The above code is equivalent to:\n *\n * ```typescript\n * const logger = getLogger(\"category\");\n * logger.info(\"A message with {foo} and {bar}.\", { foo: 123, bar: \"abc\" });\n * logger.warn(\n * \"Another message with {foo}, {bar}, and {baz}.\",\n * { foo: 123, bar: \"abc\", baz: true },\n * );\n * ```\n *\n * @param properties\n * @returns\n * @since 0.5.0\n */\n with(properties: Record<string, unknown>): Logger;\n\n /**\n * Log a trace message. Use this as a template string prefix.\n *\n * ```typescript\n * logger.trace `A trace message with ${value}.`;\n * ```\n *\n * @param message The message template strings array.\n * @param values The message template values.\n * @since 0.12.0\n */\n trace(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n\n /**\n * Log a trace message with properties.\n *\n * ```typescript\n * logger.trace('A trace message with {value}.', { value });\n * ```\n *\n * If the properties are expensive to compute, you can pass a callback that\n * returns the properties:\n *\n * ```typescript\n * logger.trace(\n * 'A trace message with {value}.',\n * () => ({ value: expensiveComputation() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties The values to replace placeholders with. For lazy\n * evaluation, this can be a callback that returns the\n * properties.\n * @since 0.12.0\n */\n trace(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log a trace message with properties computed asynchronously.\n *\n * Use this when the properties require async operations to compute:\n *\n * ```typescript\n * await logger.trace(\n * 'A trace message with {value}.',\n * async () => ({ value: await fetchValue() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties An async callback that returns the properties.\n * @returns A promise that resolves when the log is written.\n * @since 2.0.0\n */\n trace(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n\n /**\n * Log a trace values with no message. This is useful when you\n * want to log properties without a message, e.g., when you want to log\n * the context of a request or an operation.\n *\n * ```typescript\n * logger.trace({ method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * Note that this is a shorthand for:\n *\n * ```typescript\n * logger.trace('{*}', { method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * If the properties are expensive to compute, you cannot use this shorthand\n * and should use the following syntax instead:\n *\n * ```typescript\n * logger.trace('{*}', () => ({\n * method: expensiveMethod(),\n * url: expensiveUrl(),\n * }));\n * ```\n *\n * @param properties The values to log. Note that this does not take\n * a callback.\n * @since 0.12.0\n */\n trace(properties: Record<string, unknown>): void;\n\n /**\n * Lazily log a trace message. Use this when the message values are expensive\n * to compute and should only be computed if the message is actually logged.\n *\n * ```typescript\n * logger.trace(l => l`A trace message with ${expensiveValue()}.`);\n * ```\n *\n * @param callback A callback that returns the message template prefix.\n * @throws {TypeError} If no log record was made inside the callback.\n * @since 0.12.0\n */\n trace(callback: LogCallback): void;\n\n /**\n * Log a debug message. Use this as a template string prefix.\n *\n * ```typescript\n * logger.debug `A debug message with ${value}.`;\n * ```\n *\n * @param message The message template strings array.\n * @param values The message template values.\n */\n debug(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n\n /**\n * Log a debug message with properties.\n *\n * ```typescript\n * logger.debug('A debug message with {value}.', { value });\n * ```\n *\n * If the properties are expensive to compute, you can pass a callback that\n * returns the properties:\n *\n * ```typescript\n * logger.debug(\n * 'A debug message with {value}.',\n * () => ({ value: expensiveComputation() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties The values to replace placeholders with. For lazy\n * evaluation, this can be a callback that returns the\n * properties.\n */\n debug(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log a debug message with properties computed asynchronously.\n *\n * Use this when the properties require async operations to compute:\n *\n * ```typescript\n * await logger.debug(\n * 'A debug message with {value}.',\n * async () => ({ value: await fetchValue() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties An async callback that returns the properties.\n * @returns A promise that resolves when the log is written.\n * @since 2.0.0\n */\n debug(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n\n /**\n * Log a debug values with no message. This is useful when you\n * want to log properties without a message, e.g., when you want to log\n * the context of a request or an operation.\n *\n * ```typescript\n * logger.debug({ method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * Note that this is a shorthand for:\n *\n * ```typescript\n * logger.debug('{*}', { method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * If the properties are expensive to compute, you cannot use this shorthand\n * and should use the following syntax instead:\n *\n * ```typescript\n * logger.debug('{*}', () => ({\n * method: expensiveMethod(),\n * url: expensiveUrl(),\n * }));\n * ```\n *\n * @param properties The values to log. Note that this does not take\n * a callback.\n * @since 0.11.0\n */\n debug(properties: Record<string, unknown>): void;\n\n /**\n * Lazily log a debug message. Use this when the message values are expensive\n * to compute and should only be computed if the message is actually logged.\n *\n * ```typescript\n * logger.debug(l => l`A debug message with ${expensiveValue()}.`);\n * ```\n *\n * @param callback A callback that returns the message template prefix.\n * @throws {TypeError} If no log record was made inside the callback.\n */\n debug(callback: LogCallback): void;\n\n /**\n * Log an informational message. Use this as a template string prefix.\n *\n * ```typescript\n * logger.info `An info message with ${value}.`;\n * ```\n *\n * @param message The message template strings array.\n * @param values The message template values.\n */\n info(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n\n /**\n * Log an informational message with properties.\n *\n * ```typescript\n * logger.info('An info message with {value}.', { value });\n * ```\n *\n * If the properties are expensive to compute, you can pass a callback that\n * returns the properties:\n *\n * ```typescript\n * logger.info(\n * 'An info message with {value}.',\n * () => ({ value: expensiveComputation() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties The values to replace placeholders with. For lazy\n * evaluation, this can be a callback that returns the\n * properties.\n */\n info(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log an informational message with properties computed asynchronously.\n *\n * Use this when the properties require async operations to compute:\n *\n * ```typescript\n * await logger.info(\n * 'An info message with {value}.',\n * async () => ({ value: await fetchValue() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties An async callback that returns the properties.\n * @returns A promise that resolves when the log is written.\n * @since 2.0.0\n */\n info(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n\n /**\n * Log an informational values with no message. This is useful when you\n * want to log properties without a message, e.g., when you want to log\n * the context of a request or an operation.\n *\n * ```typescript\n * logger.info({ method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * Note that this is a shorthand for:\n *\n * ```typescript\n * logger.info('{*}', { method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * If the properties are expensive to compute, you cannot use this shorthand\n * and should use the following syntax instead:\n *\n * ```typescript\n * logger.info('{*}', () => ({\n * method: expensiveMethod(),\n * url: expensiveUrl(),\n * }));\n * ```\n *\n * @param properties The values to log. Note that this does not take\n * a callback.\n * @since 0.11.0\n */\n info(properties: Record<string, unknown>): void;\n\n /**\n * Lazily log an informational message. Use this when the message values are\n * expensive to compute and should only be computed if the message is actually\n * logged.\n *\n * ```typescript\n * logger.info(l => l`An info message with ${expensiveValue()}.`);\n * ```\n *\n * @param callback A callback that returns the message template prefix.\n * @throws {TypeError} If no log record was made inside the callback.\n */\n info(callback: LogCallback): void;\n\n /**\n * Log a warning.\n *\n * This overload is a shorthand for logging an {@link Error} instance as a\n * structured property.\n *\n * ```typescript\n * logger.warn(new Error(\"Oops\"));\n * ```\n *\n * Note that this uses `{error.message}` as the default message template.\n * If you want to include the stack trace in text output, include `{error}`\n * in the message template instead.\n *\n * @param error The error to log.\n * @since 2.0.0\n */\n warn(error: Error): void;\n\n /**\n * Log a warning with additional properties.\n *\n * This overload is a shorthand for logging an {@link Error} instance as a\n * structured property while also adding extra properties.\n *\n * ```typescript\n * logger.warn(new Error(\"Oops\"), { requestId });\n * ```\n *\n * @param error The error to log.\n * @param properties Additional properties to log alongside the error.\n * @since 2.1.0\n */\n warn(\n error: Error,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log a warning with additional properties computed asynchronously.\n *\n * @param error The error to log.\n * @param properties An async callback that returns the properties.\n * @returns A promise that resolves when the log is written.\n * @since 2.1.0\n */\n warn(\n error: Error,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n\n /**\n * Log a warning message with an {@link Error}.\n *\n * ```typescript\n * logger.warn(\"Failed to do something\", new Error(\"Oops\"));\n * ```\n *\n * @param message The message.\n * @param error The error to log.\n * @since 2.0.0\n */\n warn(message: string, error: Error): void;\n\n /**\n * Log a warning message. Use this as a template string prefix.\n *\n * ```typescript\n * logger.warn `A warning message with ${value}.`;\n * ```\n *\n * @param message The message template strings array.\n * @param values The message template values.\n */\n warn(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n\n /**\n * Log a warning message with properties.\n *\n * ```typescript\n * logger.warn('A warning message with {value}.', { value });\n * ```\n *\n * If the properties are expensive to compute, you can pass a callback that\n * returns the properties:\n *\n * ```typescript\n * logger.warn(\n * 'A warning message with {value}.',\n * () => ({ value: expensiveComputation() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties The values to replace placeholders with. For lazy\n * evaluation, this can be a callback that returns the\n * properties.\n */\n warn(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log a warning message with properties computed asynchronously.\n *\n * Use this when the properties require async operations to compute:\n *\n * ```typescript\n * await logger.warn(\n * 'A warning message with {value}.',\n * async () => ({ value: await fetchValue() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties An async callback that returns the properties.\n * @returns A promise that resolves when the log is written.\n * @since 2.0.0\n */\n warn(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n\n /**\n * Log a warning values with no message. This is useful when you\n * want to log properties without a message, e.g., when you want to log\n * the context of a request or an operation.\n *\n * ```typescript\n * logger.warn({ method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * Note that this is a shorthand for:\n *\n * ```typescript\n * logger.warn('{*}', { method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * If the properties are expensive to compute, you cannot use this shorthand\n * and should use the following syntax instead:\n *\n * ```typescript\n * logger.warn('{*}', () => ({\n * method: expensiveMethod(),\n * url: expensiveUrl(),\n * }));\n * ```\n *\n * @param properties The values to log. Note that this does not take\n * a callback.\n * @since 0.11.0\n */\n warn(properties: Record<string, unknown>): void;\n\n /**\n * Lazily log a warning message. Use this when the message values are\n * expensive to compute and should only be computed if the message is actually\n * logged.\n *\n * ```typescript\n * logger.warn(l => l`A warning message with ${expensiveValue()}.`);\n * ```\n *\n * @param callback A callback that returns the message template prefix.\n * @throws {TypeError} If no log record was made inside the callback.\n */\n warn(callback: LogCallback): void;\n\n /**\n * Log a warning.\n *\n * This overload is a shorthand for logging an {@link Error} instance as a\n * structured property.\n *\n * ```typescript\n * logger.warning(new Error(\"Oops\"));\n * ```\n *\n * Note that this uses `{error.message}` as the default message template.\n * If you want to include the stack trace in text output, include `{error}`\n * in the message template instead.\n *\n * @param error The error to log.\n * @since 2.0.0\n */\n warning(error: Error): void;\n\n /**\n * Log a warning with additional properties.\n *\n * This overload is a shorthand for logging an {@link Error} instance as a\n * structured property while also adding extra properties.\n *\n * ```typescript\n * logger.warning(new Error(\"Oops\"), { requestId });\n * ```\n *\n * @param error The error to log.\n * @param properties Additional properties to log alongside the error.\n * @since 2.1.0\n */\n warning(\n error: Error,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log a warning with additional properties computed asynchronously.\n *\n * @param error The error to log.\n * @param properties An async callback that returns the properties.\n * @returns A promise that resolves when the log is written.\n * @since 2.1.0\n */\n warning(\n error: Error,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n\n /**\n * Log a warning message with an {@link Error}.\n *\n * ```typescript\n * logger.warning(\"Failed to do something\", new Error(\"Oops\"));\n * ```\n *\n * @param message The message.\n * @param error The error to log.\n * @since 2.0.0\n */\n warning(message: string, error: Error): void;\n\n /**\n * Log a warning message. Use this as a template string prefix.\n *\n * ```typescript\n * logger.warning `A warning message with ${value}.`;\n * ```\n *\n * @param message The message template strings array.\n * @param values The message template values.\n * @since 0.12.0\n */\n warning(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n\n /**\n * Log a warning message with properties.\n *\n * ```typescript\n * logger.warning('A warning message with {value}.', { value });\n * ```\n *\n * If the properties are expensive to compute, you can pass a callback that\n * returns the properties:\n *\n * ```typescript\n * logger.warning(\n * 'A warning message with {value}.',\n * () => ({ value: expensiveComputation() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties The values to replace placeholders with. For lazy\n * evaluation, this can be a callback that returns the\n * properties.\n * @since 0.12.0\n */\n warning(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log a warning message with properties computed asynchronously.\n *\n * Use this when the properties require async operations to compute:\n *\n * ```typescript\n * await logger.warning(\n * 'A warning message with {value}.',\n * async () => ({ value: await fetchValue() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties An async callback that returns the properties.\n * @returns A promise that resolves when the log is written.\n * @since 2.0.0\n */\n warning(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n\n /**\n * Log a warning values with no message. This is useful when you\n * want to log properties without a message, e.g., when you want to log\n * the context of a request or an operation.\n *\n * ```typescript\n * logger.warning({ method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * Note that this is a shorthand for:\n *\n * ```typescript\n * logger.warning('{*}', { method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * If the properties are expensive to compute, you cannot use this shorthand\n * and should use the following syntax instead:\n *\n * ```typescript\n * logger.warning('{*}', () => ({\n * method: expensiveMethod(),\n * url: expensiveUrl(),\n * }));\n * ```\n *\n * @param properties The values to log. Note that this does not take\n * a callback.\n * @since 0.12.0\n */\n warning(properties: Record<string, unknown>): void;\n\n /**\n * Lazily log a warning message. Use this when the message values are\n * expensive to compute and should only be computed if the message is actually\n * logged.\n *\n * ```typescript\n * logger.warning(l => l`A warning message with ${expensiveValue()}.`);\n * ```\n *\n * @param callback A callback that returns the message template prefix.\n * @throws {TypeError} If no log record was made inside the callback.\n * @since 0.12.0\n */\n warning(callback: LogCallback): void;\n\n /**\n * Log an error.\n *\n * This overload is a shorthand for logging an {@link Error} instance as a\n * structured property.\n *\n * ```typescript\n * logger.error(new Error(\"Oops\"));\n * ```\n *\n * Note that this uses `{error.message}` as the default message template.\n * If you want to include the stack trace in text output, include `{error}`\n * in the message template instead.\n *\n * @param error The error to log.\n * @since 2.0.0\n */\n error(error: Error): void;\n\n /**\n * Log an error with additional properties.\n *\n * This overload is a shorthand for logging an {@link Error} instance as a\n * structured property while also adding extra properties.\n *\n * ```typescript\n * logger.error(new Error(\"Oops\"), { requestId });\n * ```\n *\n * If the properties are expensive to compute, you can pass a callback that\n * returns the properties:\n *\n * ```typescript\n * logger.error(\n * new Error(\"Oops\"),\n * () => ({ requestId: expensiveLookup() })\n * );\n * ```\n *\n * @param error The error to log.\n * @param properties Additional properties to log alongside the error.\n * @since 2.1.0\n */\n error(\n error: Error,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log an error with additional properties computed asynchronously.\n *\n * Use this when the properties require async operations to compute:\n *\n * ```typescript\n * await logger.error(\n * new Error(\"Oops\"),\n * async () => ({ requestId: await fetchRequestId() })\n * );\n * ```\n *\n * @param error The error to log.\n * @param properties An async callback that returns the properties.\n * @returns A promise that resolves when the log is written.\n * @since 2.1.0\n */\n error(\n error: Error,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n\n /**\n * Log an error message with an {@link Error}.\n *\n * ```typescript\n * logger.error(\"Failed to do something\", new Error(\"Oops\"));\n * ```\n *\n * @param message The message.\n * @param error The error to log.\n * @since 2.0.0\n */\n error(message: string, error: Error): void;\n\n /**\n * Log an error message. Use this as a template string prefix.\n *\n * ```typescript\n * logger.error `An error message with ${value}.`;\n * ```\n *\n * @param message The message template strings array.\n * @param values The message template values.\n */\n error(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n\n /**\n * Log an error message with properties.\n *\n * ```typescript\n * logger.warn('An error message with {value}.', { value });\n * ```\n *\n * If the properties are expensive to compute, you can pass a callback that\n * returns the properties:\n *\n * ```typescript\n * logger.error(\n * 'An error message with {value}.',\n * () => ({ value: expensiveComputation() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties The values to replace placeholders with. For lazy\n * evaluation, this can be a callback that returns the\n * properties.\n */\n error(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log an error message with properties computed asynchronously.\n *\n * Use this when the properties require async operations to compute:\n *\n * ```typescript\n * await logger.error(\n * 'An error message with {value}.',\n * async () => ({ value: await fetchValue() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties An async callback that returns the properties.\n * @returns A promise that resolves when the log is written.\n * @since 2.0.0\n */\n error(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n\n /**\n * Log an error values with no message. This is useful when you\n * want to log properties without a message, e.g., when you want to log\n * the context of a request or an operation.\n *\n * ```typescript\n * logger.error({ method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * Note that this is a shorthand for:\n *\n * ```typescript\n * logger.error('{*}', { method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * If the properties are expensive to compute, you cannot use this shorthand\n * and should use the following syntax instead:\n *\n * ```typescript\n * logger.error('{*}', () => ({\n * method: expensiveMethod(),\n * url: expensiveUrl(),\n * }));\n * ```\n *\n * @param properties The values to log. Note that this does not take\n * a callback.\n * @since 0.11.0\n */\n error(properties: Record<string, unknown>): void;\n\n /**\n * Lazily log an error message. Use this when the message values are\n * expensive to compute and should only be computed if the message is actually\n * logged.\n *\n * ```typescript\n * logger.error(l => l`An error message with ${expensiveValue()}.`);\n * ```\n *\n * @param callback A callback that returns the message template prefix.\n * @throws {TypeError} If no log record was made inside the callback.\n */\n error(callback: LogCallback): void;\n\n /**\n * Log a fatal error.\n *\n * This overload is a shorthand for logging an {@link Error} instance as a\n * structured property.\n *\n * ```typescript\n * logger.fatal(new Error(\"Oops\"));\n * ```\n *\n * Note that this uses `{error.message}` as the default message template.\n * If you want to include the stack trace in text output, include `{error}`\n * in the message template instead.\n *\n * @param error The error to log.\n * @since 2.0.0\n */\n fatal(error: Error): void;\n\n /**\n * Log a fatal error with additional properties.\n *\n * This overload is a shorthand for logging an {@link Error} instance as a\n * structured property while also adding extra properties.\n *\n * ```typescript\n * logger.fatal(new Error(\"Oops\"), { requestId });\n * ```\n *\n * @param error The error to log.\n * @param properties Additional properties to log alongside the error.\n * @since 2.1.0\n */\n fatal(\n error: Error,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log a fatal error with additional properties computed asynchronously.\n *\n * @param error The error to log.\n * @param properties An async callback that returns the properties.\n * @returns A promise that resolves when the log is written.\n * @since 2.1.0\n */\n fatal(\n error: Error,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n\n /**\n * Log a fatal error message with an {@link Error}.\n *\n * ```typescript\n * logger.fatal(\"Failed to do something\", new Error(\"Oops\"));\n * ```\n *\n * @param message The message.\n * @param error The error to log.\n * @since 2.0.0\n */\n fatal(message: string, error: Error): void;\n\n /**\n * Log a fatal error message. Use this as a template string prefix.\n *\n * ```typescript\n * logger.fatal `A fatal error message with ${value}.`;\n * ```\n *\n * @param message The message template strings array.\n * @param values The message template values.\n */\n fatal(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n\n /**\n * Log a fatal error message with properties.\n *\n * ```typescript\n * logger.warn('A fatal error message with {value}.', { value });\n * ```\n *\n * If the properties are expensive to compute, you can pass a callback that\n * returns the properties:\n *\n * ```typescript\n * logger.fatal(\n * 'A fatal error message with {value}.',\n * () => ({ value: expensiveComputation() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties The values to replace placeholders with. For lazy\n * evaluation, this can be a callback that returns the\n * properties.\n */\n fatal(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log a fatal error message with properties computed asynchronously.\n *\n * Use this when the properties require async operations to compute:\n *\n * ```typescript\n * await logger.fatal(\n * 'A fatal error message with {value}.',\n * async () => ({ value: await fetchValue() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties An async callback that returns the properties.\n * @returns A promise that resolves when the log is written.\n * @since 2.0.0\n */\n fatal(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n\n /**\n * Log a fatal error values with no message. This is useful when you\n * want to log properties without a message, e.g., when you want to log\n * the context of a request or an operation.\n *\n * ```typescript\n * logger.fatal({ method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * Note that this is a shorthand for:\n *\n * ```typescript\n * logger.fatal('{*}', { method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * If the properties are expensive to compute, you cannot use this shorthand\n * and should use the following syntax instead:\n *\n * ```typescript\n * logger.fatal('{*}', () => ({\n * method: expensiveMethod(),\n * url: expensiveUrl(),\n * }));\n * ```\n *\n * @param properties The values to log. Note that this does not take\n * a callback.\n * @since 0.11.0\n */\n fatal(properties: Record<string, unknown>): void;\n\n /**\n * Lazily log a fatal error message. Use this when the message values are\n * expensive to compute and should only be computed if the message is actually\n * logged.\n *\n * ```typescript\n * logger.fatal(l => l`A fatal error message with ${expensiveValue()}.`);\n * ```\n *\n * @param callback A callback that returns the message template prefix.\n * @throws {TypeError} If no log record was made inside the callback.\n */\n fatal(callback: LogCallback): void;\n\n /**\n * Emits a log record with custom fields while using this logger's\n * category.\n *\n * This is a low-level API for integration scenarios where you need full\n * control over the log record, particularly for preserving timestamps\n * from external systems.\n *\n * ```typescript\n * const logger = getLogger([\"my-app\", \"integration\"]);\n *\n * // Emit a log with a custom timestamp\n * logger.emit({\n * timestamp: kafkaLog.originalTimestamp,\n * level: \"info\",\n * message: [kafkaLog.message],\n * rawMessage: kafkaLog.message,\n * properties: {\n * source: \"kafka\",\n * partition: kafkaLog.partition,\n * offset: kafkaLog.offset,\n * },\n * });\n * ```\n *\n * @param record Log record without category field (category comes from\n * the logger instance)\n * @since 1.1.0\n */\n emit(record: Omit<LogRecord, \"category\">): void;\n\n /**\n * Check if a message of the given severity level would be processed by\n * this logger.\n *\n * This is useful for conditionally executing expensive computations\n * before logging, particularly for async operations where lazy\n * evaluation callbacks cannot be used:\n *\n * ```typescript\n * if (logger.isEnabledFor(\"debug\")) {\n * const result = await expensiveAsync();\n * logger.debug(\"Result: {result}\", { result });\n * }\n * ```\n *\n * @param level The log level to check.\n * @returns `true` if a message of the given level would be logged,\n * `false` otherwise.\n * @since 2.0.0\n */\n isEnabledFor(level: LogLevel): boolean;\n}\n\n/**\n * A logging callback function. It is used to defer the computation of a\n * message template until it is actually logged.\n * @param prefix The message template prefix.\n * @returns The rendered message array.\n */\nexport type LogCallback = (prefix: LogTemplatePrefix) => unknown[];\n\n/**\n * A logging template prefix function. It is used to log a message in\n * a {@link LogCallback} function.\n * @param message The message template strings array.\n * @param values The message template values.\n * @returns The rendered message array.\n */\nexport type LogTemplatePrefix = (\n message: TemplateStringsArray,\n ...values: unknown[]\n) => unknown[];\n\n/**\n * A function type for logging methods in the {@link Logger} interface.\n * @since 1.0.0\n */\nexport interface LogMethod {\n /**\n * Log a message with the given level using a template string.\n * @param message The message template strings array.\n * @param values The message template values.\n */\n (\n message: TemplateStringsArray,\n ...values: readonly unknown[]\n ): void;\n\n /**\n * Log a message with the given level with properties.\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties The values to replace placeholders with. For lazy\n * evaluation, this can be a callback that returns the\n * properties.\n */\n (\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log a message with the given level with properties computed asynchronously.\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties An async callback that returns the properties.\n * @returns A promise that resolves when the log is written.\n * @since 2.0.0\n */\n (\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n\n /**\n * Log a message with the given level with no message.\n * @param properties The values to log. Note that this does not take\n * a callback.\n */\n (properties: Record<string, unknown>): void;\n\n /**\n * Lazily log a message with the given level.\n * @param callback A callback that returns the message template prefix.\n * @throws {TypeError} If no log record was made inside the callback.\n */\n (callback: LogCallback): void;\n}\n\n/**\n * Get a logger with the given category.\n *\n * ```typescript\n * const logger = getLogger([\"my-app\"]);\n * ```\n *\n * @param category The category of the logger. It can be a string or an array\n * of strings. If it is a string, it is equivalent to an array\n * with a single element.\n * @returns The logger.\n */\nexport function getLogger(category: string | readonly string[] = []): Logger {\n return LoggerImpl.getLogger(category);\n}\n\n/**\n * The symbol for the global root logger.\n */\nconst globalRootLoggerSymbol = Symbol.for(\"logtape.rootLogger\");\n\nfunction isMetaLoggerCategory(category: readonly string[]): boolean {\n return category.length >= 2 &&\n category[0] === \"logtape\" &&\n category[1] === \"meta\";\n}\n\n/**\n * The global root logger registry.\n */\ninterface GlobalRootLoggerRegistry {\n [globalRootLoggerSymbol]?: LoggerImpl;\n}\n\n/**\n * A logger implementation. Do not use this directly; use {@link getLogger}\n * instead. This class is exported for testing purposes.\n */\nexport class LoggerImpl implements Logger {\n readonly parent: LoggerImpl | null;\n readonly children: Record<string, LoggerImpl | WeakRef<LoggerImpl>>;\n readonly category: readonly string[];\n readonly sinks: Sink[];\n readonly filters: Filter[];\n contextLocalStorage?: ContextLocalStorage<Record<string, unknown>>;\n #parentSinks: \"inherit\" | \"override\" = \"inherit\";\n #lowestLevel: LogLevel | null = \"trace\";\n #sinkPlanCache: Partial<Record<LogLevel, SinkDispatchPlan>> = {};\n\n static getLogger(category: string | readonly string[] = []): LoggerImpl {\n let rootLogger: LoggerImpl | null = globalRootLoggerSymbol in globalThis\n ? ((globalThis as GlobalRootLoggerRegistry)[globalRootLoggerSymbol] ??\n null)\n : null;\n if (rootLogger == null) {\n rootLogger = new LoggerImpl(null, []);\n (globalThis as GlobalRootLoggerRegistry)[globalRootLoggerSymbol] =\n rootLogger;\n }\n if (typeof category === \"string\") return rootLogger.getChild(category);\n if (category.length === 0) return rootLogger;\n return rootLogger.getChild(category as readonly [string, ...string[]]);\n }\n\n private static getNearestExistingLogger(\n category: readonly string[],\n ): LoggerImpl {\n let logger = LoggerImpl.getLogger();\n for (const name of category) {\n const childRef = logger.children[name];\n const child = childRef instanceof LoggerImpl\n ? childRef\n : childRef?.deref();\n if (child == null) break;\n logger = child;\n }\n return logger;\n }\n\n private constructor(parent: LoggerImpl | null, category: readonly string[]) {\n this.parent = parent;\n this.children = {};\n this.category = category;\n this.sinks = [];\n this.filters = [];\n }\n\n get parentSinks(): \"inherit\" | \"override\" {\n return this.#parentSinks;\n }\n\n set parentSinks(value: \"inherit\" | \"override\") {\n if (this.#parentSinks === value) return;\n this.#parentSinks = value;\n }\n\n get lowestLevel(): LogLevel | null {\n return this.#lowestLevel;\n }\n\n set lowestLevel(value: LogLevel | null) {\n if (this.#lowestLevel === value) return;\n this.#lowestLevel = value;\n }\n\n getChild(\n subcategory:\n | string\n | readonly [string]\n | readonly [string, ...(readonly string[])],\n ): LoggerImpl {\n const name = typeof subcategory === \"string\" ? subcategory : subcategory[0];\n const childRef = this.children[name];\n let child: LoggerImpl | undefined = childRef instanceof LoggerImpl\n ? childRef\n : childRef?.deref();\n if (child == null) {\n child = new LoggerImpl(this, [...this.category, name]);\n this.children[name] = \"WeakRef\" in globalThis\n ? new WeakRef(child)\n : child;\n }\n if (typeof subcategory === \"string\" || subcategory.length === 1) {\n return child;\n }\n return child.getChild(\n subcategory.slice(1) as [string, ...(readonly string[])],\n );\n }\n\n /**\n * Reset the logger. This removes all sinks and filters from the logger.\n */\n reset(): void {\n while (this.sinks.length > 0) this.sinks.shift();\n this.parentSinks = \"inherit\";\n while (this.filters.length > 0) this.filters.shift();\n this.lowestLevel = \"trace\";\n }\n\n /**\n * Reset the logger and all its descendants. This removes all sinks and\n * filters from the logger and all its descendants.\n */\n resetDescendants(): void {\n for (const child of Object.values(this.children)) {\n const logger = child instanceof LoggerImpl ? child : child.deref();\n if (logger != null) logger.resetDescendants();\n }\n this.reset();\n }\n\n with(properties: Record<string, unknown>): Logger {\n return new LoggerCtx(this, { ...properties });\n }\n\n filter(record: LogRecord): boolean {\n for (const filter of this.filters) {\n if (!filter(record)) return false;\n }\n if (this.filters.length < 1) return this.parent?.filter(record) ?? true;\n return true;\n }\n\n *getSinks(level: LogLevel): Iterable<Sink> {\n const plan = this.getSinkDispatchPlan(level);\n switch (plan.kind) {\n case \"none\":\n return;\n case \"one\":\n yield plan.sink;\n return;\n case \"many\":\n yield* plan.sinks;\n return;\n }\n }\n\n private getSinkDispatchPlan(level: LogLevel): SinkDispatchPlan {\n const cached = this.#sinkPlanCache[level];\n if (cached != null && this.isSinkDispatchPlanFresh(level, cached)) {\n return cached;\n }\n\n const parentPlan = this.parent != null && this.parentSinks === \"inherit\"\n ? this.parent.getSinkDispatchPlan(level)\n : undefined;\n const plan = this.createSinkDispatchPlan(level, parentPlan);\n this.#sinkPlanCache[level] = plan;\n return plan;\n }\n\n private isSinkDispatchPlanFresh(\n level: LogLevel,\n plan: SinkDispatchPlan,\n ): boolean {\n if (\n plan.lowestLevel !== this.lowestLevel ||\n plan.parentSinks !== this.parentSinks ||\n plan.localSinks.length !== this.sinks.length\n ) {\n return false;\n }\n for (let i = 0; i < plan.localSinks.length; i++) {\n if (plan.localSinks[i] !== this.sinks[i]) return false;\n }\n\n const parentPlan = this.parent != null && this.parentSinks === \"inherit\"\n ? this.parent.getSinkDispatchPlan(level)\n : undefined;\n return plan.parentPlan === parentPlan;\n }\n\n private createSinkDispatchPlan(\n level: LogLevel,\n parentPlan: SinkDispatchPlan | undefined,\n ): SinkDispatchPlan {\n const state: SinkDispatchPlanState = {\n // Keep a plain array for compatibility with cross-runtime assertions, but\n // snapshot it here so direct index/length mutations invalidate the cache.\n localSinks: [...this.sinks],\n parentSinks: this.parentSinks,\n lowestLevel: this.lowestLevel,\n parentPlan,\n };\n if (state.lowestLevel === null) return { ...state, kind: \"none\" };\n if (compareLogLevel(level, state.lowestLevel) < 0) {\n return { ...state, kind: \"none\" };\n }\n\n let firstSink: Sink | undefined;\n let sinks: Sink[] | undefined;\n const appendSink = (sink: Sink) => {\n if (sinks != null) {\n sinks.push(sink);\n } else if (firstSink == null) {\n firstSink = sink;\n } else {\n sinks = [firstSink, sink];\n }\n };\n\n if (parentPlan != null) {\n if (parentPlan.kind === \"one\") {\n firstSink = parentPlan.sink;\n } else if (parentPlan.kind === \"many\") {\n // Multiple-sink plans are snapshots. Copy the parent snapshot so local\n // sinks can be appended without mutating the parent's cached plan.\n sinks = [...parentPlan.sinks];\n }\n }\n for (const sink of state.localSinks) appendSink(sink);\n\n if (sinks != null) return { ...state, kind: \"many\", sinks };\n if (firstSink != null) return { ...state, kind: \"one\", sink: firstSink };\n return { ...state, kind: \"none\" };\n }\n\n isEnabledFor(level: LogLevel): boolean {\n const categoryPrefix = isMetaLoggerCategory(this.category)\n ? []\n : getCategoryPrefix();\n const dispatcher = categoryPrefix.length > 0\n ? LoggerImpl.getNearestExistingLogger([\n ...categoryPrefix,\n ...this.category,\n ])\n : this;\n const scopedConfig = getCurrentScopedConfig(\n LoggerImpl.getLogger().contextLocalStorage,\n );\n if (scopedConfig != null) {\n return scopedConfigHasSink(\n scopedConfig,\n categoryPrefix.length > 0\n ? [...categoryPrefix, ...this.category]\n : this.category,\n level,\n );\n }\n return dispatcher.isEnabledForResolved(level);\n }\n\n private isEnabledForResolved(level: LogLevel): boolean {\n return this.getSinkDispatchPlan(level).kind !== \"none\";\n }\n\n emit(record: Omit<LogRecord, \"category\">): void;\n emit(record: LogRecord, bypassSinks?: Set<Sink>): void;\n emit(\n record: Omit<LogRecord, \"category\"> | LogRecord,\n bypassSinks?: Set<Sink>,\n ): void {\n const hasCategory = \"category\" in record;\n const baseCategory = hasCategory\n ? (record as LogRecord).category\n : this.category;\n const categoryPrefix = isMetaLoggerCategory(baseCategory)\n ? []\n : getCategoryPrefix();\n const fullCategory = categoryPrefix.length > 0\n ? [...categoryPrefix, ...baseCategory]\n : baseCategory;\n if (\n categoryPrefix.length < 1 &&\n Object.prototype.hasOwnProperty.call(record, \"category\")\n ) {\n // The record already carries the final category in the common path, so\n // avoid cloning descriptors on every enabled log call.\n this.emitResolved(record as LogRecord, bypassSinks);\n return;\n }\n\n // Create the full record by copying property descriptors from the original\n // record, which preserves getters without invoking them (unlike spread).\n const descriptors = Object.getOwnPropertyDescriptors(record) as\n & PropertyDescriptorMap\n & { category?: PropertyDescriptor };\n descriptors.category = {\n value: fullCategory,\n enumerable: true,\n configurable: true,\n };\n const fullRecord = Object.defineProperties({}, descriptors) as LogRecord;\n const dispatcher = categoryPrefix.length > 0\n ? LoggerImpl.getNearestExistingLogger(fullCategory)\n : this;\n dispatcher.emitResolved(fullRecord, bypassSinks);\n }\n\n private emitResolved(record: LogRecord, bypassSinks?: Set<Sink>): void {\n const scopedConfig = getCurrentScopedConfig(\n LoggerImpl.getLogger().contextLocalStorage,\n );\n if (scopedConfig != null) {\n let snapshot: LogRecord | undefined;\n let snapshotFailed: boolean = false;\n emitWithScopedConfig(\n scopedConfig,\n record,\n bypassSinks,\n (sink, activeBypassSinks) => {\n try {\n if (shouldSnapshotForSink(sink)) {\n try {\n snapshot ??= snapshotLogRecordProperties(record);\n } catch {\n snapshotFailed = true;\n snapshot = record;\n }\n }\n sink(snapshot ?? record);\n } catch (error) {\n const bypassSinks2 = new Set(activeBypassSinks);\n bypassSinks2.add(sink);\n metaLogger.log(\n \"fatal\",\n \"Failed to emit a log record to sink {sink}: {error}\",\n { sink, error, record },\n bypassSinks2,\n );\n }\n if (snapshotFailed) snapshot = record;\n },\n );\n return;\n }\n\n if (\n this.lowestLevel === null ||\n compareLogLevel(record.level, this.lowestLevel) < 0 ||\n !this.filter(record)\n ) {\n return;\n }\n const plan = this.getSinkDispatchPlan(record.level);\n if (plan.kind === \"none\") return;\n\n let snapshot: LogRecord | undefined;\n let snapshotFailed: boolean = false;\n if (plan.kind === \"one\") {\n const sink = plan.sink;\n if (bypassSinks?.has(sink)) return;\n try {\n if (shouldSnapshotForSink(sink)) {\n try {\n // Avoid a sinks array for the common one-sink path, but keep lazy\n // properties snapshotted before a sink can buffer the record.\n snapshot = snapshotLogRecordProperties(record);\n } catch {\n snapshotFailed = true;\n snapshot = record;\n }\n }\n sink(snapshot ?? record);\n } catch (error) {\n const bypassSinks2 = new Set(bypassSinks);\n bypassSinks2.add(sink);\n metaLogger.log(\n \"fatal\",\n \"Failed to emit a log record to sink {sink}: {error}\",\n { sink, error, record },\n bypassSinks2,\n );\n }\n return;\n }\n\n for (const sink of plan.sinks) {\n if (bypassSinks?.has(sink)) continue;\n try {\n if (\n snapshot == null && !snapshotFailed && shouldSnapshotForSink(sink)\n ) {\n try {\n // Build the snapshot only once and only for a sink that will\n // actually requires it and will receive the record.\n snapshot = snapshotLogRecordProperties(record);\n } catch {\n snapshotFailed = true;\n snapshot = record;\n }\n }\n sink(snapshot ?? record);\n } catch (error) {\n const bypassSinks2 = new Set(bypassSinks);\n bypassSinks2.add(sink);\n metaLogger.log(\n \"fatal\",\n \"Failed to emit a log record to sink {sink}: {error}\",\n { sink, error, record },\n bypassSinks2,\n );\n }\n }\n }\n\n log(\n level: LogLevel,\n rawMessage: string,\n properties: Record<string, unknown> | (() => Record<string, unknown>),\n bypassSinks?: Set<Sink>,\n ): void {\n const implicitContext = getImplicitContextIfAny();\n if (\n typeof properties !== \"function\" &&\n implicitContext == null &&\n !rawMessage.includes(\"{\") &&\n !hasEnumerableProperties(properties)\n ) {\n const record: LogRecord = {\n category: this.category,\n level,\n message: [rawMessage],\n rawMessage,\n timestamp: Date.now(),\n properties: {},\n };\n resolvedStringLogRecords.add(record);\n this.emit(record, bypassSinks);\n return;\n }\n\n let cachedProps: Record<string, unknown> | undefined = undefined;\n let cachedMessage: readonly unknown[] | undefined = undefined;\n const record: LogRecord = typeof properties === \"function\"\n ? {\n category: this.category,\n level,\n timestamp: Date.now(),\n get message() {\n if (cachedMessage == null) {\n cachedMessage = parseMessageTemplate(rawMessage, this.properties);\n }\n return cachedMessage;\n },\n rawMessage,\n get properties() {\n if (cachedProps == null) {\n cachedProps = resolveProperties({\n ...(implicitContext ?? {}),\n ...properties(),\n });\n }\n return cachedProps;\n },\n }\n : {\n category: this.category,\n level,\n timestamp: Date.now(),\n get message() {\n if (cachedMessage == null) {\n cachedMessage = parseMessageTemplate(rawMessage, this.properties);\n }\n return cachedMessage;\n },\n rawMessage,\n get properties() {\n if (cachedProps == null) {\n cachedProps = resolveProperties({\n ...(implicitContext ?? {}),\n ...properties,\n });\n }\n return cachedProps;\n },\n };\n internalStringLogRecords.add(record);\n this.emit(record, bypassSinks);\n }\n\n logLazily(\n level: LogLevel,\n callback: LogCallback,\n properties: Record<string, unknown> = {},\n ): void {\n const implicitContext = getImplicitContextIfAny();\n let rawMessage: TemplateStringsArray | undefined = undefined;\n let msg: unknown[] | undefined = undefined;\n function realizeMessage(): [unknown[], TemplateStringsArray] {\n if (msg == null || rawMessage == null) {\n msg = callback((tpl, ...values) => {\n rawMessage = tpl;\n return renderMessage(tpl, values);\n });\n if (rawMessage == null) throw new TypeError(\"No log record was made.\");\n }\n return [msg, rawMessage];\n }\n this.emit({\n category: this.category,\n level,\n get message() {\n return realizeMessage()[0];\n },\n get rawMessage() {\n return realizeMessage()[1];\n },\n timestamp: Date.now(),\n properties: { ...(implicitContext ?? {}), ...properties },\n });\n }\n\n logTemplate(\n level: LogLevel,\n messageTemplate: TemplateStringsArray,\n values: unknown[],\n properties: Record<string, unknown> = {},\n ): void {\n const implicitContext = getImplicitContextIfAny();\n this.emit({\n category: this.category,\n level,\n message: renderMessage(messageTemplate, values),\n rawMessage: messageTemplate,\n timestamp: Date.now(),\n properties: { ...(implicitContext ?? {}), ...properties },\n });\n }\n\n trace(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n trace(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n trace(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n trace(properties: Record<string, unknown>): void;\n trace(callback: LogCallback): void;\n trace(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void | Promise<void> {\n if (typeof message === \"string\") {\n return logStringMessage(this, \"trace\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"trace\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"trace\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"trace\", message as TemplateStringsArray, values);\n }\n }\n\n debug(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n debug(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n debug(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n debug(properties: Record<string, unknown>): void;\n debug(callback: LogCallback): void;\n debug(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void | Promise<void> {\n if (typeof message === \"string\") {\n return logStringMessage(this, \"debug\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"debug\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"debug\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"debug\", message as TemplateStringsArray, values);\n }\n }\n\n info(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n info(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n info(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n info(properties: Record<string, unknown>): void;\n info(callback: LogCallback): void;\n info(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void | Promise<void> {\n if (typeof message === \"string\") {\n return logStringMessage(this, \"info\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"info\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"info\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"info\", message as TemplateStringsArray, values);\n }\n }\n\n private logError(\n level: \"warning\" | \"error\" | \"fatal\",\n error: Error,\n props?: unknown,\n ): void | Promise<void> {\n if (typeof props !== \"function\") {\n this.log(level, \"{error.message}\", {\n ...(props as Record<string, unknown>),\n error,\n });\n return;\n }\n\n if (!this.isEnabledFor(level)) return Promise.resolve();\n\n const result = (props as () =>\n | Record<string, unknown>\n | Promise<Record<string, unknown>>)();\n\n if (result instanceof Promise) {\n return result.then((resolved) => {\n this.log(level, \"{error.message}\", { ...resolved, error });\n });\n }\n\n this.log(level, \"{error.message}\", { ...result, error });\n }\n\n warn(error: Error): void;\n warn(\n error: Error,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n warn(\n error: Error,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n warn(message: string, error: Error): void;\n warn(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n warn(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n warn(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n warn(properties: Record<string, unknown>): void;\n warn(callback: LogCallback): void;\n warn(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error,\n ...values: unknown[]\n ): void | Promise<void> {\n if (message instanceof Error) {\n return this.logError(\"warning\", message, values[0]);\n } else if (typeof message === \"string\" && values[0] instanceof Error) {\n this.log(\"warning\", message, { error: values[0] });\n } else if (typeof message === \"string\") {\n return logStringMessage(this, \"warning\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"warning\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"warning\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"warning\", message as TemplateStringsArray, values);\n }\n }\n\n warning(error: Error): void;\n warning(\n error: Error,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n warning(\n error: Error,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n warning(message: string, error: Error): void;\n warning(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n warning(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n warning(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n warning(properties: Record<string, unknown>): void;\n warning(callback: LogCallback): void;\n warning(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error,\n ...values: unknown[]\n ): void | Promise<void> {\n if (message instanceof Error) {\n return this.logError(\"warning\", message, values[0]);\n } else if (typeof message === \"string\" && values[0] instanceof Error) {\n this.log(\"warning\", message, { error: values[0] });\n } else if (typeof message === \"string\") {\n return logStringMessage(this, \"warning\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"warning\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"warning\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"warning\", message as TemplateStringsArray, values);\n }\n }\n\n error(error: Error): void;\n error(\n error: Error,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n error(\n error: Error,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n error(message: string, error: Error): void;\n error(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n error(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n error(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n error(properties: Record<string, unknown>): void;\n error(callback: LogCallback): void;\n error(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error,\n ...values: unknown[]\n ): void | Promise<void> {\n if (message instanceof Error) {\n return this.logError(\"error\", message, values[0]);\n } else if (typeof message === \"string\" && values[0] instanceof Error) {\n this.log(\"error\", message, { error: values[0] });\n } else if (typeof message === \"string\") {\n return logStringMessage(this, \"error\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"error\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"error\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"error\", message as TemplateStringsArray, values);\n }\n }\n\n fatal(error: Error): void;\n fatal(\n error: Error,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n fatal(\n error: Error,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n fatal(message: string, error: Error): void;\n fatal(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n fatal(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n fatal(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n fatal(properties: Record<string, unknown>): void;\n fatal(callback: LogCallback): void;\n fatal(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error,\n ...values: unknown[]\n ): void | Promise<void> {\n if (message instanceof Error) {\n return this.logError(\"fatal\", message, values[0]);\n } else if (typeof message === \"string\" && values[0] instanceof Error) {\n this.log(\"fatal\", message, { error: values[0] });\n } else if (typeof message === \"string\") {\n return logStringMessage(this, \"fatal\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"fatal\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"fatal\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"fatal\", message as TemplateStringsArray, values);\n }\n }\n}\n\n/**\n * A logger implementation with contextual properties. Do not use this\n * directly; use {@link Logger.with} instead. This class is exported\n * for testing purposes.\n */\nexport class LoggerCtx implements Logger {\n logger: LoggerImpl;\n properties: Record<string, unknown>;\n\n constructor(logger: LoggerImpl, properties: Record<string, unknown>) {\n this.logger = logger;\n this.properties = properties;\n }\n\n get category(): readonly string[] {\n return this.logger.category;\n }\n\n get parent(): Logger | null {\n return this.logger.parent;\n }\n\n getChild(\n subcategory: string | readonly [string] | readonly [string, ...string[]],\n ): Logger {\n return this.logger.getChild(subcategory).with(this.properties);\n }\n\n with(properties: Record<string, unknown>): Logger {\n return new LoggerCtx(this.logger, { ...this.properties, ...properties });\n }\n\n log(\n level: LogLevel,\n message: string,\n properties: Record<string, unknown> | (() => Record<string, unknown>),\n bypassSinks?: Set<Sink>,\n ): void {\n const contextProps = this.properties;\n this.logger.log(\n level,\n message,\n typeof properties === \"function\"\n ? () =>\n resolveProperties({\n ...contextProps,\n ...properties(),\n })\n : () => resolveProperties({ ...contextProps, ...properties }),\n bypassSinks,\n );\n }\n\n logLazily(level: LogLevel, callback: LogCallback): void {\n this.logger.logLazily(level, callback, resolveProperties(this.properties));\n }\n\n logTemplate(\n level: LogLevel,\n messageTemplate: TemplateStringsArray,\n values: unknown[],\n ): void {\n this.logger.logTemplate(\n level,\n messageTemplate,\n values,\n resolveProperties(this.properties),\n );\n }\n\n emit(record: Omit<LogRecord, \"category\">): void {\n const recordWithContext = {\n ...record,\n properties: resolveProperties({\n ...this.properties,\n ...record.properties,\n }),\n };\n this.logger.emit(recordWithContext);\n }\n\n isEnabledFor(level: LogLevel): boolean {\n return this.logger.isEnabledFor(level);\n }\n\n trace(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n trace(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n trace(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n trace(properties: Record<string, unknown>): void;\n trace(callback: LogCallback): void;\n trace(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void | Promise<void> {\n if (typeof message === \"string\") {\n return logStringMessage(this, \"trace\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"trace\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"trace\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"trace\", message as TemplateStringsArray, values);\n }\n }\n\n debug(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n debug(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n debug(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n debug(properties: Record<string, unknown>): void;\n debug(callback: LogCallback): void;\n debug(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void | Promise<void> {\n if (typeof message === \"string\") {\n return logStringMessage(this, \"debug\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"debug\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"debug\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"debug\", message as TemplateStringsArray, values);\n }\n }\n\n info(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n info(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n info(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n info(properties: Record<string, unknown>): void;\n info(callback: LogCallback): void;\n info(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void | Promise<void> {\n if (typeof message === \"string\") {\n return logStringMessage(this, \"info\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"info\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"info\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"info\", message as TemplateStringsArray, values);\n }\n }\n\n private logError(\n level: \"warning\" | \"error\" | \"fatal\",\n error: Error,\n props?: unknown,\n ): void | Promise<void> {\n if (typeof props !== \"function\") {\n this.log(level, \"{error.message}\", {\n ...(props as Record<string, unknown>),\n error,\n });\n return;\n }\n\n if (!this.isEnabledFor(level)) return Promise.resolve();\n\n const result = (props as () =>\n | Record<string, unknown>\n | Promise<Record<string, unknown>>)();\n\n if (result instanceof Promise) {\n return result.then((resolved) => {\n this.log(level, \"{error.message}\", { ...resolved, error });\n });\n }\n\n this.log(level, \"{error.message}\", { ...result, error });\n }\n\n warn(error: Error): void;\n warn(\n error: Error,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n warn(\n error: Error,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n warn(message: string, error: Error): void;\n warn(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n warn(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n warn(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n warn(properties: Record<string, unknown>): void;\n warn(callback: LogCallback): void;\n warn(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error,\n ...values: unknown[]\n ): void | Promise<void> {\n if (message instanceof Error) {\n return this.logError(\"warning\", message, values[0]);\n } else if (typeof message === \"string\" && values[0] instanceof Error) {\n this.log(\"warning\", message, { error: values[0] });\n } else if (typeof message === \"string\") {\n return logStringMessage(this, \"warning\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"warning\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"warning\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"warning\", message as TemplateStringsArray, values);\n }\n }\n\n warning(error: Error): void;\n warning(\n error: Error,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n warning(\n error: Error,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n warning(message: string, error: Error): void;\n warning(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n warning(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n warning(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n warning(properties: Record<string, unknown>): void;\n warning(callback: LogCallback): void;\n warning(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error,\n ...values: unknown[]\n ): void | Promise<void> {\n if (message instanceof Error) {\n return this.logError(\"warning\", message, values[0]);\n } else if (typeof message === \"string\" && values[0] instanceof Error) {\n this.log(\"warning\", message, { error: values[0] });\n } else if (typeof message === \"string\") {\n return logStringMessage(this, \"warning\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"warning\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"warning\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"warning\", message as TemplateStringsArray, values);\n }\n }\n\n error(error: Error): void;\n error(\n error: Error,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n error(\n error: Error,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n error(message: string, error: Error): void;\n error(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n error(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n error(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n error(properties: Record<string, unknown>): void;\n error(callback: LogCallback): void;\n error(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error,\n ...values: unknown[]\n ): void | Promise<void> {\n if (message instanceof Error) {\n return this.logError(\"error\", message, values[0]);\n } else if (typeof message === \"string\" && values[0] instanceof Error) {\n this.log(\"error\", message, { error: values[0] });\n } else if (typeof message === \"string\") {\n return logStringMessage(this, \"error\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"error\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"error\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"error\", message as TemplateStringsArray, values);\n }\n }\n\n fatal(error: Error): void;\n fatal(\n error: Error,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n fatal(\n error: Error,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n fatal(message: string, error: Error): void;\n fatal(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n fatal(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n fatal(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n fatal(properties: Record<string, unknown>): void;\n fatal(callback: LogCallback): void;\n fatal(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error,\n ...values: unknown[]\n ): void | Promise<void> {\n if (message instanceof Error) {\n return this.logError(\"fatal\", message, values[0]);\n } else if (typeof message === \"string\" && values[0] instanceof Error) {\n this.log(\"fatal\", message, { error: values[0] });\n } else if (typeof message === \"string\") {\n return logStringMessage(this, \"fatal\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"fatal\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"fatal\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"fatal\", message as TemplateStringsArray, values);\n }\n }\n}\n\n/**\n * The meta logger. It is a logger with the category `[\"logtape\", \"meta\"]`.\n */\nconst metaLogger = LoggerImpl.getLogger([\"logtape\", \"meta\"]);\n\n/**\n * Check if a property access key contains nested access patterns.\n * @param key The property key to check.\n * @returns True if the key contains nested access patterns.\n */\nfunction isNestedAccess(key: string): boolean {\n return key.includes(\".\") || key.includes(\"[\") || key.includes(\"?.\");\n}\n\n/**\n * Safely access an own property from an object, blocking prototype pollution.\n *\n * @param obj The object to access the property from.\n * @param key The property key to access.\n * @returns The property value or undefined if not accessible.\n */\nfunction getOwnProperty(obj: unknown, key: string): unknown {\n // Block dangerous prototype keys\n if (key === \"__proto__\" || key === \"prototype\" || key === \"constructor\") {\n return undefined;\n }\n\n if ((typeof obj === \"object\" || typeof obj === \"function\") && obj !== null) {\n return Object.prototype.hasOwnProperty.call(obj, key)\n ? (obj as Record<string, unknown>)[key]\n : undefined;\n }\n\n return undefined;\n}\n\n/**\n * Result of parsing a single segment from a property path.\n */\ninterface ParseSegmentResult {\n segment: string | number;\n nextIndex: number;\n}\n\n/**\n * Parse the next segment from a property path string.\n *\n * @param path The full property path string.\n * @param fromIndex The index to start parsing from.\n * @returns The parsed segment and next index, or null if parsing fails.\n */\nfunction parseNextSegment(\n path: string,\n fromIndex: number,\n): ParseSegmentResult | null {\n const len = path.length;\n let i = fromIndex;\n\n if (i >= len) return null;\n\n let segment: string | number;\n\n if (path[i] === \"[\") {\n // Bracket notation: [0] or [\"prop\"]\n i++;\n if (i >= len) return null;\n\n if (path[i] === '\"' || path[i] === \"'\") {\n // Quoted property name: [\"prop-name\"]\n const quote = path[i];\n i++;\n // Build segment with proper escape handling\n let segmentStr = \"\";\n while (i < len && path[i] !== quote) {\n if (path[i] === \"\\\\\") {\n i++; // Skip backslash\n if (i < len) {\n // Handle escape sequences according to JavaScript spec\n const escapeChar = path[i];\n switch (escapeChar) {\n case \"n\":\n segmentStr += \"\\n\";\n break;\n case \"t\":\n segmentStr += \"\\t\";\n break;\n case \"r\":\n segmentStr += \"\\r\";\n break;\n case \"b\":\n segmentStr += \"\\b\";\n break;\n case \"f\":\n segmentStr += \"\\f\";\n break;\n case \"v\":\n segmentStr += \"\\v\";\n break;\n case \"0\":\n segmentStr += \"\\0\";\n break;\n case \"\\\\\":\n segmentStr += \"\\\\\";\n break;\n case '\"':\n segmentStr += '\"';\n break;\n case \"'\":\n segmentStr += \"'\";\n break;\n case \"u\":\n // Unicode escape: \\uXXXX\n if (i + 4 < len) {\n const hex = path.slice(i + 1, i + 5);\n const codePoint = Number.parseInt(hex, 16);\n if (!Number.isNaN(codePoint)) {\n segmentStr += String.fromCharCode(codePoint);\n i += 4; // Skip the 4 hex digits\n } else {\n // Invalid unicode escape, keep as-is\n segmentStr += escapeChar;\n }\n } else {\n // Not enough characters for unicode escape\n segmentStr += escapeChar;\n }\n break;\n default:\n // For any other character after \\, just add it as-is\n segmentStr += escapeChar;\n }\n i++;\n }\n } else {\n segmentStr += path[i];\n i++;\n }\n }\n if (i >= len) return null;\n segment = segmentStr;\n i++; // Skip closing quote\n } else {\n // Array index: [0]\n const startIndex = i;\n while (\n i < len && path[i] !== \"]\" && path[i] !== \"'\" && path[i] !== '\"'\n ) {\n i++;\n }\n if (i >= len) return null;\n const indexStr = path.slice(startIndex, i);\n // Empty bracket is invalid\n if (indexStr.length === 0) return null;\n const indexNum = Number(indexStr);\n segment = Number.isNaN(indexNum) ? indexStr : indexNum;\n }\n\n // Skip closing bracket\n while (i < len && path[i] !== \"]\") i++;\n if (i < len) i++;\n } else {\n // Dot notation: prop\n const startIndex = i;\n while (\n i < len && path[i] !== \".\" && path[i] !== \"[\" && path[i] !== \"?\" &&\n path[i] !== \"]\"\n ) {\n i++;\n }\n segment = path.slice(startIndex, i);\n // Empty segment is invalid (e.g., leading dot, double dot, trailing dot)\n if (segment.length === 0) return null;\n }\n\n // Skip dot separator\n if (i < len && path[i] === \".\") i++;\n\n return { segment, nextIndex: i };\n}\n\n/**\n * Access a property or index on an object or array.\n *\n * @param obj The object or array to access.\n * @param segment The property key or array index.\n * @returns The accessed value or undefined if not accessible.\n */\nfunction accessProperty(obj: unknown, segment: string | number): unknown {\n if (typeof segment === \"string\") {\n return getOwnProperty(obj, segment);\n }\n\n // Numeric index for arrays\n if (Array.isArray(obj) && segment >= 0 && segment < obj.length) {\n return obj[segment];\n }\n\n return undefined;\n}\n\n/**\n * Resolve a nested property path from an object.\n *\n * There are two types of property access patterns:\n * 1. Array/index access: [0] or [\"prop\"]\n * 2. Property access: prop or prop?.next\n *\n * @param obj The object to traverse.\n * @param path The property path (e.g., \"user.name\", \"users[0].email\", \"user['full-name']\").\n * @returns The resolved value or undefined if path doesn't exist.\n */\nfunction resolvePropertyPath(obj: unknown, path: string): unknown {\n if (obj == null) return undefined;\n\n // Check for invalid paths\n if (path.length === 0 || path.endsWith(\".\")) return undefined;\n\n let current: unknown = obj;\n let i = 0;\n const len = path.length;\n\n while (i < len) {\n // Handle optional chaining\n const isOptional = path.slice(i, i + 2) === \"?.\";\n if (isOptional) {\n i += 2;\n if (current == null) return undefined;\n } else if (current == null) {\n return undefined;\n }\n\n // Parse the next segment\n const result = parseNextSegment(path, i);\n if (result === null) return undefined;\n\n const { segment, nextIndex } = result;\n i = nextIndex;\n\n // Access the property/index\n current = accessProperty(current, segment);\n if (current === undefined) {\n return undefined;\n }\n }\n\n return current;\n}\n\n/**\n * Parse a message template into a message template array and a values array.\n *\n * Placeholders to be replaced with `values` are indicated by keys in curly braces\n * (e.g., `{value}`). The system supports both simple property access and nested\n * property access patterns:\n *\n * **Simple property access:**\n * ```ts\n * parseMessageTemplate(\"Hello, {user}!\", { user: \"foo\" })\n * // Returns: [\"Hello, \", \"foo\", \"!\"]\n * ```\n *\n * **Nested property access (dot notation):**\n * ```ts\n * parseMessageTemplate(\"Hello, {user.name}!\", {\n * user: { name: \"foo\", email: \"foo@example.com\" }\n * })\n * // Returns: [\"Hello, \", \"foo\", \"!\"]\n * ```\n *\n * **Array indexing:**\n * ```ts\n * parseMessageTemplate(\"First: {users[0]}\", {\n * users: [\"foo\", \"bar\", \"baz\"]\n * })\n * // Returns: [\"First: \", \"foo\", \"\"]\n * ```\n *\n * **Bracket notation for special property names:**\n * ```ts\n * parseMessageTemplate(\"Name: {user[\\\"full-name\\\"]}\", {\n * user: { \"full-name\": \"foo bar\" }\n * })\n * // Returns: [\"Name: \", \"foo bar\", \"\"]\n * ```\n *\n * **Optional chaining for safe navigation:**\n * ```ts\n * parseMessageTemplate(\"Email: {user?.profile?.email}\", {\n * user: { name: \"foo\" }\n * })\n * // Returns: [\"Email: \", undefined, \"\"]\n * ```\n *\n * **Wildcard patterns:**\n * - `{*}` - Replaced with the entire properties object\n * - `{ key-with-whitespace }` - Whitespace is trimmed when looking up keys\n *\n * **Escaping:**\n * - `{{` and `}}` are escaped literal braces\n *\n * **Error handling:**\n * - Non-existent paths return `undefined`\n * - Malformed expressions resolve to `undefined` without throwing errors\n * - Out of bounds array access returns `undefined`\n *\n * @param template The message template string containing placeholders.\n * @param properties The values to replace placeholders with.\n * @returns The message template array with values interleaved between text segments.\n */\nexport function parseMessageTemplate(\n template: string,\n properties: Record<string, unknown>,\n): readonly unknown[] {\n const length = template.length;\n if (length === 0) return [\"\"];\n\n // Fast path: no placeholders\n if (!template.includes(\"{\")) return [template];\n\n const message: unknown[] = [];\n let startIndex = 0;\n\n for (let i = 0; i < length; i++) {\n const char = template[i];\n\n if (char === \"{\") {\n const nextChar = i + 1 < length ? template[i + 1] : \"\";\n\n if (nextChar === \"{\") {\n // Escaped { character - skip and continue\n i++; // Skip the next {\n continue;\n }\n\n // Find the closing }\n const closeIndex = template.indexOf(\"}\", i + 1);\n if (closeIndex === -1) {\n // No closing } found, treat as literal text\n continue;\n }\n\n // Add text before placeholder\n const beforeText = template.slice(startIndex, i);\n message.push(beforeText.replace(/{{/g, \"{\").replace(/}}/g, \"}\"));\n\n // Extract and process placeholder key\n const key = template.slice(i + 1, closeIndex);\n\n // Resolve property value\n let prop: unknown;\n\n // Check for wildcard patterns\n const trimmedKey = key.trim();\n if (trimmedKey === \"*\") {\n // This is a wildcard pattern\n prop = key in properties\n ? properties[key]\n : \"*\" in properties\n ? properties[\"*\"]\n : properties;\n } else {\n // Regular property lookup with possible whitespace handling\n if (key !== trimmedKey) {\n // Key has leading/trailing whitespace\n prop = key in properties ? properties[key] : properties[trimmedKey];\n } else {\n // Key has no leading/trailing whitespace\n prop = properties[key];\n }\n\n // If property not found directly and this looks like nested access, try nested resolution\n if (prop === undefined && isNestedAccess(trimmedKey)) {\n prop = resolvePropertyPath(properties, trimmedKey);\n }\n }\n\n message.push(prop);\n i = closeIndex; // Move to the }\n startIndex = i + 1;\n } else if (char === \"}\" && i + 1 < length && template[i + 1] === \"}\") {\n // Escaped } character - skip\n i++; // Skip the next }\n }\n }\n\n // Add remaining text\n const remainingText = template.slice(startIndex);\n message.push(remainingText.replace(/{{/g, \"{\").replace(/}}/g, \"}\"));\n\n return message;\n}\n\n/**\n * Render a message template with values.\n * @param template The message template.\n * @param values The message template values.\n * @returns The message template values interleaved between the substitution\n * values.\n */\nexport function renderMessage(\n template: TemplateStringsArray,\n values: readonly unknown[],\n): unknown[] {\n const args = [];\n for (let i = 0; i < template.length; i++) {\n args.push(template[i]);\n if (i < values.length) args.push(values[i]);\n }\n return args;\n}\n"],"mappings":";;;;;;;;AAkBA,MAAMA,aAA4B,OAAO,IAAI,eAAe;AAC5D,MAAM,gCAAgC,OAAO,IAC3C,kCACD;AACD,MAAM,sBAAsB,OAAO,IACjC,uCACD;AACD,MAAMC,2CAA+C,IAAI;AACzD,MAAMC,2CAA+C,IAAI;;;;;;;;AAoBzD,SAAgB,OAAOC,OAAwC;AAC7D,QAAO,SAAS,eACP,UAAU,YACjB,cAAc,SACb,MAAwB,gBAAgB;AAC5C;;;;;;;;;;;;;;;;;;;;;;AAuBD,SAAgB,KAAQC,QAA0B;AAChD,QAAO;GAAG,aAAa;EAAM;CAAQ;AACtC;;;;;;;AAQD,SAAS,kBACPC,YACyB;CACzB,MAAMC,WAAoC,CAAE;AAC5C,MAAK,MAAM,OAAO,YAAY;EAC5B,MAAM,QAAQ,WAAW;AACzB,WAAS,OAAO,OAAO,MAAM,GAAG,MAAM,QAAQ,GAAG;CAClD;CACD,MAAM,mBAAmB;CACzB,MAAM,iBAAiB;AACvB,KACE,OAAO,UAAU,qBAAqB,KACpC,YACA,8BACD,EACD;EACA,MAAM,QAAQ,iBAAiB;AAC/B,iBAAe,iCAAiC,OAAO,MAAM,GACzD,MAAM,QAAQ,GACd;CACL;AACD,QAAO;AACR;AAMD,SAAS,gBAAmBH,OAAqC;AAI/D,KAAI,iBAAiB,QAAS,QAAO;AAKrC,QAAO,OAAO,UAAU,SAAS,KAAK,MAAM,KAAK,6BACvC,MAAqB,SAAS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D,WAAQ,KAAK,WAAW,QAAQ,OAAO,IAAI,CAAC,QAAQ,OAAO,IAAI,CAAC;GAGhE,MAAM,MAAM,SAAS,MAAM,IAAI,GAAG,WAAW;GAG7C,IAAIC;GAGJ,MAAM,aAAa,IAAI,MAAM;AAC7B,OAAI,eAAe,IAEjB,QAAO,OAAO,aACV,WAAW,OACX,OAAO,aACP,WAAW,OACX;QACC;AAEL,QAAI,QAAQ,WAEV,QAAO,OAAO,aAAa,WAAW,OAAO,WAAW;QAGxD,QAAO,WAAW;AAIpB,QAAI,mBAAsB,eAAe,WAAW,CAClD,QAAO,oBAAoB,YAAY,WAAW;GAErD;AAED,WAAQ,KAAK,KAAK;AAClB,OAAI;AACJ,gBAAa,IAAI;EAClB,WAAU,SAAS,OAAO,IAAI,IAAI,UAAU,SAAS,IAAI,OAAO,IAE/D;CAEH;CAGD,MAAM,gBAAgB,SAAS,MAAM,WAAW;AAChD,SAAQ,KAAK,cAAc,QAAQ,OAAO,IAAI,CAAC,QAAQ,OAAO,IAAI,CAAC;AAEnE,QAAO;AACR;;;;;;;;AASD,SAAgB,cACdC,UACAC,QACW;CACX,MAAM,OAAO,CAAE;AACf,MAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;AACxC,OAAK,KAAK,SAAS,GAAG;AACtB,MAAI,IAAI,OAAO,OAAQ,MAAK,KAAK,OAAO,GAAG;CAC5C;AACD,QAAO;AACR"}
1
+ {"version":3,"file":"logger.js","names":["lazySymbol: unique symbol","internalStringLogRecords: WeakSet<LogRecord>","resolvedStringLogRecords: WeakSet<LogRecord>","value: unknown","getter: () => T","properties: Record<string, unknown>","resolved: Record<string, unknown>","logger: StringMessageLogger","level: LogLevel","message: string","props?: unknown","record: LogRecord","properties: unknown","sink: Sink","category: string | readonly string[]","category: readonly string[]","rootLogger: LoggerImpl | null","parent: LoggerImpl | null","#parentSinks","value: \"inherit\" | \"override\"","#lowestLevel","value: LogLevel | null","subcategory:\n | string\n | readonly [string]\n | readonly [string, ...(readonly string[])]","child: LoggerImpl | undefined","#sinkPlanCache","plan: SinkDispatchPlan","parentPlan: SinkDispatchPlan | undefined","state: SinkDispatchPlanState","firstSink: Sink | undefined","sinks: Sink[] | undefined","record: Omit<LogRecord, \"category\"> | LogRecord","bypassSinks?: Set<Sink>","snapshot: LogRecord | undefined","snapshotFailed","snapshot","snapshotFailed: boolean","rawMessage: string","properties: Record<string, unknown> | (() => Record<string, unknown>)","record","cachedProps: Record<string, unknown> | undefined","cachedMessage: readonly unknown[] | undefined","callback: LogCallback","rawMessage: TemplateStringsArray | undefined","msg: unknown[] | undefined","messageTemplate: TemplateStringsArray","values: unknown[]","message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>","level: \"warning\" | \"error\" | \"fatal\"","error: Error","message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error","logger: LoggerImpl","subcategory: string | readonly [string] | readonly [string, ...string[]]","record: Omit<LogRecord, \"category\">","key: string","obj: unknown","path: string","fromIndex: number","segment: string | number","current: unknown","template: string","message: unknown[]","prop: unknown","template: TemplateStringsArray","values: readonly unknown[]"],"sources":["../src/logger.ts"],"sourcesContent":["import {\n type ContextLocalStorage,\n getCategoryPrefix,\n getImplicitContextIfAny,\n} from \"./context.ts\";\nimport type { Filter } from \"./filter.ts\";\nimport { compareLogLevel, type LogLevel } from \"./level.ts\";\nimport type { LogRecord } from \"./record.ts\";\nimport {\n emitWithScopedConfig,\n getCurrentScopedConfig,\n scopedConfigHasSink,\n} from \"./scoped-config.ts\";\nimport type { Sink } from \"./sink.ts\";\n\n/**\n * Symbol to identify lazy values.\n */\nconst lazySymbol: unique symbol = Symbol.for(\"logtape.lazy\");\nconst throttlingSummaryRecordSymbol = Symbol.for(\n \"LogTape.throttlingSummaryRecord\",\n);\nconst immediateSinkSymbol = Symbol.for(\n \"LogTape.sinkSnapshotPolicy.immediate\",\n);\nconst internalStringLogRecords: WeakSet<LogRecord> = new WeakSet();\nconst resolvedStringLogRecords: WeakSet<LogRecord> = new WeakSet();\n\n/**\n * A lazy value that is evaluated at logging time.\n *\n * @typeParam T The type of the value.\n * @since 2.0.0\n */\nexport interface Lazy<T> {\n readonly [lazySymbol]: true;\n readonly getter: () => T;\n}\n\n/**\n * Checks if a value is a lazy value.\n *\n * @param value The value to check.\n * @returns `true` if the value is a lazy value, `false` otherwise.\n * @since 2.0.0\n */\nexport function isLazy(value: unknown): value is Lazy<unknown> {\n return value != null &&\n typeof value === \"object\" &&\n lazySymbol in value &&\n (value as Lazy<unknown>)[lazySymbol] === true;\n}\n\n/**\n * Creates a lazy value that is evaluated at logging time.\n *\n * This is useful for logging contextual properties that may change over time,\n * such as the current user or request context.\n *\n * @example\n * ```typescript\n * let currentUser: string | null = null;\n * const logger = getLogger(\"app\").with({ user: lazy(() => currentUser) });\n *\n * logger.info(\"User action\"); // logs with user: null\n * currentUser = \"alice\";\n * logger.info(\"User action\"); // logs with user: \"alice\"\n * ```\n *\n * @typeParam T The type of the value.\n * @param getter A function that returns the value.\n * @returns A lazy value.\n * @since 2.0.0\n */\nexport function lazy<T>(getter: () => T): Lazy<T> {\n return { [lazySymbol]: true, getter };\n}\n\n/**\n * Resolves lazy values in a properties object.\n *\n * @param properties The properties object with potential lazy values.\n * @returns A new object with all lazy values resolved.\n */\nfunction resolveProperties(\n properties: Record<string, unknown>,\n): Record<string, unknown> {\n const resolved: Record<string, unknown> = {};\n for (const key in properties) {\n const value = properties[key];\n resolved[key] = isLazy(value) ? value.getter() : value;\n }\n const symbolProperties = properties as Record<symbol, unknown>;\n const symbolResolved = resolved as Record<symbol, unknown>;\n if (\n Object.prototype.propertyIsEnumerable.call(\n properties,\n throttlingSummaryRecordSymbol,\n )\n ) {\n const value = symbolProperties[throttlingSummaryRecordSymbol];\n symbolResolved[throttlingSummaryRecordSymbol] = isLazy(value)\n ? value.getter()\n : value;\n }\n return resolved;\n}\n\ntype LazyPropertiesCallback = () =>\n | Record<string, unknown>\n | Promise<Record<string, unknown>>;\n\nfunction isPromiseObject<T>(value: unknown): value is Promise<T> {\n // `instanceof Promise` only works for promises created in this realm.\n // Lazy callbacks may return a promise from another realm, such as a\n // `node:vm` context or a browser iframe, so we need a fallback.\n if (value instanceof Promise) return true;\n\n // `Object.prototype.toString` recognizes native promises across realms.\n // We also require a callable `then` so an object that only spoofs\n // `Symbol.toStringTag = \"Promise\"` is not treated as an async result.\n return Object.prototype.toString.call(value) === \"[object Promise]\" &&\n typeof (value as Promise<T>).then === \"function\";\n}\n\ninterface StringMessageLogger {\n isEnabledFor(level: LogLevel): boolean;\n log(\n level: LogLevel,\n message: string,\n properties: Record<string, unknown>,\n ): void;\n}\n\n// Callback-based string-message overloads are intentionally \"fire-and-forget\".\n// When the level is filtered out, we return an already-resolved promise\n// without invoking the callback so async property callbacks remain awaitable.\n// Synchronous callback call sites are expected to ignore the return value.\nfunction logStringMessage(\n logger: StringMessageLogger,\n level: LogLevel,\n message: string,\n props?: unknown,\n): void | Promise<void> {\n if (typeof props !== \"function\") {\n const properties = (props ?? {}) as Record<string, unknown>;\n logger.log(level, message, properties);\n return;\n }\n\n if (!logger.isEnabledFor(level)) return Promise.resolve();\n\n const result = (props as LazyPropertiesCallback)();\n if (isPromiseObject<Record<string, unknown>>(result)) {\n return Promise.resolve(result).then((resolvedProps) => {\n logger.log(level, message, resolvedProps);\n });\n }\n\n logger.log(level, message, result);\n}\n\nfunction snapshotLogRecordProperties(record: LogRecord): LogRecord {\n if (resolvedStringLogRecords.has(record)) {\n // The simple string fast path already owns a per-record properties object.\n // Reusing the record avoids the snapshot allocation in the hottest path.\n return record;\n }\n const properties: Record<string, unknown> = resolveProperties(\n record.properties,\n );\n if (internalStringLogRecords.has(record)) {\n // LoggerImpl.log() creates this fixed shape. Rebuilding it directly keeps\n // lazy message rendering intact without copying property descriptors.\n return {\n category: record.category,\n level: record.level,\n get message() {\n return record.message;\n },\n rawMessage: record.rawMessage,\n timestamp: record.timestamp,\n properties,\n };\n }\n const descriptors = Object.getOwnPropertyDescriptors(record) as\n & PropertyDescriptorMap\n & { properties?: PropertyDescriptor };\n descriptors.properties = {\n value: properties,\n enumerable: true,\n configurable: true,\n };\n return Object.defineProperties({}, descriptors) as LogRecord;\n}\n\nfunction hasEnumerableProperties(properties: unknown): boolean {\n if (properties == null || typeof properties !== \"object\") return false;\n return Object.keys(properties).length > 0 ||\n Object.prototype.propertyIsEnumerable.call(\n properties,\n throttlingSummaryRecordSymbol,\n );\n}\n\nfunction shouldSnapshotForSink(sink: Sink): boolean {\n // Custom sinks are assumed to be buffering sinks. Only built-in sinks that\n // synchronously finish formatting/encoding opt into receiving the live record.\n return (sink as unknown as Record<symbol, unknown>)[immediateSinkSymbol] !==\n true;\n}\n\ntype SinkDispatchPlanState = {\n readonly localSinks: readonly Sink[];\n readonly parentSinks: \"inherit\" | \"override\";\n readonly lowestLevel: LogLevel | null;\n readonly parentPlan: SinkDispatchPlan | undefined;\n};\n\ntype SinkDispatchPlan =\n & SinkDispatchPlanState\n & (\n | { readonly kind: \"none\" }\n | {\n readonly kind: \"one\";\n readonly sink: Sink;\n }\n | {\n readonly kind: \"many\";\n readonly sinks: readonly Sink[];\n }\n );\n\n/**\n * A logger interface. It provides methods to log messages at different\n * severity levels.\n *\n * ```typescript\n * const logger = getLogger(\"category\");\n * logger.trace `A trace message with ${value}`\n * logger.debug `A debug message with ${value}.`;\n * logger.info `An info message with ${value}.`;\n * logger.warn `A warning message with ${value}.`;\n * logger.error `An error message with ${value}.`;\n * logger.fatal `A fatal error message with ${value}.`;\n * ```\n *\n * Callback-based string-message overloads should be treated as\n * fire-and-forget. Async callbacks return `Promise<void>`, and when a\n * callback is filtered out because the level is disabled an implementation may\n * still return an already-resolved promise so the async path remains awaitable\n * without invoking the callback. Call sites should not branch on these\n * return values.\n */\nexport interface Logger {\n /**\n * The category of the logger. It is an array of strings.\n */\n readonly category: readonly string[];\n\n /**\n * The logger with the supercategory of the current logger. If the current\n * logger is the root logger, this is `null`.\n */\n readonly parent: Logger | null;\n\n /**\n * Get a child logger with the given subcategory.\n *\n * ```typescript\n * const logger = getLogger(\"category\");\n * const subLogger = logger.getChild(\"sub-category\");\n * ```\n *\n * The above code is equivalent to:\n *\n * ```typescript\n * const logger = getLogger(\"category\");\n * const subLogger = getLogger([\"category\", \"sub-category\"]);\n * ```\n *\n * @param subcategory The subcategory.\n * @returns The child logger.\n */\n getChild(\n subcategory: string | readonly [string] | readonly [string, ...string[]],\n ): Logger;\n\n /**\n * Get a logger with contextual properties. This is useful for\n * log multiple messages with the shared set of properties.\n *\n * ```typescript\n * const logger = getLogger(\"category\");\n * const ctx = logger.with({ foo: 123, bar: \"abc\" });\n * ctx.info(\"A message with {foo} and {bar}.\");\n * ctx.warn(\"Another message with {foo}, {bar}, and {baz}.\", { baz: true });\n * ```\n *\n * The above code is equivalent to:\n *\n * ```typescript\n * const logger = getLogger(\"category\");\n * logger.info(\"A message with {foo} and {bar}.\", { foo: 123, bar: \"abc\" });\n * logger.warn(\n * \"Another message with {foo}, {bar}, and {baz}.\",\n * { foo: 123, bar: \"abc\", baz: true },\n * );\n * ```\n *\n * @param properties\n * @returns\n * @since 0.5.0\n */\n with(properties: Record<string, unknown>): Logger;\n\n /**\n * Log a trace message. Use this as a template string prefix.\n *\n * ```typescript\n * logger.trace `A trace message with ${value}.`;\n * ```\n *\n * @param message The message template strings array.\n * @param values The message template values.\n * @since 0.12.0\n */\n trace(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n\n /**\n * Log a trace message with properties.\n *\n * ```typescript\n * logger.trace('A trace message with {value}.', { value });\n * ```\n *\n * If the properties are expensive to compute, you can pass a callback that\n * returns the properties:\n *\n * ```typescript\n * logger.trace(\n * 'A trace message with {value}.',\n * () => ({ value: expensiveComputation() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties The values to replace placeholders with. For lazy\n * evaluation, this can be a callback that returns the\n * properties.\n * @since 0.12.0\n */\n trace(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log a trace message with properties computed asynchronously.\n *\n * Use this when the properties require async operations to compute:\n *\n * ```typescript\n * await logger.trace(\n * 'A trace message with {value}.',\n * async () => ({ value: await fetchValue() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties An async callback that returns the properties.\n * @returns A promise that resolves when the log is written.\n * @since 2.0.0\n */\n trace(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n\n /**\n * Log a trace values with no message. This is useful when you\n * want to log properties without a message, e.g., when you want to log\n * the context of a request or an operation.\n *\n * ```typescript\n * logger.trace({ method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * Note that this is a shorthand for:\n *\n * ```typescript\n * logger.trace('{*}', { method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * If the properties are expensive to compute, you cannot use this shorthand\n * and should use the following syntax instead:\n *\n * ```typescript\n * logger.trace('{*}', () => ({\n * method: expensiveMethod(),\n * url: expensiveUrl(),\n * }));\n * ```\n *\n * @param properties The values to log. Note that this does not take\n * a callback.\n * @since 0.12.0\n */\n trace(properties: Record<string, unknown>): void;\n\n /**\n * Lazily log a trace message. Use this when the message values are expensive\n * to compute and should only be computed if the message is actually logged.\n *\n * ```typescript\n * logger.trace(l => l`A trace message with ${expensiveValue()}.`);\n * ```\n *\n * @param callback A callback that returns the message template prefix.\n * @throws {TypeError} If no log record was made inside the callback.\n * @since 0.12.0\n */\n trace(callback: LogCallback): void;\n\n /**\n * Log a debug message. Use this as a template string prefix.\n *\n * ```typescript\n * logger.debug `A debug message with ${value}.`;\n * ```\n *\n * @param message The message template strings array.\n * @param values The message template values.\n */\n debug(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n\n /**\n * Log a debug message with properties.\n *\n * ```typescript\n * logger.debug('A debug message with {value}.', { value });\n * ```\n *\n * If the properties are expensive to compute, you can pass a callback that\n * returns the properties:\n *\n * ```typescript\n * logger.debug(\n * 'A debug message with {value}.',\n * () => ({ value: expensiveComputation() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties The values to replace placeholders with. For lazy\n * evaluation, this can be a callback that returns the\n * properties.\n */\n debug(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log a debug message with properties computed asynchronously.\n *\n * Use this when the properties require async operations to compute:\n *\n * ```typescript\n * await logger.debug(\n * 'A debug message with {value}.',\n * async () => ({ value: await fetchValue() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties An async callback that returns the properties.\n * @returns A promise that resolves when the log is written.\n * @since 2.0.0\n */\n debug(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n\n /**\n * Log a debug values with no message. This is useful when you\n * want to log properties without a message, e.g., when you want to log\n * the context of a request or an operation.\n *\n * ```typescript\n * logger.debug({ method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * Note that this is a shorthand for:\n *\n * ```typescript\n * logger.debug('{*}', { method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * If the properties are expensive to compute, you cannot use this shorthand\n * and should use the following syntax instead:\n *\n * ```typescript\n * logger.debug('{*}', () => ({\n * method: expensiveMethod(),\n * url: expensiveUrl(),\n * }));\n * ```\n *\n * @param properties The values to log. Note that this does not take\n * a callback.\n * @since 0.11.0\n */\n debug(properties: Record<string, unknown>): void;\n\n /**\n * Lazily log a debug message. Use this when the message values are expensive\n * to compute and should only be computed if the message is actually logged.\n *\n * ```typescript\n * logger.debug(l => l`A debug message with ${expensiveValue()}.`);\n * ```\n *\n * @param callback A callback that returns the message template prefix.\n * @throws {TypeError} If no log record was made inside the callback.\n */\n debug(callback: LogCallback): void;\n\n /**\n * Log an informational message. Use this as a template string prefix.\n *\n * ```typescript\n * logger.info `An info message with ${value}.`;\n * ```\n *\n * @param message The message template strings array.\n * @param values The message template values.\n */\n info(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n\n /**\n * Log an informational message with properties.\n *\n * ```typescript\n * logger.info('An info message with {value}.', { value });\n * ```\n *\n * If the properties are expensive to compute, you can pass a callback that\n * returns the properties:\n *\n * ```typescript\n * logger.info(\n * 'An info message with {value}.',\n * () => ({ value: expensiveComputation() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties The values to replace placeholders with. For lazy\n * evaluation, this can be a callback that returns the\n * properties.\n */\n info(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log an informational message with properties computed asynchronously.\n *\n * Use this when the properties require async operations to compute:\n *\n * ```typescript\n * await logger.info(\n * 'An info message with {value}.',\n * async () => ({ value: await fetchValue() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties An async callback that returns the properties.\n * @returns A promise that resolves when the log is written.\n * @since 2.0.0\n */\n info(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n\n /**\n * Log an informational values with no message. This is useful when you\n * want to log properties without a message, e.g., when you want to log\n * the context of a request or an operation.\n *\n * ```typescript\n * logger.info({ method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * Note that this is a shorthand for:\n *\n * ```typescript\n * logger.info('{*}', { method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * If the properties are expensive to compute, you cannot use this shorthand\n * and should use the following syntax instead:\n *\n * ```typescript\n * logger.info('{*}', () => ({\n * method: expensiveMethod(),\n * url: expensiveUrl(),\n * }));\n * ```\n *\n * @param properties The values to log. Note that this does not take\n * a callback.\n * @since 0.11.0\n */\n info(properties: Record<string, unknown>): void;\n\n /**\n * Lazily log an informational message. Use this when the message values are\n * expensive to compute and should only be computed if the message is actually\n * logged.\n *\n * ```typescript\n * logger.info(l => l`An info message with ${expensiveValue()}.`);\n * ```\n *\n * @param callback A callback that returns the message template prefix.\n * @throws {TypeError} If no log record was made inside the callback.\n */\n info(callback: LogCallback): void;\n\n /**\n * Log a warning.\n *\n * This overload is a shorthand for logging an {@link Error} instance as a\n * structured property.\n *\n * ```typescript\n * logger.warn(new Error(\"Oops\"));\n * ```\n *\n * Note that this uses `{error.message}` as the default message template.\n * If you want to include the stack trace in text output, include `{error}`\n * in the message template instead.\n *\n * @param error The error to log.\n * @since 2.0.0\n */\n warn(error: Error): void;\n\n /**\n * Log a warning with additional properties.\n *\n * This overload is a shorthand for logging an {@link Error} instance as a\n * structured property while also adding extra properties.\n *\n * ```typescript\n * logger.warn(new Error(\"Oops\"), { requestId });\n * ```\n *\n * @param error The error to log.\n * @param properties Additional properties to log alongside the error.\n * @since 2.1.0\n */\n warn(\n error: Error,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log a warning with additional properties computed asynchronously.\n *\n * @param error The error to log.\n * @param properties An async callback that returns the properties.\n * @returns A promise that resolves when the log is written.\n * @since 2.1.0\n */\n warn(\n error: Error,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n\n /**\n * Log a warning message with an {@link Error}.\n *\n * ```typescript\n * logger.warn(\"Failed to do something\", new Error(\"Oops\"));\n * ```\n *\n * @param message The message.\n * @param error The error to log.\n * @since 2.0.0\n */\n warn(message: string, error: Error): void;\n\n /**\n * Log a warning message. Use this as a template string prefix.\n *\n * ```typescript\n * logger.warn `A warning message with ${value}.`;\n * ```\n *\n * @param message The message template strings array.\n * @param values The message template values.\n */\n warn(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n\n /**\n * Log a warning message with properties.\n *\n * ```typescript\n * logger.warn('A warning message with {value}.', { value });\n * ```\n *\n * If the properties are expensive to compute, you can pass a callback that\n * returns the properties:\n *\n * ```typescript\n * logger.warn(\n * 'A warning message with {value}.',\n * () => ({ value: expensiveComputation() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties The values to replace placeholders with. For lazy\n * evaluation, this can be a callback that returns the\n * properties.\n */\n warn(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log a warning message with properties computed asynchronously.\n *\n * Use this when the properties require async operations to compute:\n *\n * ```typescript\n * await logger.warn(\n * 'A warning message with {value}.',\n * async () => ({ value: await fetchValue() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties An async callback that returns the properties.\n * @returns A promise that resolves when the log is written.\n * @since 2.0.0\n */\n warn(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n\n /**\n * Log a warning values with no message. This is useful when you\n * want to log properties without a message, e.g., when you want to log\n * the context of a request or an operation.\n *\n * ```typescript\n * logger.warn({ method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * Note that this is a shorthand for:\n *\n * ```typescript\n * logger.warn('{*}', { method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * If the properties are expensive to compute, you cannot use this shorthand\n * and should use the following syntax instead:\n *\n * ```typescript\n * logger.warn('{*}', () => ({\n * method: expensiveMethod(),\n * url: expensiveUrl(),\n * }));\n * ```\n *\n * @param properties The values to log. Note that this does not take\n * a callback.\n * @since 0.11.0\n */\n warn(properties: Record<string, unknown>): void;\n\n /**\n * Lazily log a warning message. Use this when the message values are\n * expensive to compute and should only be computed if the message is actually\n * logged.\n *\n * ```typescript\n * logger.warn(l => l`A warning message with ${expensiveValue()}.`);\n * ```\n *\n * @param callback A callback that returns the message template prefix.\n * @throws {TypeError} If no log record was made inside the callback.\n */\n warn(callback: LogCallback): void;\n\n /**\n * Log a warning.\n *\n * This overload is a shorthand for logging an {@link Error} instance as a\n * structured property.\n *\n * ```typescript\n * logger.warning(new Error(\"Oops\"));\n * ```\n *\n * Note that this uses `{error.message}` as the default message template.\n * If you want to include the stack trace in text output, include `{error}`\n * in the message template instead.\n *\n * @param error The error to log.\n * @since 2.0.0\n */\n warning(error: Error): void;\n\n /**\n * Log a warning with additional properties.\n *\n * This overload is a shorthand for logging an {@link Error} instance as a\n * structured property while also adding extra properties.\n *\n * ```typescript\n * logger.warning(new Error(\"Oops\"), { requestId });\n * ```\n *\n * @param error The error to log.\n * @param properties Additional properties to log alongside the error.\n * @since 2.1.0\n */\n warning(\n error: Error,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log a warning with additional properties computed asynchronously.\n *\n * @param error The error to log.\n * @param properties An async callback that returns the properties.\n * @returns A promise that resolves when the log is written.\n * @since 2.1.0\n */\n warning(\n error: Error,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n\n /**\n * Log a warning message with an {@link Error}.\n *\n * ```typescript\n * logger.warning(\"Failed to do something\", new Error(\"Oops\"));\n * ```\n *\n * @param message The message.\n * @param error The error to log.\n * @since 2.0.0\n */\n warning(message: string, error: Error): void;\n\n /**\n * Log a warning message. Use this as a template string prefix.\n *\n * ```typescript\n * logger.warning `A warning message with ${value}.`;\n * ```\n *\n * @param message The message template strings array.\n * @param values The message template values.\n * @since 0.12.0\n */\n warning(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n\n /**\n * Log a warning message with properties.\n *\n * ```typescript\n * logger.warning('A warning message with {value}.', { value });\n * ```\n *\n * If the properties are expensive to compute, you can pass a callback that\n * returns the properties:\n *\n * ```typescript\n * logger.warning(\n * 'A warning message with {value}.',\n * () => ({ value: expensiveComputation() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties The values to replace placeholders with. For lazy\n * evaluation, this can be a callback that returns the\n * properties.\n * @since 0.12.0\n */\n warning(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log a warning message with properties computed asynchronously.\n *\n * Use this when the properties require async operations to compute:\n *\n * ```typescript\n * await logger.warning(\n * 'A warning message with {value}.',\n * async () => ({ value: await fetchValue() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties An async callback that returns the properties.\n * @returns A promise that resolves when the log is written.\n * @since 2.0.0\n */\n warning(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n\n /**\n * Log a warning values with no message. This is useful when you\n * want to log properties without a message, e.g., when you want to log\n * the context of a request or an operation.\n *\n * ```typescript\n * logger.warning({ method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * Note that this is a shorthand for:\n *\n * ```typescript\n * logger.warning('{*}', { method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * If the properties are expensive to compute, you cannot use this shorthand\n * and should use the following syntax instead:\n *\n * ```typescript\n * logger.warning('{*}', () => ({\n * method: expensiveMethod(),\n * url: expensiveUrl(),\n * }));\n * ```\n *\n * @param properties The values to log. Note that this does not take\n * a callback.\n * @since 0.12.0\n */\n warning(properties: Record<string, unknown>): void;\n\n /**\n * Lazily log a warning message. Use this when the message values are\n * expensive to compute and should only be computed if the message is actually\n * logged.\n *\n * ```typescript\n * logger.warning(l => l`A warning message with ${expensiveValue()}.`);\n * ```\n *\n * @param callback A callback that returns the message template prefix.\n * @throws {TypeError} If no log record was made inside the callback.\n * @since 0.12.0\n */\n warning(callback: LogCallback): void;\n\n /**\n * Log an error.\n *\n * This overload is a shorthand for logging an {@link Error} instance as a\n * structured property.\n *\n * ```typescript\n * logger.error(new Error(\"Oops\"));\n * ```\n *\n * Note that this uses `{error.message}` as the default message template.\n * If you want to include the stack trace in text output, include `{error}`\n * in the message template instead.\n *\n * @param error The error to log.\n * @since 2.0.0\n */\n error(error: Error): void;\n\n /**\n * Log an error with additional properties.\n *\n * This overload is a shorthand for logging an {@link Error} instance as a\n * structured property while also adding extra properties.\n *\n * ```typescript\n * logger.error(new Error(\"Oops\"), { requestId });\n * ```\n *\n * If the properties are expensive to compute, you can pass a callback that\n * returns the properties:\n *\n * ```typescript\n * logger.error(\n * new Error(\"Oops\"),\n * () => ({ requestId: expensiveLookup() })\n * );\n * ```\n *\n * @param error The error to log.\n * @param properties Additional properties to log alongside the error.\n * @since 2.1.0\n */\n error(\n error: Error,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log an error with additional properties computed asynchronously.\n *\n * Use this when the properties require async operations to compute:\n *\n * ```typescript\n * await logger.error(\n * new Error(\"Oops\"),\n * async () => ({ requestId: await fetchRequestId() })\n * );\n * ```\n *\n * @param error The error to log.\n * @param properties An async callback that returns the properties.\n * @returns A promise that resolves when the log is written.\n * @since 2.1.0\n */\n error(\n error: Error,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n\n /**\n * Log an error message with an {@link Error}.\n *\n * ```typescript\n * logger.error(\"Failed to do something\", new Error(\"Oops\"));\n * ```\n *\n * @param message The message.\n * @param error The error to log.\n * @since 2.0.0\n */\n error(message: string, error: Error): void;\n\n /**\n * Log an error message. Use this as a template string prefix.\n *\n * ```typescript\n * logger.error `An error message with ${value}.`;\n * ```\n *\n * @param message The message template strings array.\n * @param values The message template values.\n */\n error(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n\n /**\n * Log an error message with properties.\n *\n * ```typescript\n * logger.warn('An error message with {value}.', { value });\n * ```\n *\n * If the properties are expensive to compute, you can pass a callback that\n * returns the properties:\n *\n * ```typescript\n * logger.error(\n * 'An error message with {value}.',\n * () => ({ value: expensiveComputation() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties The values to replace placeholders with. For lazy\n * evaluation, this can be a callback that returns the\n * properties.\n */\n error(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log an error message with properties computed asynchronously.\n *\n * Use this when the properties require async operations to compute:\n *\n * ```typescript\n * await logger.error(\n * 'An error message with {value}.',\n * async () => ({ value: await fetchValue() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties An async callback that returns the properties.\n * @returns A promise that resolves when the log is written.\n * @since 2.0.0\n */\n error(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n\n /**\n * Log an error values with no message. This is useful when you\n * want to log properties without a message, e.g., when you want to log\n * the context of a request or an operation.\n *\n * ```typescript\n * logger.error({ method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * Note that this is a shorthand for:\n *\n * ```typescript\n * logger.error('{*}', { method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * If the properties are expensive to compute, you cannot use this shorthand\n * and should use the following syntax instead:\n *\n * ```typescript\n * logger.error('{*}', () => ({\n * method: expensiveMethod(),\n * url: expensiveUrl(),\n * }));\n * ```\n *\n * @param properties The values to log. Note that this does not take\n * a callback.\n * @since 0.11.0\n */\n error(properties: Record<string, unknown>): void;\n\n /**\n * Lazily log an error message. Use this when the message values are\n * expensive to compute and should only be computed if the message is actually\n * logged.\n *\n * ```typescript\n * logger.error(l => l`An error message with ${expensiveValue()}.`);\n * ```\n *\n * @param callback A callback that returns the message template prefix.\n * @throws {TypeError} If no log record was made inside the callback.\n */\n error(callback: LogCallback): void;\n\n /**\n * Log a fatal error.\n *\n * This overload is a shorthand for logging an {@link Error} instance as a\n * structured property.\n *\n * ```typescript\n * logger.fatal(new Error(\"Oops\"));\n * ```\n *\n * Note that this uses `{error.message}` as the default message template.\n * If you want to include the stack trace in text output, include `{error}`\n * in the message template instead.\n *\n * @param error The error to log.\n * @since 2.0.0\n */\n fatal(error: Error): void;\n\n /**\n * Log a fatal error with additional properties.\n *\n * This overload is a shorthand for logging an {@link Error} instance as a\n * structured property while also adding extra properties.\n *\n * ```typescript\n * logger.fatal(new Error(\"Oops\"), { requestId });\n * ```\n *\n * @param error The error to log.\n * @param properties Additional properties to log alongside the error.\n * @since 2.1.0\n */\n fatal(\n error: Error,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log a fatal error with additional properties computed asynchronously.\n *\n * @param error The error to log.\n * @param properties An async callback that returns the properties.\n * @returns A promise that resolves when the log is written.\n * @since 2.1.0\n */\n fatal(\n error: Error,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n\n /**\n * Log a fatal error message with an {@link Error}.\n *\n * ```typescript\n * logger.fatal(\"Failed to do something\", new Error(\"Oops\"));\n * ```\n *\n * @param message The message.\n * @param error The error to log.\n * @since 2.0.0\n */\n fatal(message: string, error: Error): void;\n\n /**\n * Log a fatal error message. Use this as a template string prefix.\n *\n * ```typescript\n * logger.fatal `A fatal error message with ${value}.`;\n * ```\n *\n * @param message The message template strings array.\n * @param values The message template values.\n */\n fatal(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n\n /**\n * Log a fatal error message with properties.\n *\n * ```typescript\n * logger.warn('A fatal error message with {value}.', { value });\n * ```\n *\n * If the properties are expensive to compute, you can pass a callback that\n * returns the properties:\n *\n * ```typescript\n * logger.fatal(\n * 'A fatal error message with {value}.',\n * () => ({ value: expensiveComputation() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties The values to replace placeholders with. For lazy\n * evaluation, this can be a callback that returns the\n * properties.\n */\n fatal(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log a fatal error message with properties computed asynchronously.\n *\n * Use this when the properties require async operations to compute:\n *\n * ```typescript\n * await logger.fatal(\n * 'A fatal error message with {value}.',\n * async () => ({ value: await fetchValue() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties An async callback that returns the properties.\n * @returns A promise that resolves when the log is written.\n * @since 2.0.0\n */\n fatal(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n\n /**\n * Log a fatal error values with no message. This is useful when you\n * want to log properties without a message, e.g., when you want to log\n * the context of a request or an operation.\n *\n * ```typescript\n * logger.fatal({ method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * Note that this is a shorthand for:\n *\n * ```typescript\n * logger.fatal('{*}', { method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * If the properties are expensive to compute, you cannot use this shorthand\n * and should use the following syntax instead:\n *\n * ```typescript\n * logger.fatal('{*}', () => ({\n * method: expensiveMethod(),\n * url: expensiveUrl(),\n * }));\n * ```\n *\n * @param properties The values to log. Note that this does not take\n * a callback.\n * @since 0.11.0\n */\n fatal(properties: Record<string, unknown>): void;\n\n /**\n * Lazily log a fatal error message. Use this when the message values are\n * expensive to compute and should only be computed if the message is actually\n * logged.\n *\n * ```typescript\n * logger.fatal(l => l`A fatal error message with ${expensiveValue()}.`);\n * ```\n *\n * @param callback A callback that returns the message template prefix.\n * @throws {TypeError} If no log record was made inside the callback.\n */\n fatal(callback: LogCallback): void;\n\n /**\n * Emits a log record with custom fields while using this logger's\n * category.\n *\n * This is a low-level API for integration scenarios where you need full\n * control over the log record, particularly for preserving timestamps\n * from external systems.\n *\n * ```typescript\n * const logger = getLogger([\"my-app\", \"integration\"]);\n *\n * // Emit a log with a custom timestamp\n * logger.emit({\n * timestamp: kafkaLog.originalTimestamp,\n * level: \"info\",\n * message: [kafkaLog.message],\n * rawMessage: kafkaLog.message,\n * properties: {\n * source: \"kafka\",\n * partition: kafkaLog.partition,\n * offset: kafkaLog.offset,\n * },\n * });\n * ```\n *\n * @param record Log record without category field (category comes from\n * the logger instance)\n * @since 1.1.0\n */\n emit(record: Omit<LogRecord, \"category\">): void;\n\n /**\n * Check if a message of the given severity level would be processed by\n * this logger.\n *\n * This is useful for conditionally executing expensive computations\n * before logging, particularly for async operations where lazy\n * evaluation callbacks cannot be used:\n *\n * ```typescript\n * if (logger.isEnabledFor(\"debug\")) {\n * const result = await expensiveAsync();\n * logger.debug(\"Result: {result}\", { result });\n * }\n * ```\n *\n * @param level The log level to check.\n * @returns `true` if a message of the given level would be logged,\n * `false` otherwise.\n * @since 2.0.0\n */\n isEnabledFor(level: LogLevel): boolean;\n}\n\n/**\n * A logging callback function. It is used to defer the computation of a\n * message template until it is actually logged.\n * @param prefix The message template prefix.\n * @returns The rendered message array.\n */\nexport type LogCallback = (prefix: LogTemplatePrefix) => unknown[];\n\n/**\n * A logging template prefix function. It is used to log a message in\n * a {@link LogCallback} function.\n * @param message The message template strings array.\n * @param values The message template values.\n * @returns The rendered message array.\n */\nexport type LogTemplatePrefix = (\n message: TemplateStringsArray,\n ...values: unknown[]\n) => unknown[];\n\n/**\n * A function type for logging methods in the {@link Logger} interface.\n * @since 1.0.0\n */\nexport interface LogMethod {\n /**\n * Log a message with the given level using a template string.\n * @param message The message template strings array.\n * @param values The message template values.\n */\n (\n message: TemplateStringsArray,\n ...values: readonly unknown[]\n ): void;\n\n /**\n * Log a message with the given level with properties.\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties The values to replace placeholders with. For lazy\n * evaluation, this can be a callback that returns the\n * properties.\n */\n (\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log a message with the given level with properties computed asynchronously.\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties An async callback that returns the properties.\n * @returns A promise that resolves when the log is written.\n * @since 2.0.0\n */\n (\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n\n /**\n * Log a message with the given level with no message.\n * @param properties The values to log. Note that this does not take\n * a callback.\n */\n (properties: Record<string, unknown>): void;\n\n /**\n * Lazily log a message with the given level.\n * @param callback A callback that returns the message template prefix.\n * @throws {TypeError} If no log record was made inside the callback.\n */\n (callback: LogCallback): void;\n}\n\n/**\n * Get a logger with the given category.\n *\n * ```typescript\n * const logger = getLogger([\"my-app\"]);\n * ```\n *\n * @param category The category of the logger. It can be a string or an array\n * of strings. If it is a string, it is equivalent to an array\n * with a single element.\n * @returns The logger.\n */\nexport function getLogger(category: string | readonly string[] = []): Logger {\n return LoggerImpl.getLogger(category);\n}\n\n/**\n * The symbol for the global root logger.\n */\nconst globalRootLoggerSymbol = Symbol.for(\"logtape.rootLogger\");\n\nfunction isMetaLoggerCategory(category: readonly string[]): boolean {\n return category.length >= 2 &&\n category[0] === \"logtape\" &&\n category[1] === \"meta\";\n}\n\n/**\n * The global root logger registry.\n */\ninterface GlobalRootLoggerRegistry {\n [globalRootLoggerSymbol]?: LoggerImpl;\n}\n\n/**\n * A logger implementation. Do not use this directly; use {@link getLogger}\n * instead. This class is exported for testing purposes.\n */\nexport class LoggerImpl implements Logger {\n readonly parent: LoggerImpl | null;\n readonly children: Record<string, LoggerImpl | WeakRef<LoggerImpl>>;\n readonly category: readonly string[];\n readonly sinks: Sink[];\n readonly filters: Filter[];\n contextLocalStorage?: ContextLocalStorage<Record<string, unknown>>;\n #parentSinks: \"inherit\" | \"override\" = \"inherit\";\n #lowestLevel: LogLevel | null = \"trace\";\n #sinkPlanCache: Partial<Record<LogLevel, SinkDispatchPlan>> = {};\n\n static getLogger(category: string | readonly string[] = []): LoggerImpl {\n let rootLogger: LoggerImpl | null = globalRootLoggerSymbol in globalThis\n ? ((globalThis as GlobalRootLoggerRegistry)[globalRootLoggerSymbol] ??\n null)\n : null;\n if (rootLogger == null) {\n rootLogger = new LoggerImpl(null, []);\n (globalThis as GlobalRootLoggerRegistry)[globalRootLoggerSymbol] =\n rootLogger;\n }\n if (typeof category === \"string\") return rootLogger.getChild(category);\n if (category.length === 0) return rootLogger;\n return rootLogger.getChild(category as readonly [string, ...string[]]);\n }\n\n private static getNearestExistingLogger(\n category: readonly string[],\n ): LoggerImpl {\n let logger = LoggerImpl.getLogger();\n for (const name of category) {\n const childRef = logger.children[name];\n const child = childRef instanceof LoggerImpl\n ? childRef\n : childRef?.deref();\n if (child == null) break;\n logger = child;\n }\n return logger;\n }\n\n private constructor(parent: LoggerImpl | null, category: readonly string[]) {\n this.parent = parent;\n this.children = {};\n this.category = category;\n this.sinks = [];\n this.filters = [];\n }\n\n get parentSinks(): \"inherit\" | \"override\" {\n return this.#parentSinks;\n }\n\n set parentSinks(value: \"inherit\" | \"override\") {\n if (this.#parentSinks === value) return;\n this.#parentSinks = value;\n }\n\n get lowestLevel(): LogLevel | null {\n return this.#lowestLevel;\n }\n\n set lowestLevel(value: LogLevel | null) {\n if (this.#lowestLevel === value) return;\n this.#lowestLevel = value;\n }\n\n getChild(\n subcategory:\n | string\n | readonly [string]\n | readonly [string, ...(readonly string[])],\n ): LoggerImpl {\n const name = typeof subcategory === \"string\" ? subcategory : subcategory[0];\n const childRef = this.children[name];\n let child: LoggerImpl | undefined = childRef instanceof LoggerImpl\n ? childRef\n : childRef?.deref();\n if (child == null) {\n child = new LoggerImpl(this, [...this.category, name]);\n this.children[name] = \"WeakRef\" in globalThis\n ? new WeakRef(child)\n : child;\n }\n if (typeof subcategory === \"string\" || subcategory.length === 1) {\n return child;\n }\n return child.getChild(\n subcategory.slice(1) as [string, ...(readonly string[])],\n );\n }\n\n /**\n * Reset the logger. This removes all sinks and filters from the logger.\n */\n reset(): void {\n while (this.sinks.length > 0) this.sinks.shift();\n this.parentSinks = \"inherit\";\n while (this.filters.length > 0) this.filters.shift();\n this.lowestLevel = \"trace\";\n }\n\n /**\n * Reset the logger and all its descendants. This removes all sinks and\n * filters from the logger and all its descendants.\n */\n resetDescendants(): void {\n for (const child of Object.values(this.children)) {\n const logger = child instanceof LoggerImpl ? child : child.deref();\n if (logger != null) logger.resetDescendants();\n }\n this.reset();\n }\n\n with(properties: Record<string, unknown>): Logger {\n return new LoggerCtx(this, { ...properties });\n }\n\n filter(record: LogRecord): boolean {\n for (const filter of this.filters) {\n if (!filter(record)) return false;\n }\n if (this.filters.length < 1) return this.parent?.filter(record) ?? true;\n return true;\n }\n\n *getSinks(level: LogLevel): Iterable<Sink> {\n const plan = this.getSinkDispatchPlan(level);\n switch (plan.kind) {\n case \"none\":\n return;\n case \"one\":\n yield plan.sink;\n return;\n case \"many\":\n yield* plan.sinks;\n return;\n }\n }\n\n private getSinkDispatchPlan(level: LogLevel): SinkDispatchPlan {\n const cached = this.#sinkPlanCache[level];\n if (cached != null && this.isSinkDispatchPlanFresh(level, cached)) {\n return cached;\n }\n\n const parentPlan = this.parent != null && this.parentSinks === \"inherit\"\n ? this.parent.getSinkDispatchPlan(level)\n : undefined;\n const plan = this.createSinkDispatchPlan(level, parentPlan);\n this.#sinkPlanCache[level] = plan;\n return plan;\n }\n\n private isSinkDispatchPlanFresh(\n level: LogLevel,\n plan: SinkDispatchPlan,\n ): boolean {\n if (\n plan.lowestLevel !== this.lowestLevel ||\n plan.parentSinks !== this.parentSinks ||\n plan.localSinks.length !== this.sinks.length\n ) {\n return false;\n }\n for (let i = 0; i < plan.localSinks.length; i++) {\n if (plan.localSinks[i] !== this.sinks[i]) return false;\n }\n\n const parentPlan = this.parent != null && this.parentSinks === \"inherit\"\n ? this.parent.getSinkDispatchPlan(level)\n : undefined;\n return plan.parentPlan === parentPlan;\n }\n\n private createSinkDispatchPlan(\n level: LogLevel,\n parentPlan: SinkDispatchPlan | undefined,\n ): SinkDispatchPlan {\n const state: SinkDispatchPlanState = {\n // Keep a plain array for compatibility with cross-runtime assertions, but\n // snapshot it here so direct index/length mutations invalidate the cache.\n localSinks: [...this.sinks],\n parentSinks: this.parentSinks,\n lowestLevel: this.lowestLevel,\n parentPlan,\n };\n if (state.lowestLevel === null) return { ...state, kind: \"none\" };\n if (compareLogLevel(level, state.lowestLevel) < 0) {\n return { ...state, kind: \"none\" };\n }\n\n let firstSink: Sink | undefined;\n let sinks: Sink[] | undefined;\n const appendSink = (sink: Sink) => {\n if (sinks != null) {\n sinks.push(sink);\n } else if (firstSink == null) {\n firstSink = sink;\n } else {\n sinks = [firstSink, sink];\n }\n };\n\n if (parentPlan != null) {\n if (parentPlan.kind === \"one\") {\n firstSink = parentPlan.sink;\n } else if (parentPlan.kind === \"many\") {\n // Multiple-sink plans are snapshots. Copy the parent snapshot so local\n // sinks can be appended without mutating the parent's cached plan.\n sinks = [...parentPlan.sinks];\n }\n }\n for (const sink of state.localSinks) appendSink(sink);\n\n if (sinks != null) return { ...state, kind: \"many\", sinks };\n if (firstSink != null) return { ...state, kind: \"one\", sink: firstSink };\n return { ...state, kind: \"none\" };\n }\n\n isEnabledFor(level: LogLevel): boolean {\n const categoryPrefix = isMetaLoggerCategory(this.category)\n ? []\n : getCategoryPrefix();\n const dispatcher = categoryPrefix.length > 0\n ? LoggerImpl.getNearestExistingLogger([\n ...categoryPrefix,\n ...this.category,\n ])\n : this;\n const scopedConfig = getCurrentScopedConfig(\n LoggerImpl.getLogger().contextLocalStorage,\n );\n if (scopedConfig != null) {\n return scopedConfigHasSink(\n scopedConfig,\n categoryPrefix.length > 0\n ? [...categoryPrefix, ...this.category]\n : this.category,\n level,\n );\n }\n return dispatcher.isEnabledForResolved(level);\n }\n\n private isEnabledForResolved(level: LogLevel): boolean {\n return this.getSinkDispatchPlan(level).kind !== \"none\";\n }\n\n emit(record: Omit<LogRecord, \"category\">): void;\n emit(record: LogRecord, bypassSinks?: Set<Sink>): void;\n emit(\n record: Omit<LogRecord, \"category\"> | LogRecord,\n bypassSinks?: Set<Sink>,\n ): void {\n const hasCategory = \"category\" in record;\n const baseCategory = hasCategory\n ? (record as LogRecord).category\n : this.category;\n const categoryPrefix = isMetaLoggerCategory(baseCategory)\n ? []\n : getCategoryPrefix();\n const fullCategory = categoryPrefix.length > 0\n ? [...categoryPrefix, ...baseCategory]\n : baseCategory;\n if (\n categoryPrefix.length < 1 &&\n Object.prototype.hasOwnProperty.call(record, \"category\")\n ) {\n // The record already carries the final category in the common path, so\n // avoid cloning descriptors on every enabled log call.\n this.emitResolved(record as LogRecord, bypassSinks);\n return;\n }\n\n // Create the full record by copying property descriptors from the original\n // record, which preserves getters without invoking them (unlike spread).\n const descriptors = Object.getOwnPropertyDescriptors(record) as\n & PropertyDescriptorMap\n & { category?: PropertyDescriptor };\n descriptors.category = {\n value: fullCategory,\n enumerable: true,\n configurable: true,\n };\n const fullRecord = Object.defineProperties({}, descriptors) as LogRecord;\n const dispatcher = categoryPrefix.length > 0\n ? LoggerImpl.getNearestExistingLogger(fullCategory)\n : this;\n dispatcher.emitResolved(fullRecord, bypassSinks);\n }\n\n private emitResolved(record: LogRecord, bypassSinks?: Set<Sink>): void {\n const scopedConfig = getCurrentScopedConfig(\n LoggerImpl.getLogger().contextLocalStorage,\n );\n if (scopedConfig != null) {\n let snapshot: LogRecord | undefined;\n let snapshotFailed = false;\n emitWithScopedConfig(\n scopedConfig,\n record,\n bypassSinks,\n (sink, activeBypassSinks) => {\n try {\n if (shouldSnapshotForSink(sink)) {\n try {\n snapshot ??= snapshotLogRecordProperties(record);\n } catch {\n snapshotFailed = true;\n snapshot = record;\n }\n }\n sink(snapshot ?? record);\n } catch (error) {\n const bypassSinks2 = new Set(activeBypassSinks);\n bypassSinks2.add(sink);\n metaLogger.log(\n \"fatal\",\n \"Failed to emit a log record to sink {sink}: {error}\",\n { sink, error, record },\n bypassSinks2,\n );\n }\n if (snapshotFailed) snapshot = record;\n },\n );\n return;\n }\n\n if (\n this.lowestLevel === null ||\n compareLogLevel(record.level, this.lowestLevel) < 0 ||\n !this.filter(record)\n ) {\n return;\n }\n const plan = this.getSinkDispatchPlan(record.level);\n if (plan.kind === \"none\") return;\n\n let snapshot: LogRecord | undefined;\n let snapshotFailed: boolean = false;\n if (plan.kind === \"one\") {\n const sink = plan.sink;\n if (bypassSinks?.has(sink)) return;\n try {\n if (shouldSnapshotForSink(sink)) {\n try {\n // Avoid a sinks array for the common one-sink path, but keep lazy\n // properties snapshotted before a sink can buffer the record.\n snapshot = snapshotLogRecordProperties(record);\n } catch {\n snapshotFailed = true;\n snapshot = record;\n }\n }\n sink(snapshot ?? record);\n } catch (error) {\n const bypassSinks2 = new Set(bypassSinks);\n bypassSinks2.add(sink);\n metaLogger.log(\n \"fatal\",\n \"Failed to emit a log record to sink {sink}: {error}\",\n { sink, error, record },\n bypassSinks2,\n );\n }\n return;\n }\n\n for (const sink of plan.sinks) {\n if (bypassSinks?.has(sink)) continue;\n try {\n if (\n snapshot == null && !snapshotFailed && shouldSnapshotForSink(sink)\n ) {\n try {\n // Build the snapshot only once and only for a sink that will\n // actually requires it and will receive the record.\n snapshot = snapshotLogRecordProperties(record);\n } catch {\n snapshotFailed = true;\n snapshot = record;\n }\n }\n sink(snapshot ?? record);\n } catch (error) {\n const bypassSinks2 = new Set(bypassSinks);\n bypassSinks2.add(sink);\n metaLogger.log(\n \"fatal\",\n \"Failed to emit a log record to sink {sink}: {error}\",\n { sink, error, record },\n bypassSinks2,\n );\n }\n }\n }\n\n log(\n level: LogLevel,\n rawMessage: string,\n properties: Record<string, unknown> | (() => Record<string, unknown>),\n bypassSinks?: Set<Sink>,\n ): void {\n const implicitContext = getImplicitContextIfAny();\n if (\n typeof properties !== \"function\" &&\n implicitContext == null &&\n !rawMessage.includes(\"{\") &&\n !hasEnumerableProperties(properties)\n ) {\n const record: LogRecord = {\n category: this.category,\n level,\n message: [rawMessage],\n rawMessage,\n timestamp: Date.now(),\n properties: {},\n };\n resolvedStringLogRecords.add(record);\n this.emit(record, bypassSinks);\n return;\n }\n\n let cachedProps: Record<string, unknown> | undefined = undefined;\n let cachedMessage: readonly unknown[] | undefined = undefined;\n const record: LogRecord = typeof properties === \"function\"\n ? {\n category: this.category,\n level,\n timestamp: Date.now(),\n get message() {\n if (cachedMessage == null) {\n cachedMessage = parseMessageTemplate(rawMessage, this.properties);\n }\n return cachedMessage;\n },\n rawMessage,\n get properties() {\n if (cachedProps == null) {\n cachedProps = resolveProperties({\n ...(implicitContext ?? {}),\n ...properties(),\n });\n }\n return cachedProps;\n },\n }\n : {\n category: this.category,\n level,\n timestamp: Date.now(),\n get message() {\n if (cachedMessage == null) {\n cachedMessage = parseMessageTemplate(rawMessage, this.properties);\n }\n return cachedMessage;\n },\n rawMessage,\n get properties() {\n if (cachedProps == null) {\n cachedProps = resolveProperties({\n ...(implicitContext ?? {}),\n ...properties,\n });\n }\n return cachedProps;\n },\n };\n internalStringLogRecords.add(record);\n this.emit(record, bypassSinks);\n }\n\n logLazily(\n level: LogLevel,\n callback: LogCallback,\n properties: Record<string, unknown> = {},\n ): void {\n const implicitContext = getImplicitContextIfAny();\n let rawMessage: TemplateStringsArray | undefined = undefined;\n let msg: unknown[] | undefined = undefined;\n function realizeMessage(): [unknown[], TemplateStringsArray] {\n if (msg == null || rawMessage == null) {\n msg = callback((tpl, ...values) => {\n rawMessage = tpl;\n return renderMessage(tpl, values);\n });\n if (rawMessage == null) throw new TypeError(\"No log record was made.\");\n }\n return [msg, rawMessage];\n }\n this.emit({\n category: this.category,\n level,\n get message() {\n return realizeMessage()[0];\n },\n get rawMessage() {\n return realizeMessage()[1];\n },\n timestamp: Date.now(),\n properties: { ...(implicitContext ?? {}), ...properties },\n });\n }\n\n logTemplate(\n level: LogLevel,\n messageTemplate: TemplateStringsArray,\n values: unknown[],\n properties: Record<string, unknown> = {},\n ): void {\n const implicitContext = getImplicitContextIfAny();\n this.emit({\n category: this.category,\n level,\n message: renderMessage(messageTemplate, values),\n rawMessage: messageTemplate,\n timestamp: Date.now(),\n properties: { ...(implicitContext ?? {}), ...properties },\n });\n }\n\n trace(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n trace(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n trace(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n trace(properties: Record<string, unknown>): void;\n trace(callback: LogCallback): void;\n trace(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void | Promise<void> {\n if (typeof message === \"string\") {\n return logStringMessage(this, \"trace\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"trace\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"trace\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"trace\", message as TemplateStringsArray, values);\n }\n }\n\n debug(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n debug(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n debug(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n debug(properties: Record<string, unknown>): void;\n debug(callback: LogCallback): void;\n debug(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void | Promise<void> {\n if (typeof message === \"string\") {\n return logStringMessage(this, \"debug\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"debug\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"debug\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"debug\", message as TemplateStringsArray, values);\n }\n }\n\n info(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n info(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n info(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n info(properties: Record<string, unknown>): void;\n info(callback: LogCallback): void;\n info(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void | Promise<void> {\n if (typeof message === \"string\") {\n return logStringMessage(this, \"info\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"info\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"info\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"info\", message as TemplateStringsArray, values);\n }\n }\n\n private logError(\n level: \"warning\" | \"error\" | \"fatal\",\n error: Error,\n props?: unknown,\n ): void | Promise<void> {\n if (typeof props !== \"function\") {\n this.log(level, \"{error.message}\", {\n ...(props as Record<string, unknown>),\n error,\n });\n return;\n }\n\n if (!this.isEnabledFor(level)) return Promise.resolve();\n\n const result = (props as () =>\n | Record<string, unknown>\n | Promise<Record<string, unknown>>)();\n\n if (result instanceof Promise) {\n return result.then((resolved) => {\n this.log(level, \"{error.message}\", { ...resolved, error });\n });\n }\n\n this.log(level, \"{error.message}\", { ...result, error });\n }\n\n warn(error: Error): void;\n warn(\n error: Error,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n warn(\n error: Error,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n warn(message: string, error: Error): void;\n warn(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n warn(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n warn(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n warn(properties: Record<string, unknown>): void;\n warn(callback: LogCallback): void;\n warn(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error,\n ...values: unknown[]\n ): void | Promise<void> {\n if (message instanceof Error) {\n return this.logError(\"warning\", message, values[0]);\n } else if (typeof message === \"string\" && values[0] instanceof Error) {\n this.log(\"warning\", message, { error: values[0] });\n } else if (typeof message === \"string\") {\n return logStringMessage(this, \"warning\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"warning\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"warning\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"warning\", message as TemplateStringsArray, values);\n }\n }\n\n warning(error: Error): void;\n warning(\n error: Error,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n warning(\n error: Error,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n warning(message: string, error: Error): void;\n warning(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n warning(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n warning(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n warning(properties: Record<string, unknown>): void;\n warning(callback: LogCallback): void;\n warning(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error,\n ...values: unknown[]\n ): void | Promise<void> {\n if (message instanceof Error) {\n return this.logError(\"warning\", message, values[0]);\n } else if (typeof message === \"string\" && values[0] instanceof Error) {\n this.log(\"warning\", message, { error: values[0] });\n } else if (typeof message === \"string\") {\n return logStringMessage(this, \"warning\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"warning\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"warning\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"warning\", message as TemplateStringsArray, values);\n }\n }\n\n error(error: Error): void;\n error(\n error: Error,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n error(\n error: Error,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n error(message: string, error: Error): void;\n error(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n error(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n error(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n error(properties: Record<string, unknown>): void;\n error(callback: LogCallback): void;\n error(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error,\n ...values: unknown[]\n ): void | Promise<void> {\n if (message instanceof Error) {\n return this.logError(\"error\", message, values[0]);\n } else if (typeof message === \"string\" && values[0] instanceof Error) {\n this.log(\"error\", message, { error: values[0] });\n } else if (typeof message === \"string\") {\n return logStringMessage(this, \"error\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"error\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"error\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"error\", message as TemplateStringsArray, values);\n }\n }\n\n fatal(error: Error): void;\n fatal(\n error: Error,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n fatal(\n error: Error,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n fatal(message: string, error: Error): void;\n fatal(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n fatal(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n fatal(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n fatal(properties: Record<string, unknown>): void;\n fatal(callback: LogCallback): void;\n fatal(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error,\n ...values: unknown[]\n ): void | Promise<void> {\n if (message instanceof Error) {\n return this.logError(\"fatal\", message, values[0]);\n } else if (typeof message === \"string\" && values[0] instanceof Error) {\n this.log(\"fatal\", message, { error: values[0] });\n } else if (typeof message === \"string\") {\n return logStringMessage(this, \"fatal\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"fatal\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"fatal\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"fatal\", message as TemplateStringsArray, values);\n }\n }\n}\n\n/**\n * A logger implementation with contextual properties. Do not use this\n * directly; use {@link Logger.with} instead. This class is exported\n * for testing purposes.\n */\nexport class LoggerCtx implements Logger {\n logger: LoggerImpl;\n properties: Record<string, unknown>;\n\n constructor(logger: LoggerImpl, properties: Record<string, unknown>) {\n this.logger = logger;\n this.properties = properties;\n }\n\n get category(): readonly string[] {\n return this.logger.category;\n }\n\n get parent(): Logger | null {\n return this.logger.parent;\n }\n\n getChild(\n subcategory: string | readonly [string] | readonly [string, ...string[]],\n ): Logger {\n return this.logger.getChild(subcategory).with(this.properties);\n }\n\n with(properties: Record<string, unknown>): Logger {\n return new LoggerCtx(this.logger, { ...this.properties, ...properties });\n }\n\n log(\n level: LogLevel,\n message: string,\n properties: Record<string, unknown> | (() => Record<string, unknown>),\n bypassSinks?: Set<Sink>,\n ): void {\n const contextProps = this.properties;\n this.logger.log(\n level,\n message,\n typeof properties === \"function\"\n ? () =>\n resolveProperties({\n ...contextProps,\n ...properties(),\n })\n : () => resolveProperties({ ...contextProps, ...properties }),\n bypassSinks,\n );\n }\n\n logLazily(level: LogLevel, callback: LogCallback): void {\n this.logger.logLazily(level, callback, resolveProperties(this.properties));\n }\n\n logTemplate(\n level: LogLevel,\n messageTemplate: TemplateStringsArray,\n values: unknown[],\n ): void {\n this.logger.logTemplate(\n level,\n messageTemplate,\n values,\n resolveProperties(this.properties),\n );\n }\n\n emit(record: Omit<LogRecord, \"category\">): void {\n const recordWithContext = {\n ...record,\n properties: resolveProperties({\n ...this.properties,\n ...record.properties,\n }),\n };\n this.logger.emit(recordWithContext);\n }\n\n isEnabledFor(level: LogLevel): boolean {\n return this.logger.isEnabledFor(level);\n }\n\n trace(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n trace(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n trace(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n trace(properties: Record<string, unknown>): void;\n trace(callback: LogCallback): void;\n trace(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void | Promise<void> {\n if (typeof message === \"string\") {\n return logStringMessage(this, \"trace\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"trace\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"trace\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"trace\", message as TemplateStringsArray, values);\n }\n }\n\n debug(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n debug(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n debug(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n debug(properties: Record<string, unknown>): void;\n debug(callback: LogCallback): void;\n debug(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void | Promise<void> {\n if (typeof message === \"string\") {\n return logStringMessage(this, \"debug\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"debug\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"debug\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"debug\", message as TemplateStringsArray, values);\n }\n }\n\n info(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n info(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n info(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n info(properties: Record<string, unknown>): void;\n info(callback: LogCallback): void;\n info(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void | Promise<void> {\n if (typeof message === \"string\") {\n return logStringMessage(this, \"info\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"info\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"info\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"info\", message as TemplateStringsArray, values);\n }\n }\n\n private logError(\n level: \"warning\" | \"error\" | \"fatal\",\n error: Error,\n props?: unknown,\n ): void | Promise<void> {\n if (typeof props !== \"function\") {\n this.log(level, \"{error.message}\", {\n ...(props as Record<string, unknown>),\n error,\n });\n return;\n }\n\n if (!this.isEnabledFor(level)) return Promise.resolve();\n\n const result = (props as () =>\n | Record<string, unknown>\n | Promise<Record<string, unknown>>)();\n\n if (result instanceof Promise) {\n return result.then((resolved) => {\n this.log(level, \"{error.message}\", { ...resolved, error });\n });\n }\n\n this.log(level, \"{error.message}\", { ...result, error });\n }\n\n warn(error: Error): void;\n warn(\n error: Error,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n warn(\n error: Error,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n warn(message: string, error: Error): void;\n warn(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n warn(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n warn(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n warn(properties: Record<string, unknown>): void;\n warn(callback: LogCallback): void;\n warn(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error,\n ...values: unknown[]\n ): void | Promise<void> {\n if (message instanceof Error) {\n return this.logError(\"warning\", message, values[0]);\n } else if (typeof message === \"string\" && values[0] instanceof Error) {\n this.log(\"warning\", message, { error: values[0] });\n } else if (typeof message === \"string\") {\n return logStringMessage(this, \"warning\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"warning\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"warning\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"warning\", message as TemplateStringsArray, values);\n }\n }\n\n warning(error: Error): void;\n warning(\n error: Error,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n warning(\n error: Error,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n warning(message: string, error: Error): void;\n warning(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n warning(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n warning(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n warning(properties: Record<string, unknown>): void;\n warning(callback: LogCallback): void;\n warning(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error,\n ...values: unknown[]\n ): void | Promise<void> {\n if (message instanceof Error) {\n return this.logError(\"warning\", message, values[0]);\n } else if (typeof message === \"string\" && values[0] instanceof Error) {\n this.log(\"warning\", message, { error: values[0] });\n } else if (typeof message === \"string\") {\n return logStringMessage(this, \"warning\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"warning\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"warning\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"warning\", message as TemplateStringsArray, values);\n }\n }\n\n error(error: Error): void;\n error(\n error: Error,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n error(\n error: Error,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n error(message: string, error: Error): void;\n error(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n error(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n error(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n error(properties: Record<string, unknown>): void;\n error(callback: LogCallback): void;\n error(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error,\n ...values: unknown[]\n ): void | Promise<void> {\n if (message instanceof Error) {\n return this.logError(\"error\", message, values[0]);\n } else if (typeof message === \"string\" && values[0] instanceof Error) {\n this.log(\"error\", message, { error: values[0] });\n } else if (typeof message === \"string\") {\n return logStringMessage(this, \"error\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"error\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"error\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"error\", message as TemplateStringsArray, values);\n }\n }\n\n fatal(error: Error): void;\n fatal(\n error: Error,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n fatal(\n error: Error,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n fatal(message: string, error: Error): void;\n fatal(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n fatal(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n fatal(\n message: string,\n properties: () => Promise<Record<string, unknown>>,\n ): Promise<void>;\n fatal(properties: Record<string, unknown>): void;\n fatal(callback: LogCallback): void;\n fatal(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error,\n ...values: unknown[]\n ): void | Promise<void> {\n if (message instanceof Error) {\n return this.logError(\"fatal\", message, values[0]);\n } else if (typeof message === \"string\" && values[0] instanceof Error) {\n this.log(\"fatal\", message, { error: values[0] });\n } else if (typeof message === \"string\") {\n return logStringMessage(this, \"fatal\", message, values[0]);\n } else if (typeof message === \"function\") {\n this.logLazily(\"fatal\", message);\n } else if (!Array.isArray(message)) {\n this.log(\"fatal\", \"{*}\", message as Record<string, unknown>);\n } else {\n this.logTemplate(\"fatal\", message as TemplateStringsArray, values);\n }\n }\n}\n\n/**\n * The meta logger. It is a logger with the category `[\"logtape\", \"meta\"]`.\n */\nconst metaLogger = LoggerImpl.getLogger([\"logtape\", \"meta\"]);\n\n/**\n * Check if a property access key contains nested access patterns.\n * @param key The property key to check.\n * @returns True if the key contains nested access patterns.\n */\nfunction isNestedAccess(key: string): boolean {\n return key.includes(\".\") || key.includes(\"[\") || key.includes(\"?.\");\n}\n\n/**\n * Safely access an own property from an object, blocking prototype pollution.\n *\n * @param obj The object to access the property from.\n * @param key The property key to access.\n * @returns The property value or undefined if not accessible.\n */\nfunction getOwnProperty(obj: unknown, key: string): unknown {\n // Block dangerous prototype keys\n if (key === \"__proto__\" || key === \"prototype\" || key === \"constructor\") {\n return undefined;\n }\n\n if ((typeof obj === \"object\" || typeof obj === \"function\") && obj !== null) {\n return Object.prototype.hasOwnProperty.call(obj, key)\n ? (obj as Record<string, unknown>)[key]\n : undefined;\n }\n\n return undefined;\n}\n\n/**\n * Result of parsing a single segment from a property path.\n */\ninterface ParseSegmentResult {\n segment: string | number;\n nextIndex: number;\n}\n\n/**\n * Parse the next segment from a property path string.\n *\n * @param path The full property path string.\n * @param fromIndex The index to start parsing from.\n * @returns The parsed segment and next index, or null if parsing fails.\n */\nfunction parseNextSegment(\n path: string,\n fromIndex: number,\n): ParseSegmentResult | null {\n const len = path.length;\n let i = fromIndex;\n\n if (i >= len) return null;\n\n let segment: string | number;\n\n if (path[i] === \"[\") {\n // Bracket notation: [0] or [\"prop\"]\n i++;\n if (i >= len) return null;\n\n if (path[i] === '\"' || path[i] === \"'\") {\n // Quoted property name: [\"prop-name\"]\n const quote = path[i];\n i++;\n // Build segment with proper escape handling\n let segmentStr = \"\";\n while (i < len && path[i] !== quote) {\n if (path[i] === \"\\\\\") {\n i++; // Skip backslash\n if (i < len) {\n // Handle escape sequences according to JavaScript spec\n const escapeChar = path[i];\n switch (escapeChar) {\n case \"n\":\n segmentStr += \"\\n\";\n break;\n case \"t\":\n segmentStr += \"\\t\";\n break;\n case \"r\":\n segmentStr += \"\\r\";\n break;\n case \"b\":\n segmentStr += \"\\b\";\n break;\n case \"f\":\n segmentStr += \"\\f\";\n break;\n case \"v\":\n segmentStr += \"\\v\";\n break;\n case \"0\":\n segmentStr += \"\\0\";\n break;\n case \"\\\\\":\n segmentStr += \"\\\\\";\n break;\n case '\"':\n segmentStr += '\"';\n break;\n case \"'\":\n segmentStr += \"'\";\n break;\n case \"u\":\n // Unicode escape: \\uXXXX\n if (i + 4 < len) {\n const hex = path.slice(i + 1, i + 5);\n const codePoint = Number.parseInt(hex, 16);\n if (!Number.isNaN(codePoint)) {\n segmentStr += String.fromCharCode(codePoint);\n i += 4; // Skip the 4 hex digits\n } else {\n // Invalid unicode escape, keep as-is\n segmentStr += escapeChar;\n }\n } else {\n // Not enough characters for unicode escape\n segmentStr += escapeChar;\n }\n break;\n default:\n // For any other character after \\, just add it as-is\n segmentStr += escapeChar;\n }\n i++;\n }\n } else {\n segmentStr += path[i];\n i++;\n }\n }\n if (i >= len) return null;\n segment = segmentStr;\n i++; // Skip closing quote\n } else {\n // Array index: [0]\n const startIndex = i;\n while (\n i < len && path[i] !== \"]\" && path[i] !== \"'\" && path[i] !== '\"'\n ) {\n i++;\n }\n if (i >= len) return null;\n const indexStr = path.slice(startIndex, i);\n // Empty bracket is invalid\n if (indexStr.length === 0) return null;\n const indexNum = Number(indexStr);\n segment = Number.isNaN(indexNum) ? indexStr : indexNum;\n }\n\n // Skip closing bracket\n while (i < len && path[i] !== \"]\") i++;\n if (i < len) i++;\n } else {\n // Dot notation: prop\n const startIndex = i;\n while (\n i < len && path[i] !== \".\" && path[i] !== \"[\" && path[i] !== \"?\" &&\n path[i] !== \"]\"\n ) {\n i++;\n }\n segment = path.slice(startIndex, i);\n // Empty segment is invalid (e.g., leading dot, double dot, trailing dot)\n if (segment.length === 0) return null;\n }\n\n // Skip dot separator\n if (i < len && path[i] === \".\") i++;\n\n return { segment, nextIndex: i };\n}\n\n/**\n * Access a property or index on an object or array.\n *\n * @param obj The object or array to access.\n * @param segment The property key or array index.\n * @returns The accessed value or undefined if not accessible.\n */\nfunction accessProperty(obj: unknown, segment: string | number): unknown {\n if (typeof segment === \"string\") {\n return getOwnProperty(obj, segment);\n }\n\n // Numeric index for arrays\n if (Array.isArray(obj) && segment >= 0 && segment < obj.length) {\n return obj[segment];\n }\n\n return undefined;\n}\n\n/**\n * Resolve a nested property path from an object.\n *\n * There are two types of property access patterns:\n * 1. Array/index access: [0] or [\"prop\"]\n * 2. Property access: prop or prop?.next\n *\n * @param obj The object to traverse.\n * @param path The property path (e.g., \"user.name\", \"users[0].email\", \"user['full-name']\").\n * @returns The resolved value or undefined if path doesn't exist.\n */\nfunction resolvePropertyPath(obj: unknown, path: string): unknown {\n if (obj == null) return undefined;\n\n // Check for invalid paths\n if (path.length === 0 || path.endsWith(\".\")) return undefined;\n\n let current: unknown = obj;\n let i = 0;\n const len = path.length;\n\n while (i < len) {\n // Handle optional chaining\n const isOptional = path.slice(i, i + 2) === \"?.\";\n if (isOptional) {\n i += 2;\n if (current == null) return undefined;\n } else if (current == null) {\n return undefined;\n }\n\n // Parse the next segment\n const result = parseNextSegment(path, i);\n if (result === null) return undefined;\n\n const { segment, nextIndex } = result;\n i = nextIndex;\n\n // Access the property/index\n current = accessProperty(current, segment);\n if (current === undefined) {\n return undefined;\n }\n }\n\n return current;\n}\n\n/**\n * Parse a message template into a message template array and a values array.\n *\n * Placeholders to be replaced with `values` are indicated by keys in curly braces\n * (e.g., `{value}`). The system supports both simple property access and nested\n * property access patterns:\n *\n * **Simple property access:**\n * ```ts\n * parseMessageTemplate(\"Hello, {user}!\", { user: \"foo\" })\n * // Returns: [\"Hello, \", \"foo\", \"!\"]\n * ```\n *\n * **Nested property access (dot notation):**\n * ```ts\n * parseMessageTemplate(\"Hello, {user.name}!\", {\n * user: { name: \"foo\", email: \"foo@example.com\" }\n * })\n * // Returns: [\"Hello, \", \"foo\", \"!\"]\n * ```\n *\n * **Array indexing:**\n * ```ts\n * parseMessageTemplate(\"First: {users[0]}\", {\n * users: [\"foo\", \"bar\", \"baz\"]\n * })\n * // Returns: [\"First: \", \"foo\", \"\"]\n * ```\n *\n * **Bracket notation for special property names:**\n * ```ts\n * parseMessageTemplate(\"Name: {user[\\\"full-name\\\"]}\", {\n * user: { \"full-name\": \"foo bar\" }\n * })\n * // Returns: [\"Name: \", \"foo bar\", \"\"]\n * ```\n *\n * **Optional chaining for safe navigation:**\n * ```ts\n * parseMessageTemplate(\"Email: {user?.profile?.email}\", {\n * user: { name: \"foo\" }\n * })\n * // Returns: [\"Email: \", undefined, \"\"]\n * ```\n *\n * **Wildcard patterns:**\n * - `{*}` - Replaced with the entire properties object\n * - `{ key-with-whitespace }` - Whitespace is trimmed when looking up keys\n *\n * **Escaping:**\n * - `{{` and `}}` are escaped literal braces\n *\n * **Error handling:**\n * - Non-existent paths return `undefined`\n * - Malformed expressions resolve to `undefined` without throwing errors\n * - Out of bounds array access returns `undefined`\n *\n * @param template The message template string containing placeholders.\n * @param properties The values to replace placeholders with.\n * @returns The message template array with values interleaved between text segments.\n */\nexport function parseMessageTemplate(\n template: string,\n properties: Record<string, unknown>,\n): readonly unknown[] {\n const length = template.length;\n if (length === 0) return [\"\"];\n\n // Fast path: no placeholders\n if (!template.includes(\"{\")) return [template];\n\n const message: unknown[] = [];\n let startIndex = 0;\n\n for (let i = 0; i < length; i++) {\n const char = template[i];\n\n if (char === \"{\") {\n const nextChar = i + 1 < length ? template[i + 1] : \"\";\n\n if (nextChar === \"{\") {\n // Escaped { character - skip and continue\n i++; // Skip the next {\n continue;\n }\n\n // Find the closing }\n const closeIndex = template.indexOf(\"}\", i + 1);\n if (closeIndex === -1) {\n // No closing } found, treat as literal text\n continue;\n }\n\n // Add text before placeholder\n const beforeText = template.slice(startIndex, i);\n message.push(beforeText.replace(/{{/g, \"{\").replace(/}}/g, \"}\"));\n\n // Extract and process placeholder key\n const key = template.slice(i + 1, closeIndex);\n\n // Resolve property value\n let prop: unknown;\n\n // Check for wildcard patterns\n const trimmedKey = key.trim();\n if (trimmedKey === \"*\") {\n // This is a wildcard pattern\n prop = key in properties\n ? properties[key]\n : \"*\" in properties\n ? properties[\"*\"]\n : properties;\n } else {\n // Regular property lookup with possible whitespace handling\n if (key !== trimmedKey) {\n // Key has leading/trailing whitespace\n prop = key in properties ? properties[key] : properties[trimmedKey];\n } else {\n // Key has no leading/trailing whitespace\n prop = properties[key];\n }\n\n // If property not found directly and this looks like nested access, try nested resolution\n if (prop === undefined && isNestedAccess(trimmedKey)) {\n prop = resolvePropertyPath(properties, trimmedKey);\n }\n }\n\n message.push(prop);\n i = closeIndex; // Move to the }\n startIndex = i + 1;\n } else if (char === \"}\" && i + 1 < length && template[i + 1] === \"}\") {\n // Escaped } character - skip\n i++; // Skip the next }\n }\n }\n\n // Add remaining text\n const remainingText = template.slice(startIndex);\n message.push(remainingText.replace(/{{/g, \"{\").replace(/}}/g, \"}\"));\n\n return message;\n}\n\n/**\n * Render a message template with values.\n * @param template The message template.\n * @param values The message template values.\n * @returns The message template values interleaved between the substitution\n * values.\n */\nexport function renderMessage(\n template: TemplateStringsArray,\n values: readonly unknown[],\n): unknown[] {\n const args = [];\n for (let i = 0; i < template.length; i++) {\n args.push(template[i]);\n if (i < values.length) args.push(values[i]);\n }\n return args;\n}\n"],"mappings":";;;;;;;;AAkBA,MAAMA,aAA4B,OAAO,IAAI,eAAe;AAC5D,MAAM,gCAAgC,OAAO,IAC3C,kCACD;AACD,MAAM,sBAAsB,OAAO,IACjC,uCACD;AACD,MAAMC,2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AAI,IAAI,UAAU,SAAS,IAAI,OAAO,IAE/D;CAEH;CAGD,MAAM,gBAAgB,SAAS,MAAM,WAAW;AAChD,SAAQ,KAAK,cAAc,QAAQ,OAAO,IAAI,CAAC,QAAQ,OAAO,IAAI,CAAC;AAEnE,QAAO;AACR;;;;;;;;AASD,SAAgB,cACdC,UACAC,QACW;CACX,MAAM,OAAO,CAAE;AACf,MAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;AACxC,OAAK,KAAK,SAAS,GAAG;AACtB,MAAI,IAAI,OAAO,OAAQ,MAAK,KAAK,OAAO,GAAG;CAC5C;AACD,QAAO;AACR"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logtape/logtape",
3
- "version": "2.3.0-dev.793+68821ae3",
3
+ "version": "2.3.0-dev.795+50e33c4d",
4
4
  "description": "Unobtrusive logging library with zero dependencies—library-first design for Deno/Node.js/Bun/browsers/edge",
5
5
  "keywords": [
6
6
  "logging",