@logtape/logtape 0.13.0-dev.205 → 1.0.0-dev.207
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/config.test.ts +0 -2
- package/config.ts +0 -21
- package/deno.json +1 -1
- package/dist/config.cjs +0 -6
- package/dist/config.d.cts +0 -7
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.ts +0 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +0 -6
- package/dist/config.js.map +1 -1
- package/dist/level.cjs +1 -1
- package/dist/level.d.cts +1 -1
- package/dist/level.d.ts +1 -1
- package/dist/level.js +1 -1
- package/dist/level.js.map +1 -1
- package/dist/logger.d.cts +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/logger.js.map +1 -1
- package/level.ts +1 -1
- package/logger.ts +1 -1
- package/package.json +1 -1
package/config.test.ts
CHANGED
|
@@ -60,7 +60,6 @@ test("configure()", async () => {
|
|
|
60
60
|
category: ["my-app", "bar"],
|
|
61
61
|
sinks: ["c"],
|
|
62
62
|
filters: ["debug"],
|
|
63
|
-
level: "info", // deprecated
|
|
64
63
|
lowestLevel: "info",
|
|
65
64
|
},
|
|
66
65
|
],
|
|
@@ -322,7 +321,6 @@ test("configureSync()", async () => {
|
|
|
322
321
|
category: ["my-app", "bar"],
|
|
323
322
|
sinks: ["c"],
|
|
324
323
|
filters: ["debug"],
|
|
325
|
-
level: "info", // deprecated
|
|
326
324
|
lowestLevel: "info",
|
|
327
325
|
},
|
|
328
326
|
],
|
package/config.ts
CHANGED
|
@@ -70,14 +70,6 @@ export interface LoggerConfig<
|
|
|
70
70
|
*/
|
|
71
71
|
filters?: TFilterId[];
|
|
72
72
|
|
|
73
|
-
/**
|
|
74
|
-
* The log level to filter by. If `null`, the logger will reject all
|
|
75
|
-
* records.
|
|
76
|
-
* @deprecated Use `filters` instead for backward compatibility, or use
|
|
77
|
-
* `lowestLevel` for less-misleading behavior.
|
|
78
|
-
*/
|
|
79
|
-
level?: LogLevel | null;
|
|
80
|
-
|
|
81
73
|
/**
|
|
82
74
|
* The lowest log level to accept. If `null`, the logger will reject all
|
|
83
75
|
* records.
|
|
@@ -241,7 +233,6 @@ function configureInternal<
|
|
|
241
233
|
currentConfig = config;
|
|
242
234
|
|
|
243
235
|
let metaConfigured = false;
|
|
244
|
-
let levelUsed = false;
|
|
245
236
|
const configuredCategories = new Set<string>();
|
|
246
237
|
|
|
247
238
|
for (const cfg of config.loggers) {
|
|
@@ -273,10 +264,6 @@ function configureInternal<
|
|
|
273
264
|
if (cfg.lowestLevel !== undefined) {
|
|
274
265
|
logger.lowestLevel = cfg.lowestLevel;
|
|
275
266
|
}
|
|
276
|
-
if (cfg.level !== undefined) {
|
|
277
|
-
levelUsed = true;
|
|
278
|
-
logger.filters.push(toFilter(cfg.level));
|
|
279
|
-
}
|
|
280
267
|
for (const filterId of cfg.filters ?? []) {
|
|
281
268
|
const filter = config.filters?.[filterId];
|
|
282
269
|
if (filter === undefined) {
|
|
@@ -339,14 +326,6 @@ function configureInternal<
|
|
|
339
326
|
"<https://logtape.org/manual/categories#meta-logger>.",
|
|
340
327
|
{ metaLoggerCategory: ["logtape", "meta"], dismissLevel: "info" },
|
|
341
328
|
);
|
|
342
|
-
|
|
343
|
-
if (levelUsed) {
|
|
344
|
-
meta.warn(
|
|
345
|
-
"The level option is deprecated in favor of lowestLevel option. " +
|
|
346
|
-
"Please update your configuration. See also " +
|
|
347
|
-
"<https://logtape.org/manual/levels#configuring-severity-levels>.",
|
|
348
|
-
);
|
|
349
|
-
}
|
|
350
329
|
}
|
|
351
330
|
|
|
352
331
|
/**
|
package/deno.json
CHANGED
package/dist/config.cjs
CHANGED
|
@@ -123,7 +123,6 @@ function configureSync(config) {
|
|
|
123
123
|
function configureInternal(config, allowAsync) {
|
|
124
124
|
currentConfig = config;
|
|
125
125
|
let metaConfigured = false;
|
|
126
|
-
let levelUsed = false;
|
|
127
126
|
const configuredCategories = /* @__PURE__ */ new Set();
|
|
128
127
|
for (const cfg of config.loggers) {
|
|
129
128
|
if (isLoggerConfigMeta(cfg)) metaConfigured = true;
|
|
@@ -138,10 +137,6 @@ function configureInternal(config, allowAsync) {
|
|
|
138
137
|
}
|
|
139
138
|
logger.parentSinks = cfg.parentSinks ?? "inherit";
|
|
140
139
|
if (cfg.lowestLevel !== void 0) logger.lowestLevel = cfg.lowestLevel;
|
|
141
|
-
if (cfg.level !== void 0) {
|
|
142
|
-
levelUsed = true;
|
|
143
|
-
logger.filters.push(require_filter.toFilter(cfg.level));
|
|
144
|
-
}
|
|
145
140
|
for (const filterId of cfg.filters ?? []) {
|
|
146
141
|
const filter = config.filters?.[filterId];
|
|
147
142
|
if (filter === void 0) throw new ConfigError(`Filter not found: ${filterId}.`);
|
|
@@ -169,7 +164,6 @@ function configureInternal(config, allowAsync) {
|
|
|
169
164
|
metaLoggerCategory: ["logtape", "meta"],
|
|
170
165
|
dismissLevel: "info"
|
|
171
166
|
});
|
|
172
|
-
if (levelUsed) meta.warn("The level option is deprecated in favor of lowestLevel option. Please update your configuration. See also <https://logtape.org/manual/levels#configuring-severity-levels>.");
|
|
173
167
|
}
|
|
174
168
|
/**
|
|
175
169
|
* Get the current configuration, if any. Otherwise, `null`.
|
package/dist/config.d.cts
CHANGED
|
@@ -60,13 +60,6 @@ interface LoggerConfig<TSinkId extends string, TFilterId extends string> {
|
|
|
60
60
|
* The filter identifiers to use.
|
|
61
61
|
*/
|
|
62
62
|
filters?: TFilterId[];
|
|
63
|
-
/**
|
|
64
|
-
* The log level to filter by. If `null`, the logger will reject all
|
|
65
|
-
* records.
|
|
66
|
-
* @deprecated Use `filters` instead for backward compatibility, or use
|
|
67
|
-
* `lowestLevel` for less-misleading behavior.
|
|
68
|
-
*/
|
|
69
|
-
level?: LogLevel | null;
|
|
70
63
|
/**
|
|
71
64
|
* The lowest log level to accept. If `null`, the logger will reject all
|
|
72
65
|
* records.
|
package/dist/config.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.cts","names":[],"sources":["../config.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AASA;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;AAW3C;EAA6B,OAAA,EAjBlB,YAiBkB,CAjBL,OAiBK,EAjBI,SAiBJ,CAAA,EAAA;EAAA
|
|
1
|
+
{"version":3,"file":"config.d.cts","names":[],"sources":["../config.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AASA;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;AAW3C;EAA6B,OAAA,EAjBlB,YAiBkB,CAjBL,OAiBK,EAjBI,SAiBJ,CAAA,EAAA;EAAA;;;AAoCL;EA6EF,mBAAS,CAAA,EA5HP,mBA4HO,CA5Ha,MA4Hb,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA;EAAA;;;EAGI,KAAzB,CAAA,EAAA,OAAA;;AAAoC;AAgD9C;;AACiB,UArKA,YAqKA,CAAA,gBAAA,MAAA,EAAA,kBAAA,MAAA,CAAA,CAAA;EAAO;;AAAR;AAgIhB;EAOsB,QAAK,EAAA,MAAA,GAAI,MAAA,EAAO;EAUtB;AAgBhB;AAeA;EAQa,KAAA,CAAA,EAhVH,OAgVe,EAAA;;;;;;;;;;;;;;YAhUb;;;;;;gBAOI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6EM,oEAGZ,OAAO,SAAS,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgDvB,wEACN,OAAO,SAAS;;;;;iBAgIV,SAAA,CAAA,GAAa;;;;iBAOP,KAAA,CAAA,GAAS;;;;;;iBAUf,SAAA,CAAA;;;;iBAgBM,OAAA,CAAA,GAAW;;;;;;iBAejB,WAAA,CAAA;;;;cAQH,WAAA,SAAoB,KAAK"}
|
package/dist/config.d.ts
CHANGED
|
@@ -60,13 +60,6 @@ interface LoggerConfig<TSinkId extends string, TFilterId extends string> {
|
|
|
60
60
|
* The filter identifiers to use.
|
|
61
61
|
*/
|
|
62
62
|
filters?: TFilterId[];
|
|
63
|
-
/**
|
|
64
|
-
* The log level to filter by. If `null`, the logger will reject all
|
|
65
|
-
* records.
|
|
66
|
-
* @deprecated Use `filters` instead for backward compatibility, or use
|
|
67
|
-
* `lowestLevel` for less-misleading behavior.
|
|
68
|
-
*/
|
|
69
|
-
level?: LogLevel | null;
|
|
70
63
|
/**
|
|
71
64
|
* The lowest log level to accept. If `null`, the logger will reject all
|
|
72
65
|
* records.
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","names":[],"sources":["../config.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AASA;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;AAW3C;EAA6B,OAAA,EAjBlB,YAiBkB,CAjBL,OAiBK,EAjBI,SAiBJ,CAAA,EAAA;EAAA
|
|
1
|
+
{"version":3,"file":"config.d.ts","names":[],"sources":["../config.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AASA;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;AAW3C;EAA6B,OAAA,EAjBlB,YAiBkB,CAjBL,OAiBK,EAjBI,SAiBJ,CAAA,EAAA;EAAA;;;AAoCL;EA6EF,mBAAS,CAAA,EA5HP,mBA4HO,CA5Ha,MA4Hb,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA;EAAA;;;EAGI,KAAzB,CAAA,EAAA,OAAA;;AAAoC;AAgD9C;;AACiB,UArKA,YAqKA,CAAA,gBAAA,MAAA,EAAA,kBAAA,MAAA,CAAA,CAAA;EAAO;;AAAR;AAgIhB;EAOsB,QAAK,EAAA,MAAA,GAAI,MAAA,EAAO;EAUtB;AAgBhB;AAeA;EAQa,KAAA,CAAA,EAhVH,OAgVe,EAAA;;;;;;;;;;;;;;YAhUb;;;;;;gBAOI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6EM,oEAGZ,OAAO,SAAS,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgDvB,wEACN,OAAO,SAAS;;;;;iBAgIV,SAAA,CAAA,GAAa;;;;iBAOP,KAAA,CAAA,GAAS;;;;;;iBAUf,SAAA,CAAA;;;;iBAgBM,OAAA,CAAA,GAAW;;;;;;iBAejB,WAAA,CAAA;;;;cAQH,WAAA,SAAoB,KAAK"}
|
package/dist/config.js
CHANGED
|
@@ -123,7 +123,6 @@ function configureSync(config) {
|
|
|
123
123
|
function configureInternal(config, allowAsync) {
|
|
124
124
|
currentConfig = config;
|
|
125
125
|
let metaConfigured = false;
|
|
126
|
-
let levelUsed = false;
|
|
127
126
|
const configuredCategories = /* @__PURE__ */ new Set();
|
|
128
127
|
for (const cfg of config.loggers) {
|
|
129
128
|
if (isLoggerConfigMeta(cfg)) metaConfigured = true;
|
|
@@ -138,10 +137,6 @@ function configureInternal(config, allowAsync) {
|
|
|
138
137
|
}
|
|
139
138
|
logger.parentSinks = cfg.parentSinks ?? "inherit";
|
|
140
139
|
if (cfg.lowestLevel !== void 0) logger.lowestLevel = cfg.lowestLevel;
|
|
141
|
-
if (cfg.level !== void 0) {
|
|
142
|
-
levelUsed = true;
|
|
143
|
-
logger.filters.push(toFilter(cfg.level));
|
|
144
|
-
}
|
|
145
140
|
for (const filterId of cfg.filters ?? []) {
|
|
146
141
|
const filter = config.filters?.[filterId];
|
|
147
142
|
if (filter === void 0) throw new ConfigError(`Filter not found: ${filterId}.`);
|
|
@@ -169,7 +164,6 @@ function configureInternal(config, allowAsync) {
|
|
|
169
164
|
metaLoggerCategory: ["logtape", "meta"],
|
|
170
165
|
dismissLevel: "info"
|
|
171
166
|
});
|
|
172
|
-
if (levelUsed) meta.warn("The level option is deprecated in favor of lowestLevel option. Please update your configuration. See also <https://logtape.org/manual/levels#configuring-severity-levels>.");
|
|
173
167
|
}
|
|
174
168
|
/**
|
|
175
169
|
* Get the current configuration, if any. Otherwise, `null`.
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":["currentConfig: Config<string, string> | null","strongRefs: Set<LoggerImpl>","disposables: Set<Disposable>","asyncDisposables: Set<AsyncDisposable>","cfg: LoggerConfig<TSinkId, TFilterId>","config: Config<TSinkId, TFilterId>","allowAsync: boolean","promises: PromiseLike<void>[]","message: string"],"sources":["../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 { 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 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 log level to filter by. If `null`, the logger will reject all\n * records.\n * @deprecated Use `filters` instead for backward compatibility, or use\n * `lowestLevel` for less-misleading behavior.\n */\n level?: LogLevel | null;\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;\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 * Disposables to dispose when resetting the configuration.\n */\nconst disposables: Set<Disposable> = new Set();\n\n/**\n * Async disposables to dispose when resetting the configuration.\n */\nconst asyncDisposables: 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 return cfg.category.length === 0 ||\n (cfg.category.length === 1 && cfg.category[0] === \"logtape\") ||\n (cfg.category.length === 2 &&\n cfg.category[0] === \"logtape\" &&\n cfg.category[1] === \"meta\");\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 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 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 (asyncDisposables.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\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 let levelUsed = 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 if (cfg.level !== undefined) {\n levelUsed = true;\n logger.filters.push(toFilter(cfg.level));\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) asyncDisposables.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) disposables.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) asyncDisposables.add(filter as AsyncDisposable);\n else {\n throw new ConfigError(\n \"Async disposables cannot be used with configureSync().\",\n );\n }\n }\n if (Symbol.dispose in filter) disposables.add(filter as Disposable);\n }\n\n if (\"process\" in globalThis && !(\"Deno\" in globalThis)) {\n // @ts-ignore: It's fine to use process in Node\n // deno-lint-ignore no-process-global\n process.on(\"exit\", allowAsync ? dispose : disposeSync);\n } else {\n // @ts-ignore: It's fine to addEventListener() on the browser/Deno\n addEventListener(\"unload\", allowAsync ? dispose : disposeSync);\n }\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 \" +\n \"purposes to log internal errors such as sink exceptions. If you \" +\n \"are seeing this message, the meta logger is automatically configured. \" +\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 if (levelUsed) {\n meta.warn(\n \"The level option is deprecated in favor of lowestLevel option. \" +\n \"Please update your configuration. See also \" +\n \"<https://logtape.org/manual/levels#configuring-severity-levels>.\",\n );\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 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 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 disposeSync();\n const promises: PromiseLike<void>[] = [];\n for (const disposable of asyncDisposables) {\n promises.push(disposable[Symbol.asyncDispose]());\n asyncDisposables.delete(disposable);\n }\n await Promise.all(promises);\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 for (const disposable of disposables) disposable[Symbol.dispose]();\n disposables.clear();\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 = \"ConfigureError\";\n }\n}\n"],"mappings":";;;;;;;;AA2FA,IAAIA,gBAA+C;;;;;;AAOnD,MAAMC,6BAA8B,IAAI;;;;AAKxC,MAAMC,8BAA+B,IAAI;;;;AAKzC,MAAMC,mCAAyC,IAAI;;;;AAKnD,SAAS,mBACPC,KACS;AACT,QAAO,IAAI,SAAS,WAAW,KAC5B,IAAI,SAAS,WAAW,KAAK,IAAI,SAAS,OAAO,aACjD,IAAI,SAAS,WAAW,KACvB,IAAI,SAAS,OAAO,aACpB,IAAI,SAAS,OAAO;AACzB;;;;;;;;;;;;;;;;;;;;;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;;;AAOD,SAAgB,YAAkB;AAChC,cAAa;AACb,gBAAe;AAChB;AAED,SAAS,gBAAsB;CAC7B,MAAM,aAAa,WAAW,UAAU,CAAE,EAAC;AAC3C,YAAW,kBAAkB;AAC7B,QAAO,WAAW;AAClB,YAAW,OAAO;AAClB,iBAAgB;AACjB;;;;AAKD,eAAsB,UAAyB;AAC7C,cAAa;CACb,MAAMC,WAAgC,CAAE;AACxC,MAAK,MAAM,cAAc,kBAAkB;AACzC,WAAS,KAAK,WAAW,OAAO,eAAe,CAAC;AAChD,mBAAiB,OAAO,WAAW;CACpC;AACD,OAAM,QAAQ,IAAI,SAAS;AAC5B;;;;;;AAOD,SAAgB,cAAoB;AAClC,MAAK,MAAM,cAAc,YAAa,YAAW,OAAO,UAAU;AAClE,aAAY,OAAO;AACpB;;;;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>","disposables: Set<Disposable>","asyncDisposables: Set<AsyncDisposable>","cfg: LoggerConfig<TSinkId, TFilterId>","config: Config<TSinkId, TFilterId>","allowAsync: boolean","promises: PromiseLike<void>[]","message: string"],"sources":["../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 { 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 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;\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 * Disposables to dispose when resetting the configuration.\n */\nconst disposables: Set<Disposable> = new Set();\n\n/**\n * Async disposables to dispose when resetting the configuration.\n */\nconst asyncDisposables: 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 return cfg.category.length === 0 ||\n (cfg.category.length === 1 && cfg.category[0] === \"logtape\") ||\n (cfg.category.length === 2 &&\n cfg.category[0] === \"logtape\" &&\n cfg.category[1] === \"meta\");\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 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 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 (asyncDisposables.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\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) asyncDisposables.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) disposables.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) asyncDisposables.add(filter as AsyncDisposable);\n else {\n throw new ConfigError(\n \"Async disposables cannot be used with configureSync().\",\n );\n }\n }\n if (Symbol.dispose in filter) disposables.add(filter as Disposable);\n }\n\n if (\"process\" in globalThis && !(\"Deno\" in globalThis)) {\n // @ts-ignore: It's fine to use process in Node\n // deno-lint-ignore no-process-global\n process.on(\"exit\", allowAsync ? dispose : disposeSync);\n } else {\n // @ts-ignore: It's fine to addEventListener() on the browser/Deno\n addEventListener(\"unload\", allowAsync ? dispose : disposeSync);\n }\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 \" +\n \"purposes to log internal errors such as sink exceptions. If you \" +\n \"are seeing this message, the meta logger is automatically configured. \" +\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 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 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 disposeSync();\n const promises: PromiseLike<void>[] = [];\n for (const disposable of asyncDisposables) {\n promises.push(disposable[Symbol.asyncDispose]());\n asyncDisposables.delete(disposable);\n }\n await Promise.all(promises);\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 for (const disposable of disposables) disposable[Symbol.dispose]();\n disposables.clear();\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 = \"ConfigureError\";\n }\n}\n"],"mappings":";;;;;;;;AAmFA,IAAIA,gBAA+C;;;;;;AAOnD,MAAMC,6BAA8B,IAAI;;;;AAKxC,MAAMC,8BAA+B,IAAI;;;;AAKzC,MAAMC,mCAAyC,IAAI;;;;AAKnD,SAAS,mBACPC,KACS;AACT,QAAO,IAAI,SAAS,WAAW,KAC5B,IAAI,SAAS,WAAW,KAAK,IAAI,SAAS,OAAO,aACjD,IAAI,SAAS,WAAW,KACvB,IAAI,SAAS,OAAO,aACpB,IAAI,SAAS,OAAO;AACzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCD,eAAsB,UAGpBC,QAAmD;AACnD,KAAI,iBAAiB,SAAS,OAAO,MACnC,OAAM,IAAI,YACR;AAGJ,OAAM,OAAO;AACb,KAAI;AACF,oBAAkB,QAAQ,KAAK;CAChC,SAAQ,GAAG;AACV,MAAI,aAAa,YAAa,OAAM,OAAO;AAC3C,QAAM;CACP;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCD,SAAgB,cACdA,QACM;AACN,KAAI,iBAAiB,SAAS,OAAO,MACnC,OAAM,IAAI,YACR;AAGJ,KAAI,iBAAiB,OAAO,EAC1B,OAAM,IAAI,YACR;AAIJ,YAAW;AACX,KAAI;AACF,oBAAkB,QAAQ,MAA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"}
|
package/dist/level.cjs
CHANGED
|
@@ -12,7 +12,7 @@ const logLevels = [
|
|
|
12
12
|
* Lists all available log levels with the order of their severity.
|
|
13
13
|
* The `"trace"` level goes first, and the `"fatal"` level goes last.
|
|
14
14
|
* @returns A new copy of the array of log levels.
|
|
15
|
-
* @since 0.
|
|
15
|
+
* @since 1.0.0
|
|
16
16
|
*/
|
|
17
17
|
function getLogLevels() {
|
|
18
18
|
return [...logLevels];
|
package/dist/level.d.cts
CHANGED
|
@@ -8,7 +8,7 @@ type LogLevel = typeof logLevels[number];
|
|
|
8
8
|
* Lists all available log levels with the order of their severity.
|
|
9
9
|
* The `"trace"` level goes first, and the `"fatal"` level goes last.
|
|
10
10
|
* @returns A new copy of the array of log levels.
|
|
11
|
-
* @since 0.
|
|
11
|
+
* @since 1.0.0
|
|
12
12
|
*/
|
|
13
13
|
declare function getLogLevels(): readonly LogLevel[];
|
|
14
14
|
/**
|
package/dist/level.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ type LogLevel = typeof logLevels[number];
|
|
|
8
8
|
* Lists all available log levels with the order of their severity.
|
|
9
9
|
* The `"trace"` level goes first, and the `"fatal"` level goes last.
|
|
10
10
|
* @returns A new copy of the array of log levels.
|
|
11
|
-
* @since 0.
|
|
11
|
+
* @since 1.0.0
|
|
12
12
|
*/
|
|
13
13
|
declare function getLogLevels(): readonly LogLevel[];
|
|
14
14
|
/**
|
package/dist/level.js
CHANGED
|
@@ -11,7 +11,7 @@ const logLevels = [
|
|
|
11
11
|
* Lists all available log levels with the order of their severity.
|
|
12
12
|
* The `"trace"` level goes first, and the `"fatal"` level goes last.
|
|
13
13
|
* @returns A new copy of the array of log levels.
|
|
14
|
-
* @since 0.
|
|
14
|
+
* @since 1.0.0
|
|
15
15
|
*/
|
|
16
16
|
function getLogLevels() {
|
|
17
17
|
return [...logLevels];
|
package/dist/level.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"level.js","names":["level: string","a: LogLevel","b: LogLevel"],"sources":["../level.ts"],"sourcesContent":["const logLevels = [\n \"trace\",\n \"debug\",\n \"info\",\n \"warning\",\n \"error\",\n \"fatal\",\n] as const;\n\n/**\n * The severity level of a {@link LogRecord}.\n */\nexport type LogLevel = typeof logLevels[number];\n\n/**\n * Lists all available log levels with the order of their severity.\n * The `\"trace\"` level goes first, and the `\"fatal\"` level goes last.\n * @returns A new copy of the array of log levels.\n * @since 0.
|
|
1
|
+
{"version":3,"file":"level.js","names":["level: string","a: LogLevel","b: LogLevel"],"sources":["../level.ts"],"sourcesContent":["const logLevels = [\n \"trace\",\n \"debug\",\n \"info\",\n \"warning\",\n \"error\",\n \"fatal\",\n] as const;\n\n/**\n * The severity level of a {@link LogRecord}.\n */\nexport type LogLevel = typeof logLevels[number];\n\n/**\n * Lists all available log levels with the order of their severity.\n * The `\"trace\"` level goes first, and the `\"fatal\"` level goes last.\n * @returns A new copy of the array of log levels.\n * @since 1.0.0\n */\nexport function getLogLevels(): readonly LogLevel[] {\n return [...logLevels];\n}\n\n/**\n * Parses a log level from a string.\n *\n * @param level The log level as a string. This is case-insensitive.\n * @returns The log level.\n * @throws {TypeError} If the log level is invalid.\n */\nexport function parseLogLevel(level: string): LogLevel {\n level = level.toLowerCase();\n switch (level) {\n case \"trace\":\n case \"debug\":\n case \"info\":\n case \"warning\":\n case \"error\":\n case \"fatal\":\n return level;\n default:\n throw new TypeError(`Invalid log level: ${level}.`);\n }\n}\n\n/**\n * Checks if a string is a valid log level. This function can be used as\n * as a type guard to narrow the type of a string to a {@link LogLevel}.\n *\n * @param level The log level as a string. This is case-sensitive.\n * @returns `true` if the string is a valid log level.\n */\nexport function isLogLevel(level: string): level is LogLevel {\n switch (level) {\n case \"trace\":\n case \"debug\":\n case \"info\":\n case \"warning\":\n case \"error\":\n case \"fatal\":\n return true;\n default:\n return false;\n }\n}\n\n/**\n * Compares two log levels.\n * @param a The first log level.\n * @param b The second log level.\n * @returns A negative number if `a` is less than `b`, a positive number if `a`\n * is greater than `b`, or zero if they are equal.\n * @since 0.8.0\n */\nexport function compareLogLevel(a: LogLevel, b: LogLevel): number {\n const aIndex = logLevels.indexOf(a);\n if (aIndex < 0) {\n throw new TypeError(`Invalid log level: ${JSON.stringify(a)}.`);\n }\n const bIndex = logLevels.indexOf(b);\n if (bIndex < 0) {\n throw new TypeError(`Invalid log level: ${JSON.stringify(b)}.`);\n }\n return aIndex - bIndex;\n}\n"],"mappings":";AAAA,MAAM,YAAY;CAChB;CACA;CACA;CACA;CACA;CACA;AACD;;;;;;;AAaD,SAAgB,eAAoC;AAClD,QAAO,CAAC,GAAG,SAAU;AACtB;;;;;;;;AASD,SAAgB,cAAcA,OAAyB;AACrD,SAAQ,MAAM,aAAa;AAC3B,SAAQ,OAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,QACH,QAAO;EACT,QACE,OAAM,IAAI,WAAW,qBAAqB,MAAM;CACnD;AACF;;;;;;;;AASD,SAAgB,WAAWA,OAAkC;AAC3D,SAAQ,OAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,QACH,QAAO;EACT,QACE,QAAO;CACV;AACF;;;;;;;;;AAUD,SAAgB,gBAAgBC,GAAaC,GAAqB;CAChE,MAAM,SAAS,UAAU,QAAQ,EAAE;AACnC,KAAI,SAAS,EACX,OAAM,IAAI,WAAW,qBAAqB,KAAK,UAAU,EAAE,CAAC;CAE9D,MAAM,SAAS,UAAU,QAAQ,EAAE;AACnC,KAAI,SAAS,EACX,OAAM,IAAI,WAAW,qBAAqB,KAAK,UAAU,EAAE,CAAC;AAE9D,QAAO,SAAS;AACjB"}
|
package/dist/logger.d.cts
CHANGED
|
@@ -645,7 +645,7 @@ type LogCallback = (prefix: LogTemplatePrefix) => unknown[];
|
|
|
645
645
|
type LogTemplatePrefix = (message: TemplateStringsArray, ...values: unknown[]) => unknown[];
|
|
646
646
|
/**
|
|
647
647
|
* A function type for logging methods in the {@link Logger} interface.
|
|
648
|
-
* @since 0.
|
|
648
|
+
* @since 1.0.0
|
|
649
649
|
*/
|
|
650
650
|
interface LogMethod {
|
|
651
651
|
/**
|
package/dist/logger.d.ts
CHANGED
|
@@ -645,7 +645,7 @@ type LogCallback = (prefix: LogTemplatePrefix) => unknown[];
|
|
|
645
645
|
type LogTemplatePrefix = (message: TemplateStringsArray, ...values: unknown[]) => unknown[];
|
|
646
646
|
/**
|
|
647
647
|
* A function type for logging methods in the {@link Logger} interface.
|
|
648
|
-
* @since 0.
|
|
648
|
+
* @since 1.0.0
|
|
649
649
|
*/
|
|
650
650
|
interface LogMethod {
|
|
651
651
|
/**
|
package/dist/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","names":["category: string | readonly string[]","rootLogger: LoggerImpl | null","parent: LoggerImpl | null","category: readonly string[]","subcategory:\n | string\n | readonly [string]\n | readonly [string, ...(readonly string[])]","child: LoggerImpl | undefined","properties: Record<string, unknown>","record: LogRecord","level: LogLevel","bypassSinks?: Set<Sink>","rawMessage: string","properties: Record<string, unknown> | (() => Record<string, unknown>)","cachedProps: Record<string, 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>","logger: LoggerImpl","subcategory: string | readonly [string] | readonly [string, ...string[]]","message: string","template: string","message: unknown[]","prop: unknown","template: TemplateStringsArray","values: readonly unknown[]"],"sources":["../logger.ts"],"sourcesContent":["import type { ContextLocalStorage } from \"./context.ts\";\nimport type { Filter } from \"./filter.ts\";\nimport { compareLogLevel, type LogLevel } from \"./level.ts\";\nimport type { LogRecord } from \"./record.ts\";\nimport type { Sink } from \"./sink.ts\";\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 */\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 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 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 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 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 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 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 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 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 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 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 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/**\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 0.13.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 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\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 parentSinks: \"inherit\" | \"override\" = \"inherit\";\n readonly filters: Filter[];\n lowestLevel: LogLevel | null = \"trace\";\n contextLocalStorage?: ContextLocalStorage<Record<string, unknown>>;\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 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 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 if (\n this.lowestLevel === null || compareLogLevel(level, this.lowestLevel) < 0\n ) {\n return;\n }\n if (this.parent != null && this.parentSinks === \"inherit\") {\n for (const sink of this.parent.getSinks(level)) yield sink;\n }\n for (const sink of this.sinks) yield sink;\n }\n\n emit(record: LogRecord, bypassSinks?: Set<Sink>): void {\n if (\n this.lowestLevel === null ||\n compareLogLevel(record.level, this.lowestLevel) < 0 ||\n !this.filter(record)\n ) {\n return;\n }\n for (const sink of this.getSinks(record.level)) {\n if (bypassSinks?.has(sink)) continue;\n try {\n sink(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 =\n LoggerImpl.getLogger().contextLocalStorage?.getStore() ?? {};\n let cachedProps: Record<string, 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 return parseMessageTemplate(rawMessage, this.properties);\n },\n rawMessage,\n get properties() {\n if (cachedProps == null) {\n cachedProps = {\n ...implicitContext,\n ...properties(),\n };\n }\n return cachedProps;\n },\n }\n : {\n category: this.category,\n level,\n timestamp: Date.now(),\n message: parseMessageTemplate(rawMessage, {\n ...implicitContext,\n ...properties,\n }),\n rawMessage,\n properties: { ...implicitContext, ...properties },\n };\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 =\n LoggerImpl.getLogger().contextLocalStorage?.getStore() ?? {};\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 =\n LoggerImpl.getLogger().contextLocalStorage?.getStore() ?? {};\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(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n if (typeof message === \"string\") {\n this.log(\"trace\", message, (values[0] ?? {}) as Record<string, unknown>);\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(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n if (typeof message === \"string\") {\n this.log(\"debug\", message, (values[0] ?? {}) as Record<string, unknown>);\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(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n if (typeof message === \"string\") {\n this.log(\"info\", message, (values[0] ?? {}) as Record<string, unknown>);\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 warn(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n if (typeof message === \"string\") {\n this.log(\n \"warning\",\n message,\n (values[0] ?? {}) as Record<string, unknown>,\n );\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(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n this.warn(message, ...values);\n }\n\n error(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n if (typeof message === \"string\") {\n this.log(\"error\", message, (values[0] ?? {}) as Record<string, unknown>);\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(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n if (typeof message === \"string\") {\n this.log(\"fatal\", message, (values[0] ?? {}) as Record<string, unknown>);\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 this.logger.log(\n level,\n message,\n typeof properties === \"function\"\n ? () => ({\n ...this.properties,\n ...properties(),\n })\n : { ...this.properties, ...properties },\n bypassSinks,\n );\n }\n\n logLazily(level: LogLevel, callback: LogCallback): void {\n this.logger.logLazily(level, callback, this.properties);\n }\n\n logTemplate(\n level: LogLevel,\n messageTemplate: TemplateStringsArray,\n values: unknown[],\n ): void {\n this.logger.logTemplate(level, messageTemplate, values, this.properties);\n }\n\n trace(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n if (typeof message === \"string\") {\n this.log(\"trace\", message, (values[0] ?? {}) as Record<string, unknown>);\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(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n if (typeof message === \"string\") {\n this.log(\"debug\", message, (values[0] ?? {}) as Record<string, unknown>);\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(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n if (typeof message === \"string\") {\n this.log(\"info\", message, (values[0] ?? {}) as Record<string, unknown>);\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 warn(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n if (typeof message === \"string\") {\n this.log(\n \"warning\",\n message,\n (values[0] ?? {}) as Record<string, unknown>,\n );\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(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n this.warn(message, ...values);\n }\n\n error(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n if (typeof message === \"string\") {\n this.log(\"error\", message, (values[0] ?? {}) as Record<string, unknown>);\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(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n if (typeof message === \"string\") {\n this.log(\"fatal\", message, (values[0] ?? {}) as Record<string, unknown>);\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 * Parse a message template into a message template array and a values array.\n * @param template The message template.\n * @param properties The values to replace placeholders with.\n * @returns The message template array and the values array.\n */\nexport function parseMessageTemplate(\n template: string,\n properties: Record<string, unknown>,\n): readonly unknown[] {\n const message: unknown[] = [];\n let part = \"\";\n for (let i = 0; i < template.length; i++) {\n const char = template.charAt(i);\n const nextChar = template.charAt(i + 1);\n\n if (char === \"{\" && nextChar === \"{\") {\n // Escaped { character\n part = part + char;\n i++;\n } else if (char === \"}\" && nextChar === \"}\") {\n // Escaped } character\n part = part + char;\n i++;\n } else if (char === \"{\") {\n // Start of a placeholder\n message.push(part);\n part = \"\";\n } else if (char === \"}\") {\n // End of a placeholder\n let prop: unknown;\n if (part.match(/^\\s*\\*\\s*$/)) {\n prop = part in properties\n ? properties[part]\n : \"*\" in properties\n ? properties[\"*\"]\n : properties;\n } else if (part.match(/^\\s|\\s$/)) {\n prop = part in properties ? properties[part] : properties[part.trim()];\n } else {\n prop = properties[part];\n }\n message.push(prop);\n part = \"\";\n } else {\n // Default case\n part = part + char;\n }\n }\n message.push(part);\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":";;;;;;;;;;;;;;;AA6vBA,SAAgB,UAAUA,WAAuC,CAAE,GAAU;AAC3E,QAAO,WAAW,UAAU,SAAS;AACtC;;;;AAKD,MAAM,yBAAyB,OAAO,IAAI,qBAAqB;;;;;AAa/D,IAAa,aAAb,MAAa,WAA6B;CACxC,AAAS;CACT,AAAS;CACT,AAAS;CACT,AAAS;CACT,cAAsC;CACtC,AAAS;CACT,cAA+B;CAC/B;CAEA,OAAO,UAAUA,WAAuC,CAAE,GAAc;EACtE,IAAIC,aAAgC,0BAA0B,aACxD,WAAwC,2BAC1C,OACA;AACJ,MAAI,cAAc,MAAM;AACtB,gBAAa,IAAI,WAAW,MAAM,CAAE;AACpC,GAAC,WAAwC,0BACvC;EACH;AACD,aAAW,aAAa,SAAU,QAAO,WAAW,SAAS,SAAS;AACtE,MAAI,SAAS,WAAW,EAAG,QAAO;AAClC,SAAO,WAAW,SAAS,SAA2C;CACvE;CAED,AAAQ,YAAYC,QAA2BC,UAA6B;AAC1E,OAAK,SAAS;AACd,OAAK,WAAW,CAAE;AAClB,OAAK,WAAW;AAChB,OAAK,QAAQ,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KAAK;AAEpC,UAAO,OAAO;AACd;EACD,WAAU,SAAS,OAAO,aAAa,KAAK;AAE3C,UAAO,OAAO;AACd;EACD,WAAU,SAAS,KAAK;AAEvB,WAAQ,KAAK,KAAK;AAClB,UAAO;EACR,WAAU,SAAS,KAAK;GAEvB,IAAIC;AACJ,OAAI,KAAK,MAAM,aAAa,CAC1B,QAAO,QAAQ,aACX,WAAW,QACX,OAAO,aACP,WAAW,OACX;YACK,KAAK,MAAM,UAAU,CAC9B,QAAO,QAAQ,aAAa,WAAW,QAAQ,WAAW,KAAK,MAAM;OAErE,QAAO,WAAW;AAEpB,WAAQ,KAAK,KAAK;AAClB,UAAO;EACR,MAEC,QAAO,OAAO;CAEjB;AACD,SAAQ,KAAK,KAAK;AAClB,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":["category: string | readonly string[]","rootLogger: LoggerImpl | null","parent: LoggerImpl | null","category: readonly string[]","subcategory:\n | string\n | readonly [string]\n | readonly [string, ...(readonly string[])]","child: LoggerImpl | undefined","properties: Record<string, unknown>","record: LogRecord","level: LogLevel","bypassSinks?: Set<Sink>","rawMessage: string","properties: Record<string, unknown> | (() => Record<string, unknown>)","cachedProps: Record<string, 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>","logger: LoggerImpl","subcategory: string | readonly [string] | readonly [string, ...string[]]","message: string","template: string","message: unknown[]","prop: unknown","template: TemplateStringsArray","values: readonly unknown[]"],"sources":["../logger.ts"],"sourcesContent":["import type { ContextLocalStorage } from \"./context.ts\";\nimport type { Filter } from \"./filter.ts\";\nimport { compareLogLevel, type LogLevel } from \"./level.ts\";\nimport type { LogRecord } from \"./record.ts\";\nimport type { Sink } from \"./sink.ts\";\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 */\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 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 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 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 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 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 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 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 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 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 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 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/**\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 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\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 parentSinks: \"inherit\" | \"override\" = \"inherit\";\n readonly filters: Filter[];\n lowestLevel: LogLevel | null = \"trace\";\n contextLocalStorage?: ContextLocalStorage<Record<string, unknown>>;\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 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 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 if (\n this.lowestLevel === null || compareLogLevel(level, this.lowestLevel) < 0\n ) {\n return;\n }\n if (this.parent != null && this.parentSinks === \"inherit\") {\n for (const sink of this.parent.getSinks(level)) yield sink;\n }\n for (const sink of this.sinks) yield sink;\n }\n\n emit(record: LogRecord, bypassSinks?: Set<Sink>): void {\n if (\n this.lowestLevel === null ||\n compareLogLevel(record.level, this.lowestLevel) < 0 ||\n !this.filter(record)\n ) {\n return;\n }\n for (const sink of this.getSinks(record.level)) {\n if (bypassSinks?.has(sink)) continue;\n try {\n sink(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 =\n LoggerImpl.getLogger().contextLocalStorage?.getStore() ?? {};\n let cachedProps: Record<string, 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 return parseMessageTemplate(rawMessage, this.properties);\n },\n rawMessage,\n get properties() {\n if (cachedProps == null) {\n cachedProps = {\n ...implicitContext,\n ...properties(),\n };\n }\n return cachedProps;\n },\n }\n : {\n category: this.category,\n level,\n timestamp: Date.now(),\n message: parseMessageTemplate(rawMessage, {\n ...implicitContext,\n ...properties,\n }),\n rawMessage,\n properties: { ...implicitContext, ...properties },\n };\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 =\n LoggerImpl.getLogger().contextLocalStorage?.getStore() ?? {};\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 =\n LoggerImpl.getLogger().contextLocalStorage?.getStore() ?? {};\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(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n if (typeof message === \"string\") {\n this.log(\"trace\", message, (values[0] ?? {}) as Record<string, unknown>);\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(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n if (typeof message === \"string\") {\n this.log(\"debug\", message, (values[0] ?? {}) as Record<string, unknown>);\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(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n if (typeof message === \"string\") {\n this.log(\"info\", message, (values[0] ?? {}) as Record<string, unknown>);\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 warn(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n if (typeof message === \"string\") {\n this.log(\n \"warning\",\n message,\n (values[0] ?? {}) as Record<string, unknown>,\n );\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(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n this.warn(message, ...values);\n }\n\n error(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n if (typeof message === \"string\") {\n this.log(\"error\", message, (values[0] ?? {}) as Record<string, unknown>);\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(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n if (typeof message === \"string\") {\n this.log(\"fatal\", message, (values[0] ?? {}) as Record<string, unknown>);\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 this.logger.log(\n level,\n message,\n typeof properties === \"function\"\n ? () => ({\n ...this.properties,\n ...properties(),\n })\n : { ...this.properties, ...properties },\n bypassSinks,\n );\n }\n\n logLazily(level: LogLevel, callback: LogCallback): void {\n this.logger.logLazily(level, callback, this.properties);\n }\n\n logTemplate(\n level: LogLevel,\n messageTemplate: TemplateStringsArray,\n values: unknown[],\n ): void {\n this.logger.logTemplate(level, messageTemplate, values, this.properties);\n }\n\n trace(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n if (typeof message === \"string\") {\n this.log(\"trace\", message, (values[0] ?? {}) as Record<string, unknown>);\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(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n if (typeof message === \"string\") {\n this.log(\"debug\", message, (values[0] ?? {}) as Record<string, unknown>);\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(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n if (typeof message === \"string\") {\n this.log(\"info\", message, (values[0] ?? {}) as Record<string, unknown>);\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 warn(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n if (typeof message === \"string\") {\n this.log(\n \"warning\",\n message,\n (values[0] ?? {}) as Record<string, unknown>,\n );\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(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n this.warn(message, ...values);\n }\n\n error(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n if (typeof message === \"string\") {\n this.log(\"error\", message, (values[0] ?? {}) as Record<string, unknown>);\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(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>,\n ...values: unknown[]\n ): void {\n if (typeof message === \"string\") {\n this.log(\"fatal\", message, (values[0] ?? {}) as Record<string, unknown>);\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 * Parse a message template into a message template array and a values array.\n * @param template The message template.\n * @param properties The values to replace placeholders with.\n * @returns The message template array and the values array.\n */\nexport function parseMessageTemplate(\n template: string,\n properties: Record<string, unknown>,\n): readonly unknown[] {\n const message: unknown[] = [];\n let part = \"\";\n for (let i = 0; i < template.length; i++) {\n const char = template.charAt(i);\n const nextChar = template.charAt(i + 1);\n\n if (char === \"{\" && nextChar === \"{\") {\n // Escaped { character\n part = part + char;\n i++;\n } else if (char === \"}\" && nextChar === \"}\") {\n // Escaped } character\n part = part + char;\n i++;\n } else if (char === \"{\") {\n // Start of a placeholder\n message.push(part);\n part = \"\";\n } else if (char === \"}\") {\n // End of a placeholder\n let prop: unknown;\n if (part.match(/^\\s*\\*\\s*$/)) {\n prop = part in properties\n ? properties[part]\n : \"*\" in properties\n ? properties[\"*\"]\n : properties;\n } else if (part.match(/^\\s|\\s$/)) {\n prop = part in properties ? properties[part] : properties[part.trim()];\n } else {\n prop = properties[part];\n }\n message.push(prop);\n part = \"\";\n } else {\n // Default case\n part = part + char;\n }\n }\n message.push(part);\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":";;;;;;;;;;;;;;;AA6vBA,SAAgB,UAAUA,WAAuC,CAAE,GAAU;AAC3E,QAAO,WAAW,UAAU,SAAS;AACtC;;;;AAKD,MAAM,yBAAyB,OAAO,IAAI,qBAAqB;;;;;AAa/D,IAAa,aAAb,MAAa,WAA6B;CACxC,AAAS;CACT,AAAS;CACT,AAAS;CACT,AAAS;CACT,cAAsC;CACtC,AAAS;CACT,cAA+B;CAC/B;CAEA,OAAO,UAAUA,WAAuC,CAAE,GAAc;EACtE,IAAIC,aAAgC,0BAA0B,aACxD,WAAwC,2BAC1C,OACA;AACJ,MAAI,cAAc,MAAM;AACtB,gBAAa,IAAI,WAAW,MAAM,CAAE;AACpC,GAAC,WAAwC,0BACvC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,SAAgB,qBACdI,UACAhB,YACoB;CACpB,MAAMiB,UAAqB,CAAE;CAC7B,IAAI,OAAO;AACX,MAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;EACxC,MAAM,OAAO,SAAS,OAAO,EAAE;EAC/B,MAAM,WAAW,SAAS,OAAO,IAAI,EAAE;AAEvC,MAAI,SAAS,OAAO,aAAa,KAAK;AAEpC,UAAO,OAAO;AACd;EACD,WAAU,SAAS,OAAO,aAAa,KAAK;AAE3C,UAAO,OAAO;AACd;EACD,WAAU,SAAS,KAAK;AAEvB,WAAQ,KAAK,KAAK;AAClB,UAAO;EACR,WAAU,SAAS,KAAK;GAEvB,IAAIC;AACJ,OAAI,KAAK,MAAM,aAAa,CAC1B,QAAO,QAAQ,aACX,WAAW,QACX,OAAO,aACP,WAAW,OACX;YACK,KAAK,MAAM,UAAU,CAC9B,QAAO,QAAQ,aAAa,WAAW,QAAQ,WAAW,KAAK,MAAM;OAErE,QAAO,WAAW;AAEpB,WAAQ,KAAK,KAAK;AAClB,UAAO;EACR,MAEC,QAAO,OAAO;CAEjB;AACD,SAAQ,KAAK,KAAK;AAClB,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/level.ts
CHANGED
|
@@ -16,7 +16,7 @@ export type LogLevel = typeof logLevels[number];
|
|
|
16
16
|
* Lists all available log levels with the order of their severity.
|
|
17
17
|
* The `"trace"` level goes first, and the `"fatal"` level goes last.
|
|
18
18
|
* @returns A new copy of the array of log levels.
|
|
19
|
-
* @since 0.
|
|
19
|
+
* @since 1.0.0
|
|
20
20
|
*/
|
|
21
21
|
export function getLogLevels(): readonly LogLevel[] {
|
|
22
22
|
return [...logLevels];
|
package/logger.ts
CHANGED