@logtape/logtape 0.12.0-dev.185 → 0.12.0-dev.186
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/README.md +1 -2
- package/config.test.ts +3 -3
- package/deno.json +1 -1
- package/dist/filter.cjs +2 -1
- package/dist/filter.js +2 -1
- package/dist/filter.js.map +1 -1
- package/dist/formatter.cjs +3 -0
- package/dist/formatter.d.cts +1 -0
- package/dist/formatter.d.cts.map +1 -1
- package/dist/formatter.d.ts +1 -0
- package/dist/formatter.d.ts.map +1 -1
- package/dist/formatter.js +3 -0
- package/dist/formatter.js.map +1 -1
- package/dist/level.cjs +3 -0
- package/dist/level.d.cts +1 -1
- package/dist/level.d.cts.map +1 -1
- package/dist/level.d.ts +1 -1
- package/dist/level.d.ts.map +1 -1
- package/dist/level.js +3 -0
- package/dist/level.js.map +1 -1
- package/dist/logger.cjs +14 -2
- package/dist/logger.d.cts +86 -1
- package/dist/logger.d.cts.map +1 -1
- package/dist/logger.d.ts +86 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +14 -2
- package/dist/logger.js.map +1 -1
- package/dist/sink.cjs +1 -0
- package/dist/sink.d.cts +1 -0
- package/dist/sink.d.cts.map +1 -1
- package/dist/sink.d.ts +1 -0
- package/dist/sink.d.ts.map +1 -1
- package/dist/sink.js +1 -0
- package/dist/sink.js.map +1 -1
- package/filter.test.ts +15 -1
- package/filter.ts +8 -1
- package/fixtures.ts +5 -0
- package/formatter.test.ts +2 -0
- package/formatter.ts +4 -0
- package/level.ts +10 -1
- package/logger.test.ts +10 -1
- package/logger.ts +133 -3
- package/package.json +1 -1
- package/sink.test.ts +30 -1
- package/sink.ts +2 -0
package/README.md
CHANGED
|
@@ -39,8 +39,7 @@ The highlights of LogTape are:
|
|
|
39
39
|
|
|
40
40
|
- *[Dead simple sinks]*: You can easily add your own sinks to LogTape.
|
|
41
41
|
|
|
42
|
-

|
|
42
|
+

|
|
44
43
|
|
|
45
44
|
[JSR]: https://jsr.io/@logtape/logtape
|
|
46
45
|
[JSR badge]: https://jsr.io/badges/@logtape/logtape
|
package/config.test.ts
CHANGED
|
@@ -70,11 +70,11 @@ test("configure()", async () => {
|
|
|
70
70
|
const logger = LoggerImpl.getLogger("my-app");
|
|
71
71
|
assertEquals(logger.sinks, [a]);
|
|
72
72
|
assertEquals(logger.filters, [x]);
|
|
73
|
-
assertEquals(logger.lowestLevel, "
|
|
73
|
+
assertEquals(logger.lowestLevel, "trace");
|
|
74
74
|
const foo = LoggerImpl.getLogger(["my-app", "foo"]);
|
|
75
75
|
assertEquals(foo.sinks, [b]);
|
|
76
76
|
assertEquals(foo.filters, [y]);
|
|
77
|
-
assertEquals(foo.lowestLevel, "
|
|
77
|
+
assertEquals(foo.lowestLevel, "trace");
|
|
78
78
|
const bar = LoggerImpl.getLogger(["my-app", "bar"]);
|
|
79
79
|
assertEquals(bar.sinks, [c]);
|
|
80
80
|
assertEquals(bar.lowestLevel, "info");
|
|
@@ -332,7 +332,7 @@ test("configureSync()", async () => {
|
|
|
332
332
|
const foo = LoggerImpl.getLogger(["my-app", "foo"]);
|
|
333
333
|
assertEquals(foo.sinks, [b]);
|
|
334
334
|
assertEquals(foo.filters, [y]);
|
|
335
|
-
assertEquals(foo.lowestLevel, "
|
|
335
|
+
assertEquals(foo.lowestLevel, "trace");
|
|
336
336
|
const bar = LoggerImpl.getLogger(["my-app", "bar"]);
|
|
337
337
|
assertEquals(bar.sinks, [c]);
|
|
338
338
|
assertEquals(bar.lowestLevel, "info");
|
package/deno.json
CHANGED
package/dist/filter.cjs
CHANGED
|
@@ -23,7 +23,8 @@ function getLevelFilter(level) {
|
|
|
23
23
|
else if (level === "error") return (record) => record.level === "fatal" || record.level === "error";
|
|
24
24
|
else if (level === "warning") return (record) => record.level === "fatal" || record.level === "error" || record.level === "warning";
|
|
25
25
|
else if (level === "info") return (record) => record.level === "fatal" || record.level === "error" || record.level === "warning" || record.level === "info";
|
|
26
|
-
else if (level === "debug") return () =>
|
|
26
|
+
else if (level === "debug") return (record) => record.level === "fatal" || record.level === "error" || record.level === "warning" || record.level === "info" || record.level === "debug";
|
|
27
|
+
else if (level === "trace") return () => true;
|
|
27
28
|
throw new TypeError(`Invalid log level: ${level}.`);
|
|
28
29
|
}
|
|
29
30
|
|
package/dist/filter.js
CHANGED
|
@@ -22,7 +22,8 @@ function getLevelFilter(level) {
|
|
|
22
22
|
else if (level === "error") return (record) => record.level === "fatal" || record.level === "error";
|
|
23
23
|
else if (level === "warning") return (record) => record.level === "fatal" || record.level === "error" || record.level === "warning";
|
|
24
24
|
else if (level === "info") return (record) => record.level === "fatal" || record.level === "error" || record.level === "warning" || record.level === "info";
|
|
25
|
-
else if (level === "debug") return () =>
|
|
25
|
+
else if (level === "debug") return (record) => record.level === "fatal" || record.level === "error" || record.level === "warning" || record.level === "info" || record.level === "debug";
|
|
26
|
+
else if (level === "trace") return () => true;
|
|
26
27
|
throw new TypeError(`Invalid log level: ${level}.`);
|
|
27
28
|
}
|
|
28
29
|
|
package/dist/filter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.js","names":["filter: FilterLike","level: LogLevel | null","record: LogRecord"],"sources":["../filter.ts"],"sourcesContent":["import type { LogLevel } from \"./level.ts\";\nimport type { LogRecord } from \"./record.ts\";\n\n/**\n * A filter is a function that accepts a log record and returns `true` if the\n * record should be passed to the sink.\n *\n * @param record The log record to filter.\n * @returns `true` if the record should be passed to the sink.\n */\nexport type Filter = (record: LogRecord) => boolean;\n\n/**\n * A filter-like value is either a {@link Filter} or a {@link LogLevel}.\n * `null` is also allowed to represent a filter that rejects all records.\n */\nexport type FilterLike = Filter | LogLevel | null;\n\n/**\n * Converts a {@link FilterLike} value to an actual {@link Filter}.\n *\n * @param filter The filter-like value to convert.\n * @returns The actual filter.\n */\nexport function toFilter(filter: FilterLike): Filter {\n if (typeof filter === \"function\") return filter;\n return getLevelFilter(filter);\n}\n\n/**\n * Returns a filter that accepts log records with the specified level.\n *\n * @param level The level to filter by. If `null`, the filter will reject all\n * records.\n * @returns The filter.\n */\nexport function getLevelFilter(level: LogLevel | null): Filter {\n if (level == null) return () => false;\n if (level === \"fatal\") {\n return (record: LogRecord) => record.level === \"fatal\";\n } else if (level === \"error\") {\n return (record: LogRecord) =>\n record.level === \"fatal\" || record.level === \"error\";\n } else if (level === \"warning\") {\n return (record: LogRecord) =>\n record.level === \"fatal\" ||\n record.level === \"error\" ||\n record.level === \"warning\";\n } else if (level === \"info\") {\n return (record: LogRecord) =>\n record.level === \"fatal\" ||\n record.level === \"error\" ||\n record.level === \"warning\" ||\n record.level === \"info\";\n } else if (level === \"debug\") return () => true;\n throw new TypeError(`Invalid log level: ${level}.`);\n}\n"],"mappings":";;;;;;;AAwBA,SAAgB,SAASA,QAA4B;AACnD,YAAW,WAAW,WAAY,QAAO;AACzC,QAAO,eAAe,OAAO;AAC9B;;;;;;;;AASD,SAAgB,eAAeC,OAAgC;AAC7D,KAAI,SAAS,KAAM,QAAO,MAAM;AAChC,KAAI,UAAU,QACZ,QAAO,CAACC,WAAsB,OAAO,UAAU;UACtC,UAAU,QACnB,QAAO,CAACA,WACN,OAAO,UAAU,WAAW,OAAO,UAAU;UACtC,UAAU,UACnB,QAAO,CAACA,WACN,OAAO,UAAU,WACjB,OAAO,UAAU,WACjB,OAAO,UAAU;UACV,UAAU,OACnB,QAAO,CAACA,WACN,OAAO,UAAU,WACjB,OAAO,UAAU,WACjB,OAAO,UAAU,aACjB,OAAO,UAAU;UACV,UAAU,QAAS,QAAO,MAAM;AAC3C,OAAM,IAAI,WAAW,qBAAqB,MAAM;AACjD"}
|
|
1
|
+
{"version":3,"file":"filter.js","names":["filter: FilterLike","level: LogLevel | null","record: LogRecord"],"sources":["../filter.ts"],"sourcesContent":["import type { LogLevel } from \"./level.ts\";\nimport type { LogRecord } from \"./record.ts\";\n\n/**\n * A filter is a function that accepts a log record and returns `true` if the\n * record should be passed to the sink.\n *\n * @param record The log record to filter.\n * @returns `true` if the record should be passed to the sink.\n */\nexport type Filter = (record: LogRecord) => boolean;\n\n/**\n * A filter-like value is either a {@link Filter} or a {@link LogLevel}.\n * `null` is also allowed to represent a filter that rejects all records.\n */\nexport type FilterLike = Filter | LogLevel | null;\n\n/**\n * Converts a {@link FilterLike} value to an actual {@link Filter}.\n *\n * @param filter The filter-like value to convert.\n * @returns The actual filter.\n */\nexport function toFilter(filter: FilterLike): Filter {\n if (typeof filter === \"function\") return filter;\n return getLevelFilter(filter);\n}\n\n/**\n * Returns a filter that accepts log records with the specified level.\n *\n * @param level The level to filter by. If `null`, the filter will reject all\n * records.\n * @returns The filter.\n */\nexport function getLevelFilter(level: LogLevel | null): Filter {\n if (level == null) return () => false;\n if (level === \"fatal\") {\n return (record: LogRecord) => record.level === \"fatal\";\n } else if (level === \"error\") {\n return (record: LogRecord) =>\n record.level === \"fatal\" || record.level === \"error\";\n } else if (level === \"warning\") {\n return (record: LogRecord) =>\n record.level === \"fatal\" ||\n record.level === \"error\" ||\n record.level === \"warning\";\n } else if (level === \"info\") {\n return (record: LogRecord) =>\n record.level === \"fatal\" ||\n record.level === \"error\" ||\n record.level === \"warning\" ||\n record.level === \"info\";\n } else if (level === \"debug\") {\n return (record: LogRecord) =>\n record.level === \"fatal\" ||\n record.level === \"error\" ||\n record.level === \"warning\" ||\n record.level === \"info\" ||\n record.level === \"debug\";\n } else if (level === \"trace\") return () => true;\n throw new TypeError(`Invalid log level: ${level}.`);\n}\n"],"mappings":";;;;;;;AAwBA,SAAgB,SAASA,QAA4B;AACnD,YAAW,WAAW,WAAY,QAAO;AACzC,QAAO,eAAe,OAAO;AAC9B;;;;;;;;AASD,SAAgB,eAAeC,OAAgC;AAC7D,KAAI,SAAS,KAAM,QAAO,MAAM;AAChC,KAAI,UAAU,QACZ,QAAO,CAACC,WAAsB,OAAO,UAAU;UACtC,UAAU,QACnB,QAAO,CAACA,WACN,OAAO,UAAU,WAAW,OAAO,UAAU;UACtC,UAAU,UACnB,QAAO,CAACA,WACN,OAAO,UAAU,WACjB,OAAO,UAAU,WACjB,OAAO,UAAU;UACV,UAAU,OACnB,QAAO,CAACA,WACN,OAAO,UAAU,WACjB,OAAO,UAAU,WACjB,OAAO,UAAU,aACjB,OAAO,UAAU;UACV,UAAU,QACnB,QAAO,CAACA,WACN,OAAO,UAAU,WACjB,OAAO,UAAU,WACjB,OAAO,UAAU,aACjB,OAAO,UAAU,UACjB,OAAO,UAAU;UACV,UAAU,QAAS,QAAO,MAAM;AAC3C,OAAM,IAAI,WAAW,qBAAqB,MAAM;AACjD"}
|
package/dist/formatter.cjs
CHANGED
|
@@ -6,6 +6,7 @@ const __util = require_rolldown_runtime.__toESM(require("#util"));
|
|
|
6
6
|
* The severity level abbreviations.
|
|
7
7
|
*/
|
|
8
8
|
const levelAbbreviations = {
|
|
9
|
+
"trace": "TRC",
|
|
9
10
|
"debug": "DBG",
|
|
10
11
|
"info": "INF",
|
|
11
12
|
"warning": "WRN",
|
|
@@ -101,6 +102,7 @@ const ansiStyles = {
|
|
|
101
102
|
strikethrough: "\x1B[9m"
|
|
102
103
|
};
|
|
103
104
|
const defaultLevelColors = {
|
|
105
|
+
trace: null,
|
|
104
106
|
debug: "blue",
|
|
105
107
|
info: "green",
|
|
106
108
|
warning: "yellow",
|
|
@@ -237,6 +239,7 @@ const jsonLinesFormatter = getJsonLinesFormatter();
|
|
|
237
239
|
* The styles for the log level in the console.
|
|
238
240
|
*/
|
|
239
241
|
const logLevelStyles = {
|
|
242
|
+
"trace": "background-color: gray; color: white;",
|
|
240
243
|
"debug": "background-color: gray; color: white;",
|
|
241
244
|
"info": "background-color: white; color: black;",
|
|
242
245
|
"warning": "background-color: orange; color: black;",
|
package/dist/formatter.d.cts
CHANGED
|
@@ -209,6 +209,7 @@ interface AnsiColorFormatterOptions extends TextFormatterOptions {
|
|
|
209
209
|
/**
|
|
210
210
|
* The ANSI colors for the log levels. The default colors are as follows:
|
|
211
211
|
*
|
|
212
|
+
* - `"trace"`: `null` (no color)
|
|
212
213
|
* - `"debug"`: `"blue"`
|
|
213
214
|
* - `"info"`: `"green"`
|
|
214
215
|
* - `"warning"`: `"yellow"`
|
package/dist/formatter.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.d.cts","names":[],"sources":["../formatter.ts"],"sourcesContent":[],"mappings":";;;;;;;AAWA;
|
|
1
|
+
{"version":3,"file":"formatter.d.cts","names":[],"sources":["../formatter.ts"],"sourcesContent":[],"mappings":";;;;;;;AAWA;AA+DA;AA+BA;;;AAuGoB,KArMR,aAAA,GAqMQ,CAAA,MAAA,EArMiB,SAqMjB,EAAA,GAAA,MAAA;AAAe;AAoBnC;;;AAEG,UA5Jc,eAAA,CA4Jd;EAAa;AA6EhB;AAQA;EAyBY,SAAA,EAAA,MAAS,GAAA,IAAA;EA4BJ;;;EAwCW,KAKT,EAAA,MAAA;EAAS;;;EAiBc,QAA1B,EAAA,MAAA;EAAM;;;EA9DiD,OAAA,EAAA,MAAA;EAmFvD;;;EACyB,MACtC,EAnWO,SAmWP;AAAa;AA4DhB;AAMA;AAsDA;;AACW,UArdM,oBAAA,CAqdN;EAA8B;AACzB;AA8FhB;AAUA;AAqBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mEArhBe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAyCK;;;;;;;;;;;;;;;;;;;iBAoBJ,gBAAA,WACL,uBACR;;;;;;;;;;;cA6EU,sBAAsB;;;;;KAQvB,SAAA;;;;;KAyBA,SAAA;;;;;UA4BK,yBAAA,SAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAwChC;;;;mBAKA;;;;eAKJ;;;;;;;;;;;gBAYC,OAAO,UAAU;;;;kBAKf;;;;kBAKA;;;;;;;;;;iBAWF,qBAAA,WACL,4BACR;;;;;;;;;;cA4DU,oBAAoB;;;;;UAMhB,yBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsDD,qBAAA,WACL,4BACR;;;;;;;;;;;;;;;;;cA8FU,oBAAoB;;;;;;;;;KAUrB,gBAAA,YAA4B;;;;;;;;iBAqBxB,uBAAA,SAAgC"}
|
package/dist/formatter.d.ts
CHANGED
|
@@ -209,6 +209,7 @@ interface AnsiColorFormatterOptions extends TextFormatterOptions {
|
|
|
209
209
|
/**
|
|
210
210
|
* The ANSI colors for the log levels. The default colors are as follows:
|
|
211
211
|
*
|
|
212
|
+
* - `"trace"`: `null` (no color)
|
|
212
213
|
* - `"debug"`: `"blue"`
|
|
213
214
|
* - `"info"`: `"green"`
|
|
214
215
|
* - `"warning"`: `"yellow"`
|
package/dist/formatter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.d.ts","names":[],"sources":["../formatter.ts"],"sourcesContent":[],"mappings":";;;;;;;AAWA;
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","names":[],"sources":["../formatter.ts"],"sourcesContent":[],"mappings":";;;;;;;AAWA;AA+DA;AA+BA;;;AAuGoB,KArMR,aAAA,GAqMQ,CAAA,MAAA,EArMiB,SAqMjB,EAAA,GAAA,MAAA;AAAe;AAoBnC;;;AAEG,UA5Jc,eAAA,CA4Jd;EAAa;AA6EhB;AAQA;EAyBY,SAAA,EAAA,MAAS,GAAA,IAAA;EA4BJ;;;EAwCW,KAKT,EAAA,MAAA;EAAS;;;EAiBc,QAA1B,EAAA,MAAA;EAAM;;;EA9DiD,OAAA,EAAA,MAAA;EAmFvD;;;EACyB,MACtC,EAnWO,SAmWP;AAAa;AA4DhB;AAMA;AAsDA;;AACW,UArdM,oBAAA,CAqdN;EAA8B;AACzB;AA8FhB;AAUA;AAqBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mEArhBe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAyCK;;;;;;;;;;;;;;;;;;;iBAoBJ,gBAAA,WACL,uBACR;;;;;;;;;;;cA6EU,sBAAsB;;;;;KAQvB,SAAA;;;;;KAyBA,SAAA;;;;;UA4BK,yBAAA,SAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAwChC;;;;mBAKA;;;;eAKJ;;;;;;;;;;;gBAYC,OAAO,UAAU;;;;kBAKf;;;;kBAKA;;;;;;;;;;iBAWF,qBAAA,WACL,4BACR;;;;;;;;;;cA4DU,oBAAoB;;;;;UAMhB,yBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsDD,qBAAA,WACL,4BACR;;;;;;;;;;;;;;;;;cA8FU,oBAAoB;;;;;;;;;KAUrB,gBAAA,YAA4B;;;;;;;;iBAqBxB,uBAAA,SAAgC"}
|
package/dist/formatter.js
CHANGED
|
@@ -5,6 +5,7 @@ import * as util from "#util";
|
|
|
5
5
|
* The severity level abbreviations.
|
|
6
6
|
*/
|
|
7
7
|
const levelAbbreviations = {
|
|
8
|
+
"trace": "TRC",
|
|
8
9
|
"debug": "DBG",
|
|
9
10
|
"info": "INF",
|
|
10
11
|
"warning": "WRN",
|
|
@@ -100,6 +101,7 @@ const ansiStyles = {
|
|
|
100
101
|
strikethrough: "\x1B[9m"
|
|
101
102
|
};
|
|
102
103
|
const defaultLevelColors = {
|
|
104
|
+
trace: null,
|
|
103
105
|
debug: "blue",
|
|
104
106
|
info: "green",
|
|
105
107
|
warning: "yellow",
|
|
@@ -236,6 +238,7 @@ const jsonLinesFormatter = getJsonLinesFormatter();
|
|
|
236
238
|
* The styles for the log level in the console.
|
|
237
239
|
*/
|
|
238
240
|
const logLevelStyles = {
|
|
241
|
+
"trace": "background-color: gray; color: white;",
|
|
239
242
|
"debug": "background-color: gray; color: white;",
|
|
240
243
|
"info": "background-color: white; color: black;",
|
|
241
244
|
"warning": "background-color: orange; color: black;",
|
package/dist/formatter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.js","names":["levelAbbreviations: Record<LogLevel, string>","inspect: (value: unknown, options?: { colors?: boolean }) => string","options: TextFormatterOptions","ts: number","level: LogLevel","formatter: (values: FormattedValues) => string","record: LogRecord","values: FormattedValues","defaultTextFormatter: TextFormatter","ansiColors: Record<AnsiColor, string>","ansiStyles: Record<AnsiStyle, string>","defaultLevelColors: Record<LogLevel, AnsiColor | null>","options: AnsiColorFormatterOptions","value: unknown","ansiColorFormatter: TextFormatter","options: JsonLinesFormatterOptions","joinCategory: (category: readonly string[]) => string | readonly string[]","category: readonly string[]","getMessage: TextFormatter","getProperties: (\n properties: Record<string, unknown>,\n ) => Record<string, unknown>","result: Record<string, unknown>","jsonLinesFormatter: TextFormatter","logLevelStyles: Record<LogLevel, string>","values: unknown[]"],"sources":["../formatter.ts"],"sourcesContent":["import * as util from \"#util\";\nimport type { LogLevel } from \"./level.ts\";\nimport type { LogRecord } from \"./record.ts\";\n\n/**\n * A text formatter is a function that accepts a log record and returns\n * a string.\n *\n * @param record The log record to format.\n * @returns The formatted log record.\n */\nexport type TextFormatter = (record: LogRecord) => string;\n\n/**\n * The severity level abbreviations.\n */\nconst levelAbbreviations: Record<LogLevel, string> = {\n \"debug\": \"DBG\",\n \"info\": \"INF\",\n \"warning\": \"WRN\",\n \"error\": \"ERR\",\n \"fatal\": \"FTL\",\n};\n\n/**\n * A platform-specific inspect function. In Deno, this is {@link Deno.inspect},\n * and in Node.js/Bun it is `util.inspect()`. If neither is available, it\n * falls back to {@link JSON.stringify}.\n *\n * @param value The value to inspect.\n * @param options The options for inspecting the value.\n * If `colors` is `true`, the output will be ANSI-colored.\n * @returns The string representation of the value.\n */\nconst inspect: (value: unknown, options?: { colors?: boolean }) => string =\n // @ts-ignore: Browser detection\n // dnt-shim-ignore\n typeof document !== \"undefined\" ||\n // @ts-ignore: React Native detection\n // dnt-shim-ignore\n typeof navigator !== \"undefined\" && navigator.product === \"ReactNative\"\n ? (v) => JSON.stringify(v)\n // @ts-ignore: Deno global\n // dnt-shim-ignore\n : \"Deno\" in globalThis && \"inspect\" in globalThis.Deno &&\n // @ts-ignore: Deno global\n // dnt-shim-ignore\n typeof globalThis.Deno.inspect === \"function\"\n ? (v, opts) =>\n // @ts-ignore: Deno global\n // dnt-shim-ignore\n globalThis.Deno.inspect(v, {\n strAbbreviateSize: Infinity,\n iterableLimit: Infinity,\n ...opts,\n })\n // @ts-ignore: Node.js global\n // dnt-shim-ignore\n : util != null && \"inspect\" in util && typeof util.inspect === \"function\"\n ? (v, opts) =>\n // @ts-ignore: Node.js global\n // dnt-shim-ignore\n util.inspect(v, {\n maxArrayLength: Infinity,\n maxStringLength: Infinity,\n ...opts,\n })\n : (v) => JSON.stringify(v);\n\n/**\n * The formatted values for a log record.\n * @since 0.6.0\n */\nexport interface FormattedValues {\n /**\n * The formatted timestamp.\n */\n timestamp: string | null;\n\n /**\n * The formatted log level.\n */\n level: string;\n\n /**\n * The formatted category.\n */\n category: string;\n\n /**\n * The formatted message.\n */\n message: string;\n\n /**\n * The unformatted log record.\n */\n record: LogRecord;\n}\n\n/**\n * The various options for the built-in text formatters.\n * @since 0.6.0\n */\nexport interface TextFormatterOptions {\n /**\n * The timestamp format. This can be one of the following:\n *\n * - `\"date-time-timezone\"`: The date and time with the full timezone offset\n * (e.g., `\"2023-11-14 22:13:20.000 +00:00\"`).\n * - `\"date-time-tz\"`: The date and time with the short timezone offset\n * (e.g., `\"2023-11-14 22:13:20.000 +00\"`).\n * - `\"date-time\"`: The date and time without the timezone offset\n * (e.g., `\"2023-11-14 22:13:20.000\"`).\n * - `\"time-timezone\"`: The time with the full timezone offset but without\n * the date (e.g., `\"22:13:20.000 +00:00\"`).\n * - `\"time-tz\"`: The time with the short timezone offset but without the date\n * (e.g., `\"22:13:20.000 +00\"`).\n * - `\"time\"`: The time without the date or timezone offset\n * (e.g., `\"22:13:20.000\"`).\n * - `\"date\"`: The date without the time or timezone offset\n * (e.g., `\"2023-11-14\"`).\n * - `\"rfc3339\"`: The date and time in RFC 3339 format\n * (e.g., `\"2023-11-14T22:13:20.000Z\"`).\n * - `\"none\"` or `\"disabled\"`: No display\n *\n * Alternatively, this can be a function that accepts a timestamp and returns\n * a string.\n *\n * The default is `\"date-time-timezone\"`.\n */\n timestamp?:\n | \"date-time-timezone\"\n | \"date-time-tz\"\n | \"date-time\"\n | \"time-timezone\"\n | \"time-tz\"\n | \"time\"\n | \"date\"\n | \"rfc3339\"\n | \"none\"\n | \"disabled\"\n | ((ts: number) => string | null);\n\n /**\n * The log level format. This can be one of the following:\n *\n * - `\"ABBR\"`: The log level abbreviation in uppercase (e.g., `\"INF\"`).\n * - `\"FULL\"`: The full log level name in uppercase (e.g., `\"INFO\"`).\n * - `\"L\"`: The first letter of the log level in uppercase (e.g., `\"I\"`).\n * - `\"abbr\"`: The log level abbreviation in lowercase (e.g., `\"inf\"`).\n * - `\"full\"`: The full log level name in lowercase (e.g., `\"info\"`).\n * - `\"l\"`: The first letter of the log level in lowercase (e.g., `\"i\"`).\n *\n * Alternatively, this can be a function that accepts a log level and returns\n * a string.\n *\n * The default is `\"ABBR\"`.\n */\n level?:\n | \"ABBR\"\n | \"FULL\"\n | \"L\"\n | \"abbr\"\n | \"full\"\n | \"l\"\n | ((level: LogLevel) => string);\n\n /**\n * The separator between category names. For example, if the separator is\n * `\"·\"`, the category `[\"a\", \"b\", \"c\"]` will be formatted as `\"a·b·c\"`.\n * The default separator is `\"·\"`.\n *\n * If this is a function, it will be called with the category array and\n * should return a string, which will be used for rendering the category.\n */\n category?: string | ((category: readonly string[]) => string);\n\n /**\n * The format of the embedded values.\n *\n * A function that renders a value to a string. This function is used to\n * render the values in the log record. The default is [`util.inspect()`] in\n * Node.js/Bun and [`Deno.inspect()`] in Deno.\n *\n * [`util.inspect()`]: https://nodejs.org/api/util.html#utilinspectobject-options\n * [`Deno.inspect()`]: https://docs.deno.com/api/deno/~/Deno.inspect\n * @param value The value to render.\n * @returns The string representation of the value.\n */\n value?: (value: unknown) => string;\n\n /**\n * How those formatted parts are concatenated.\n *\n * A function that formats the log record. This function is called with the\n * formatted values and should return a string. Note that the formatted\n * *should not* include a newline character at the end.\n *\n * By default, this is a function that formats the log record as follows:\n *\n * ```\n * 2023-11-14 22:13:20.000 +00:00 [INF] category·subcategory: Hello, world!\n * ```\n * @param values The formatted values.\n * @returns The formatted log record.\n */\n format?: (values: FormattedValues) => string;\n}\n\n/**\n * Get a text formatter with the specified options. Although it's flexible\n * enough to create a custom formatter, if you want more control, you can\n * create a custom formatter that satisfies the {@link TextFormatter} type\n * instead.\n *\n * For more information on the options, see {@link TextFormatterOptions}.\n *\n * By default, the formatter formats log records as follows:\n *\n * ```\n * 2023-11-14 22:13:20.000 +00:00 [INF] category·subcategory: Hello, world!\n * ```\n * @param options The options for the text formatter.\n * @returns The text formatter.\n * @since 0.6.0\n */\nexport function getTextFormatter(\n options: TextFormatterOptions = {},\n): TextFormatter {\n const timestampRenderer =\n options.timestamp == null || options.timestamp === \"date-time-timezone\"\n ? (ts: number): string =>\n new Date(ts).toISOString().replace(\"T\", \" \").replace(\"Z\", \" +00:00\")\n : options.timestamp === \"date-time-tz\"\n ? (ts: number): string =>\n new Date(ts).toISOString().replace(\"T\", \" \").replace(\"Z\", \" +00\")\n : options.timestamp === \"date-time\"\n ? (ts: number): string =>\n new Date(ts).toISOString().replace(\"T\", \" \").replace(\"Z\", \"\")\n : options.timestamp === \"time-timezone\"\n ? (ts: number): string =>\n new Date(ts).toISOString().replace(/.*T/, \"\").replace(\"Z\", \" +00:00\")\n : options.timestamp === \"time-tz\"\n ? (ts: number): string =>\n new Date(ts).toISOString().replace(/.*T/, \"\").replace(\"Z\", \" +00\")\n : options.timestamp === \"time\"\n ? (ts: number): string =>\n new Date(ts).toISOString().replace(/.*T/, \"\").replace(\"Z\", \"\")\n : options.timestamp === \"date\"\n ? (ts: number): string => new Date(ts).toISOString().replace(/T.*/, \"\")\n : options.timestamp === \"rfc3339\"\n ? (ts: number): string => new Date(ts).toISOString()\n : options.timestamp === \"none\" || options.timestamp === \"disabled\"\n ? () => null\n : options.timestamp;\n const categorySeparator = options.category ?? \"·\";\n const valueRenderer = options.value ?? inspect;\n const levelRenderer = options.level == null || options.level === \"ABBR\"\n ? (level: LogLevel): string => levelAbbreviations[level]\n : options.level === \"abbr\"\n ? (level: LogLevel): string => levelAbbreviations[level].toLowerCase()\n : options.level === \"FULL\"\n ? (level: LogLevel): string => level.toUpperCase()\n : options.level === \"full\"\n ? (level: LogLevel): string => level\n : options.level === \"L\"\n ? (level: LogLevel): string => level.charAt(0).toUpperCase()\n : options.level === \"l\"\n ? (level: LogLevel): string => level.charAt(0)\n : options.level;\n const formatter: (values: FormattedValues) => string = options.format ??\n (({ timestamp, level, category, message }: FormattedValues) =>\n `${timestamp ? `${timestamp} ` : \"\"}[${level}] ${category}: ${message}`);\n return (record: LogRecord): string => {\n let message = \"\";\n for (let i = 0; i < record.message.length; i++) {\n if (i % 2 === 0) message += record.message[i];\n else message += valueRenderer(record.message[i]);\n }\n const timestamp = timestampRenderer(record.timestamp);\n const level = levelRenderer(record.level);\n const category = typeof categorySeparator === \"function\"\n ? categorySeparator(record.category)\n : record.category.join(categorySeparator);\n const values: FormattedValues = {\n timestamp,\n level,\n category,\n message,\n record,\n };\n return `${formatter(values)}\\n`;\n };\n}\n\n/**\n * The default text formatter. This formatter formats log records as follows:\n *\n * ```\n * 2023-11-14 22:13:20.000 +00:00 [INF] category·subcategory: Hello, world!\n * ```\n *\n * @param record The log record to format.\n * @returns The formatted log record.\n */\nexport const defaultTextFormatter: TextFormatter = getTextFormatter();\n\nconst RESET = \"\\x1b[0m\";\n\n/**\n * The ANSI colors. These can be used to colorize text in the console.\n * @since 0.6.0\n */\nexport type AnsiColor =\n | \"black\"\n | \"red\"\n | \"green\"\n | \"yellow\"\n | \"blue\"\n | \"magenta\"\n | \"cyan\"\n | \"white\";\n\nconst ansiColors: Record<AnsiColor, string> = {\n black: \"\\x1b[30m\",\n red: \"\\x1b[31m\",\n green: \"\\x1b[32m\",\n yellow: \"\\x1b[33m\",\n blue: \"\\x1b[34m\",\n magenta: \"\\x1b[35m\",\n cyan: \"\\x1b[36m\",\n white: \"\\x1b[37m\",\n};\n\n/**\n * The ANSI text styles.\n * @since 0.6.0\n */\nexport type AnsiStyle =\n | \"bold\"\n | \"dim\"\n | \"italic\"\n | \"underline\"\n | \"strikethrough\";\n\nconst ansiStyles: Record<AnsiStyle, string> = {\n bold: \"\\x1b[1m\",\n dim: \"\\x1b[2m\",\n italic: \"\\x1b[3m\",\n underline: \"\\x1b[4m\",\n strikethrough: \"\\x1b[9m\",\n};\n\nconst defaultLevelColors: Record<LogLevel, AnsiColor | null> = {\n debug: \"blue\",\n info: \"green\",\n warning: \"yellow\",\n error: \"red\",\n fatal: \"magenta\",\n};\n\n/**\n * The various options for the ANSI color formatter.\n * @since 0.6.0\n */\nexport interface AnsiColorFormatterOptions extends TextFormatterOptions {\n /**\n * The timestamp format. This can be one of the following:\n *\n * - `\"date-time-timezone\"`: The date and time with the full timezone offset\n * (e.g., `\"2023-11-14 22:13:20.000 +00:00\"`).\n * - `\"date-time-tz\"`: The date and time with the short timezone offset\n * (e.g., `\"2023-11-14 22:13:20.000 +00\"`).\n * - `\"date-time\"`: The date and time without the timezone offset\n * (e.g., `\"2023-11-14 22:13:20.000\"`).\n * - `\"time-timezone\"`: The time with the full timezone offset but without\n * the date (e.g., `\"22:13:20.000 +00:00\"`).\n * - `\"time-tz\"`: The time with the short timezone offset but without the date\n * (e.g., `\"22:13:20.000 +00\"`).\n * - `\"time\"`: The time without the date or timezone offset\n * (e.g., `\"22:13:20.000\"`).\n * - `\"date\"`: The date without the time or timezone offset\n * (e.g., `\"2023-11-14\"`).\n * - `\"rfc3339\"`: The date and time in RFC 3339 format\n * (e.g., `\"2023-11-14T22:13:20.000Z\"`).\n *\n * Alternatively, this can be a function that accepts a timestamp and returns\n * a string.\n *\n * The default is `\"date-time-tz\"`.\n */\n timestamp?:\n | \"date-time-timezone\"\n | \"date-time-tz\"\n | \"date-time\"\n | \"time-timezone\"\n | \"time-tz\"\n | \"time\"\n | \"date\"\n | \"rfc3339\"\n | ((ts: number) => string);\n\n /**\n * The ANSI style for the timestamp. `\"dim\"` is used by default.\n */\n timestampStyle?: AnsiStyle | null;\n\n /**\n * The ANSI color for the timestamp. No color is used by default.\n */\n timestampColor?: AnsiColor | null;\n\n /**\n * The ANSI style for the log level. `\"bold\"` is used by default.\n */\n levelStyle?: AnsiStyle | null;\n\n /**\n * The ANSI colors for the log levels. The default colors are as follows:\n *\n * - `\"debug\"`: `\"blue\"`\n * - `\"info\"`: `\"green\"`\n * - `\"warning\"`: `\"yellow\"`\n * - `\"error\"`: `\"red\"`\n * - `\"fatal\"`: `\"magenta\"`\n */\n levelColors?: Record<LogLevel, AnsiColor | null>;\n\n /**\n * The ANSI style for the category. `\"dim\"` is used by default.\n */\n categoryStyle?: AnsiStyle | null;\n\n /**\n * The ANSI color for the category. No color is used by default.\n */\n categoryColor?: AnsiColor | null;\n}\n\n/**\n * Get an ANSI color formatter with the specified options.\n *\n * \n * @param option The options for the ANSI color formatter.\n * @returns The ANSI color formatter.\n * @since 0.6.0\n */\nexport function getAnsiColorFormatter(\n options: AnsiColorFormatterOptions = {},\n): TextFormatter {\n const format = options.format;\n const timestampStyle = typeof options.timestampStyle === \"undefined\"\n ? \"dim\"\n : options.timestampStyle;\n const timestampColor = options.timestampColor ?? null;\n const timestampPrefix = `${\n timestampStyle == null ? \"\" : ansiStyles[timestampStyle]\n }${timestampColor == null ? \"\" : ansiColors[timestampColor]}`;\n const timestampSuffix = timestampStyle == null && timestampColor == null\n ? \"\"\n : RESET;\n const levelStyle = typeof options.levelStyle === \"undefined\"\n ? \"bold\"\n : options.levelStyle;\n const levelColors = options.levelColors ?? defaultLevelColors;\n const categoryStyle = typeof options.categoryStyle === \"undefined\"\n ? \"dim\"\n : options.categoryStyle;\n const categoryColor = options.categoryColor ?? null;\n const categoryPrefix = `${\n categoryStyle == null ? \"\" : ansiStyles[categoryStyle]\n }${categoryColor == null ? \"\" : ansiColors[categoryColor]}`;\n const categorySuffix = categoryStyle == null && categoryColor == null\n ? \"\"\n : RESET;\n return getTextFormatter({\n timestamp: \"date-time-tz\",\n value(value: unknown): string {\n return inspect(value, { colors: true });\n },\n ...options,\n format({ timestamp, level, category, message, record }): string {\n const levelColor = levelColors[record.level];\n timestamp = `${timestampPrefix}${timestamp}${timestampSuffix}`;\n level = `${levelStyle == null ? \"\" : ansiStyles[levelStyle]}${\n levelColor == null ? \"\" : ansiColors[levelColor]\n }${level}${levelStyle == null && levelColor == null ? \"\" : RESET}`;\n return format == null\n ? `${timestamp} ${level} ${categoryPrefix}${category}:${categorySuffix} ${message}`\n : format({\n timestamp,\n level,\n category: `${categoryPrefix}${category}${categorySuffix}`,\n message,\n record,\n });\n },\n });\n}\n\n/**\n * A text formatter that uses ANSI colors to format log records.\n *\n * \n *\n * @param record The log record to format.\n * @returns The formatted log record.\n * @since 0.5.0\n */\nexport const ansiColorFormatter: TextFormatter = getAnsiColorFormatter();\n\n/**\n * Options for the {@link getJsonLinesFormatter} function.\n * @since 0.11.0\n */\nexport interface JsonLinesFormatterOptions {\n /**\n * The separator between category names. For example, if the separator is\n * `\".\"`, the category `[\"a\", \"b\", \"c\"]` will be formatted as `\"a.b.c\"`.\n * If this is a function, it will be called with the category array and\n * should return a string or an array of strings, which will be used\n * for rendering the category.\n *\n * @default `\".\"`\n */\n readonly categorySeparator?:\n | string\n | ((category: readonly string[]) => string | readonly string[]);\n\n /**\n * The message format. This can be one of the following:\n *\n * - `\"template\"`: The raw message template is used as the message.\n * - `\"rendered\"`: The message is rendered with the values.\n *\n * @default `\"rendered\"`\n */\n readonly message?: \"template\" | \"rendered\";\n\n /**\n * The properties format. This can be one of the following:\n *\n * - `\"flatten\"`: The properties are flattened into the root object.\n * - `\"prepend:<prefix>\"`: The properties are prepended with the given prefix\n * (e.g., `\"prepend:ctx_\"` will prepend `ctx_` to each property key).\n * - `\"nest:<key>\"`: The properties are nested under the given key\n * (e.g., `\"nest:properties\"` will nest the properties under the\n * `properties` key).\n *\n * @default `\"nest:properties\"`\n */\n readonly properties?: \"flatten\" | `prepend:${string}` | `nest:${string}`;\n}\n\n/**\n * Get a [JSON Lines] formatter with the specified options. The log records\n * will be rendered as JSON objects, one per line, which is a common format\n * for log files. This format is also known as Newline-Delimited JSON (NDJSON).\n * It looks like this:\n *\n * ```json\n * {\"@timestamp\":\"2023-11-14T22:13:20.000Z\",\"level\":\"INFO\",\"message\":\"Hello, world!\",\"logger\":\"my.logger\",\"properties\":{\"key\":\"value\"}}\n * ```\n *\n * [JSON Lines]: https://jsonlines.org/\n * @param options The options for the JSON Lines formatter.\n * @returns The JSON Lines formatter.\n * @since 0.11.0\n */\nexport function getJsonLinesFormatter(\n options: JsonLinesFormatterOptions = {},\n): TextFormatter {\n let joinCategory: (category: readonly string[]) => string | readonly string[];\n if (typeof options.categorySeparator === \"function\") {\n joinCategory = options.categorySeparator;\n } else {\n const separator = options.categorySeparator ?? \".\";\n joinCategory = (category: readonly string[]): string =>\n category.join(separator);\n }\n\n let getMessage: TextFormatter;\n if (options.message === \"template\") {\n getMessage = (record: LogRecord): string => {\n if (typeof record.rawMessage === \"string\") {\n return record.rawMessage;\n }\n let msg = \"\";\n for (let i = 0; i < record.rawMessage.length; i++) {\n msg += i % 2 < 1 ? record.rawMessage[i] : \"{}\";\n }\n return msg;\n };\n } else {\n getMessage = (record: LogRecord): string => {\n let msg = \"\";\n for (let i = 0; i < record.message.length; i++) {\n msg += i % 2 < 1\n ? record.message[i]\n : JSON.stringify(record.message[i]);\n }\n return msg;\n };\n }\n\n const propertiesOption = options.properties ?? \"nest:properties\";\n let getProperties: (\n properties: Record<string, unknown>,\n ) => Record<string, unknown>;\n if (propertiesOption === \"flatten\") {\n getProperties = (properties) => properties;\n } else if (propertiesOption.startsWith(\"prepend:\")) {\n const prefix = propertiesOption.substring(8);\n if (prefix === \"\") {\n throw new TypeError(\n `Invalid properties option: ${\n JSON.stringify(propertiesOption)\n }. It must be of the form \"prepend:<prefix>\" where <prefix> is a non-empty string.`,\n );\n }\n getProperties = (properties) => {\n const result: Record<string, unknown> = {};\n for (const key in properties) {\n result[`${prefix}${key}`] = properties[key];\n }\n return result;\n };\n } else if (propertiesOption.startsWith(\"nest:\")) {\n const key = propertiesOption.substring(5);\n getProperties = (properties) => ({ [key]: properties });\n } else {\n throw new TypeError(\n `Invalid properties option: ${\n JSON.stringify(propertiesOption)\n }. It must be \"flatten\", \"prepend:<prefix>\", or \"nest:<key>\".`,\n );\n }\n\n return (record: LogRecord): string => {\n return JSON.stringify({\n \"@timestamp\": new Date(record.timestamp).toISOString(),\n level: record.level === \"warning\" ? \"WARN\" : record.level.toUpperCase(),\n message: getMessage(record),\n logger: joinCategory(record.category),\n ...getProperties(record.properties),\n });\n };\n}\n\n/**\n * The default [JSON Lines] formatter. This formatter formats log records\n * as JSON objects, one per line, which is a common format for log files.\n * It looks like this:\n *\n * ```json\n * {\"@timestamp\":\"2023-11-14T22:13:20.000Z\",\"level\":\"INFO\",\"message\":\"Hello, world!\",\"logger\":\"my.logger\",\"properties\":{\"key\":\"value\"}}\n * ```\n *\n * You can customize the output by passing options to\n * {@link getJsonLinesFormatter}. For example, you can change the category\n * separator, the message format, and how the properties are formatted.\n *\n * [JSON Lines]: https://jsonlines.org/\n * @since 0.11.0\n */\nexport const jsonLinesFormatter: TextFormatter = getJsonLinesFormatter();\n\n/**\n * A console formatter is a function that accepts a log record and returns\n * an array of arguments to pass to {@link console.log}.\n *\n * @param record The log record to format.\n * @returns The formatted log record, as an array of arguments for\n * {@link console.log}.\n */\nexport type ConsoleFormatter = (record: LogRecord) => readonly unknown[];\n\n/**\n * The styles for the log level in the console.\n */\nconst logLevelStyles: Record<LogLevel, string> = {\n \"debug\": \"background-color: gray; color: white;\",\n \"info\": \"background-color: white; color: black;\",\n \"warning\": \"background-color: orange; color: black;\",\n \"error\": \"background-color: red; color: white;\",\n \"fatal\": \"background-color: maroon; color: white;\",\n};\n\n/**\n * The default console formatter.\n *\n * @param record The log record to format.\n * @returns The formatted log record, as an array of arguments for\n * {@link console.log}.\n */\nexport function defaultConsoleFormatter(record: LogRecord): readonly unknown[] {\n let msg = \"\";\n const values: unknown[] = [];\n for (let i = 0; i < record.message.length; i++) {\n if (i % 2 === 0) msg += record.message[i];\n else {\n msg += \"%o\";\n values.push(record.message[i]);\n }\n }\n const date = new Date(record.timestamp);\n const time = `${date.getUTCHours().toString().padStart(2, \"0\")}:${\n date.getUTCMinutes().toString().padStart(2, \"0\")\n }:${date.getUTCSeconds().toString().padStart(2, \"0\")}.${\n date.getUTCMilliseconds().toString().padStart(3, \"0\")\n }`;\n return [\n `%c${time} %c${levelAbbreviations[record.level]}%c %c${\n record.category.join(\"\\xb7\")\n } %c${msg}`,\n \"color: gray;\",\n logLevelStyles[record.level],\n \"background-color: default;\",\n \"color: gray;\",\n \"color: default;\",\n ...values,\n ];\n}\n"],"mappings":";;;;;;AAgBA,MAAMA,qBAA+C;CACnD,SAAS;CACT,QAAQ;CACR,WAAW;CACX,SAAS;CACT,SAAS;AACV;;;;;;;;;;;AAYD,MAAMC,iBAGG,aAAa,sBAGX,cAAc,eAAe,UAAU,YAAY,gBACxD,CAAC,MAAM,KAAK,UAAU,EAAE,GAGxB,UAAU,cAAc,aAAa,WAAW,eAGvC,WAAW,KAAK,YAAY,aACrC,CAAC,GAAG,SAGJ,WAAW,KAAK,QAAQ,GAAG;CACzB,mBAAmB;CACnB,eAAe;CACf,GAAG;AACJ,EAAC,GAGF,QAAQ,QAAQ,aAAa,eAAe,KAAK,YAAY,aAC7D,CAAC,GAAG,SAGJ,KAAK,QAAQ,GAAG;CACd,gBAAgB;CAChB,iBAAiB;CACjB,GAAG;AACJ,EAAC,GACF,CAAC,MAAM,KAAK,UAAU,EAAE;;;;;;;;;;;;;;;;;;AAgK9B,SAAgB,iBACdC,UAAgC,CAAE,GACnB;CACf,MAAM,oBACJ,QAAQ,aAAa,QAAQ,QAAQ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MAAM,aAAa;GACvE,SAAS,WAAW,OAAO;GAC3B,QAAQ,aAAa,OAAO,SAAS;GACrC,GAAG,cAAc,OAAO,WAAW;EACpC,EAAC;CACH;AACF;;;;;;;;;;;;;;;;;AAkBD,MAAae,qBAAoC,uBAAuB;;;;AAexE,MAAMC,iBAA2C;CAC/C,SAAS;CACT,QAAQ;CACR,WAAW;CACX,SAAS;CACT,SAAS;AACV;;;;;;;;AASD,SAAgB,wBAAwBhB,QAAuC;CAC7E,IAAI,MAAM;CACV,MAAMiB,SAAoB,CAAE;AAC5B,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,QAAQ,IACzC,KAAI,IAAI,MAAM,EAAG,QAAO,OAAO,QAAQ;MAClC;AACH,SAAO;AACP,SAAO,KAAK,OAAO,QAAQ,GAAG;CAC/B;CAEH,MAAM,OAAO,IAAI,KAAK,OAAO;CAC7B,MAAM,QAAQ,EAAE,KAAK,aAAa,CAAC,UAAU,CAAC,SAAS,GAAG,IAAI,CAAC,GAC7D,KAAK,eAAe,CAAC,UAAU,CAAC,SAAS,GAAG,IAAI,CACjD,GAAG,KAAK,eAAe,CAAC,UAAU,CAAC,SAAS,GAAG,IAAI,CAAC,GACnD,KAAK,oBAAoB,CAAC,UAAU,CAAC,SAAS,GAAG,IAAI,CACtD;AACD,QAAO;GACJ,IAAI,KAAK,KAAK,mBAAmB,OAAO,OAAO,OAC9C,OAAO,SAAS,KAAK,IAAO,CAC7B,KAAK,IAAI;EACV;EACA,eAAe,OAAO;EACtB;EACA;EACA;EACA,GAAG;CACJ;AACF"}
|
|
1
|
+
{"version":3,"file":"formatter.js","names":["levelAbbreviations: Record<LogLevel, string>","inspect: (value: unknown, options?: { colors?: boolean }) => string","options: TextFormatterOptions","ts: number","level: LogLevel","formatter: (values: FormattedValues) => string","record: LogRecord","values: FormattedValues","defaultTextFormatter: TextFormatter","ansiColors: Record<AnsiColor, string>","ansiStyles: Record<AnsiStyle, string>","defaultLevelColors: Record<LogLevel, AnsiColor | null>","options: AnsiColorFormatterOptions","value: unknown","ansiColorFormatter: TextFormatter","options: JsonLinesFormatterOptions","joinCategory: (category: readonly string[]) => string | readonly string[]","category: readonly string[]","getMessage: TextFormatter","getProperties: (\n properties: Record<string, unknown>,\n ) => Record<string, unknown>","result: Record<string, unknown>","jsonLinesFormatter: TextFormatter","logLevelStyles: Record<LogLevel, string>","values: unknown[]"],"sources":["../formatter.ts"],"sourcesContent":["import * as util from \"#util\";\nimport type { LogLevel } from \"./level.ts\";\nimport type { LogRecord } from \"./record.ts\";\n\n/**\n * A text formatter is a function that accepts a log record and returns\n * a string.\n *\n * @param record The log record to format.\n * @returns The formatted log record.\n */\nexport type TextFormatter = (record: LogRecord) => string;\n\n/**\n * The severity level abbreviations.\n */\nconst levelAbbreviations: Record<LogLevel, string> = {\n \"trace\": \"TRC\",\n \"debug\": \"DBG\",\n \"info\": \"INF\",\n \"warning\": \"WRN\",\n \"error\": \"ERR\",\n \"fatal\": \"FTL\",\n};\n\n/**\n * A platform-specific inspect function. In Deno, this is {@link Deno.inspect},\n * and in Node.js/Bun it is `util.inspect()`. If neither is available, it\n * falls back to {@link JSON.stringify}.\n *\n * @param value The value to inspect.\n * @param options The options for inspecting the value.\n * If `colors` is `true`, the output will be ANSI-colored.\n * @returns The string representation of the value.\n */\nconst inspect: (value: unknown, options?: { colors?: boolean }) => string =\n // @ts-ignore: Browser detection\n // dnt-shim-ignore\n typeof document !== \"undefined\" ||\n // @ts-ignore: React Native detection\n // dnt-shim-ignore\n typeof navigator !== \"undefined\" && navigator.product === \"ReactNative\"\n ? (v) => JSON.stringify(v)\n // @ts-ignore: Deno global\n // dnt-shim-ignore\n : \"Deno\" in globalThis && \"inspect\" in globalThis.Deno &&\n // @ts-ignore: Deno global\n // dnt-shim-ignore\n typeof globalThis.Deno.inspect === \"function\"\n ? (v, opts) =>\n // @ts-ignore: Deno global\n // dnt-shim-ignore\n globalThis.Deno.inspect(v, {\n strAbbreviateSize: Infinity,\n iterableLimit: Infinity,\n ...opts,\n })\n // @ts-ignore: Node.js global\n // dnt-shim-ignore\n : util != null && \"inspect\" in util && typeof util.inspect === \"function\"\n ? (v, opts) =>\n // @ts-ignore: Node.js global\n // dnt-shim-ignore\n util.inspect(v, {\n maxArrayLength: Infinity,\n maxStringLength: Infinity,\n ...opts,\n })\n : (v) => JSON.stringify(v);\n\n/**\n * The formatted values for a log record.\n * @since 0.6.0\n */\nexport interface FormattedValues {\n /**\n * The formatted timestamp.\n */\n timestamp: string | null;\n\n /**\n * The formatted log level.\n */\n level: string;\n\n /**\n * The formatted category.\n */\n category: string;\n\n /**\n * The formatted message.\n */\n message: string;\n\n /**\n * The unformatted log record.\n */\n record: LogRecord;\n}\n\n/**\n * The various options for the built-in text formatters.\n * @since 0.6.0\n */\nexport interface TextFormatterOptions {\n /**\n * The timestamp format. This can be one of the following:\n *\n * - `\"date-time-timezone\"`: The date and time with the full timezone offset\n * (e.g., `\"2023-11-14 22:13:20.000 +00:00\"`).\n * - `\"date-time-tz\"`: The date and time with the short timezone offset\n * (e.g., `\"2023-11-14 22:13:20.000 +00\"`).\n * - `\"date-time\"`: The date and time without the timezone offset\n * (e.g., `\"2023-11-14 22:13:20.000\"`).\n * - `\"time-timezone\"`: The time with the full timezone offset but without\n * the date (e.g., `\"22:13:20.000 +00:00\"`).\n * - `\"time-tz\"`: The time with the short timezone offset but without the date\n * (e.g., `\"22:13:20.000 +00\"`).\n * - `\"time\"`: The time without the date or timezone offset\n * (e.g., `\"22:13:20.000\"`).\n * - `\"date\"`: The date without the time or timezone offset\n * (e.g., `\"2023-11-14\"`).\n * - `\"rfc3339\"`: The date and time in RFC 3339 format\n * (e.g., `\"2023-11-14T22:13:20.000Z\"`).\n * - `\"none\"` or `\"disabled\"`: No display\n *\n * Alternatively, this can be a function that accepts a timestamp and returns\n * a string.\n *\n * The default is `\"date-time-timezone\"`.\n */\n timestamp?:\n | \"date-time-timezone\"\n | \"date-time-tz\"\n | \"date-time\"\n | \"time-timezone\"\n | \"time-tz\"\n | \"time\"\n | \"date\"\n | \"rfc3339\"\n | \"none\"\n | \"disabled\"\n | ((ts: number) => string | null);\n\n /**\n * The log level format. This can be one of the following:\n *\n * - `\"ABBR\"`: The log level abbreviation in uppercase (e.g., `\"INF\"`).\n * - `\"FULL\"`: The full log level name in uppercase (e.g., `\"INFO\"`).\n * - `\"L\"`: The first letter of the log level in uppercase (e.g., `\"I\"`).\n * - `\"abbr\"`: The log level abbreviation in lowercase (e.g., `\"inf\"`).\n * - `\"full\"`: The full log level name in lowercase (e.g., `\"info\"`).\n * - `\"l\"`: The first letter of the log level in lowercase (e.g., `\"i\"`).\n *\n * Alternatively, this can be a function that accepts a log level and returns\n * a string.\n *\n * The default is `\"ABBR\"`.\n */\n level?:\n | \"ABBR\"\n | \"FULL\"\n | \"L\"\n | \"abbr\"\n | \"full\"\n | \"l\"\n | ((level: LogLevel) => string);\n\n /**\n * The separator between category names. For example, if the separator is\n * `\"·\"`, the category `[\"a\", \"b\", \"c\"]` will be formatted as `\"a·b·c\"`.\n * The default separator is `\"·\"`.\n *\n * If this is a function, it will be called with the category array and\n * should return a string, which will be used for rendering the category.\n */\n category?: string | ((category: readonly string[]) => string);\n\n /**\n * The format of the embedded values.\n *\n * A function that renders a value to a string. This function is used to\n * render the values in the log record. The default is [`util.inspect()`] in\n * Node.js/Bun and [`Deno.inspect()`] in Deno.\n *\n * [`util.inspect()`]: https://nodejs.org/api/util.html#utilinspectobject-options\n * [`Deno.inspect()`]: https://docs.deno.com/api/deno/~/Deno.inspect\n * @param value The value to render.\n * @returns The string representation of the value.\n */\n value?: (value: unknown) => string;\n\n /**\n * How those formatted parts are concatenated.\n *\n * A function that formats the log record. This function is called with the\n * formatted values and should return a string. Note that the formatted\n * *should not* include a newline character at the end.\n *\n * By default, this is a function that formats the log record as follows:\n *\n * ```\n * 2023-11-14 22:13:20.000 +00:00 [INF] category·subcategory: Hello, world!\n * ```\n * @param values The formatted values.\n * @returns The formatted log record.\n */\n format?: (values: FormattedValues) => string;\n}\n\n/**\n * Get a text formatter with the specified options. Although it's flexible\n * enough to create a custom formatter, if you want more control, you can\n * create a custom formatter that satisfies the {@link TextFormatter} type\n * instead.\n *\n * For more information on the options, see {@link TextFormatterOptions}.\n *\n * By default, the formatter formats log records as follows:\n *\n * ```\n * 2023-11-14 22:13:20.000 +00:00 [INF] category·subcategory: Hello, world!\n * ```\n * @param options The options for the text formatter.\n * @returns The text formatter.\n * @since 0.6.0\n */\nexport function getTextFormatter(\n options: TextFormatterOptions = {},\n): TextFormatter {\n const timestampRenderer =\n options.timestamp == null || options.timestamp === \"date-time-timezone\"\n ? (ts: number): string =>\n new Date(ts).toISOString().replace(\"T\", \" \").replace(\"Z\", \" +00:00\")\n : options.timestamp === \"date-time-tz\"\n ? (ts: number): string =>\n new Date(ts).toISOString().replace(\"T\", \" \").replace(\"Z\", \" +00\")\n : options.timestamp === \"date-time\"\n ? (ts: number): string =>\n new Date(ts).toISOString().replace(\"T\", \" \").replace(\"Z\", \"\")\n : options.timestamp === \"time-timezone\"\n ? (ts: number): string =>\n new Date(ts).toISOString().replace(/.*T/, \"\").replace(\"Z\", \" +00:00\")\n : options.timestamp === \"time-tz\"\n ? (ts: number): string =>\n new Date(ts).toISOString().replace(/.*T/, \"\").replace(\"Z\", \" +00\")\n : options.timestamp === \"time\"\n ? (ts: number): string =>\n new Date(ts).toISOString().replace(/.*T/, \"\").replace(\"Z\", \"\")\n : options.timestamp === \"date\"\n ? (ts: number): string => new Date(ts).toISOString().replace(/T.*/, \"\")\n : options.timestamp === \"rfc3339\"\n ? (ts: number): string => new Date(ts).toISOString()\n : options.timestamp === \"none\" || options.timestamp === \"disabled\"\n ? () => null\n : options.timestamp;\n const categorySeparator = options.category ?? \"·\";\n const valueRenderer = options.value ?? inspect;\n const levelRenderer = options.level == null || options.level === \"ABBR\"\n ? (level: LogLevel): string => levelAbbreviations[level]\n : options.level === \"abbr\"\n ? (level: LogLevel): string => levelAbbreviations[level].toLowerCase()\n : options.level === \"FULL\"\n ? (level: LogLevel): string => level.toUpperCase()\n : options.level === \"full\"\n ? (level: LogLevel): string => level\n : options.level === \"L\"\n ? (level: LogLevel): string => level.charAt(0).toUpperCase()\n : options.level === \"l\"\n ? (level: LogLevel): string => level.charAt(0)\n : options.level;\n const formatter: (values: FormattedValues) => string = options.format ??\n (({ timestamp, level, category, message }: FormattedValues) =>\n `${timestamp ? `${timestamp} ` : \"\"}[${level}] ${category}: ${message}`);\n return (record: LogRecord): string => {\n let message = \"\";\n for (let i = 0; i < record.message.length; i++) {\n if (i % 2 === 0) message += record.message[i];\n else message += valueRenderer(record.message[i]);\n }\n const timestamp = timestampRenderer(record.timestamp);\n const level = levelRenderer(record.level);\n const category = typeof categorySeparator === \"function\"\n ? categorySeparator(record.category)\n : record.category.join(categorySeparator);\n const values: FormattedValues = {\n timestamp,\n level,\n category,\n message,\n record,\n };\n return `${formatter(values)}\\n`;\n };\n}\n\n/**\n * The default text formatter. This formatter formats log records as follows:\n *\n * ```\n * 2023-11-14 22:13:20.000 +00:00 [INF] category·subcategory: Hello, world!\n * ```\n *\n * @param record The log record to format.\n * @returns The formatted log record.\n */\nexport const defaultTextFormatter: TextFormatter = getTextFormatter();\n\nconst RESET = \"\\x1b[0m\";\n\n/**\n * The ANSI colors. These can be used to colorize text in the console.\n * @since 0.6.0\n */\nexport type AnsiColor =\n | \"black\"\n | \"red\"\n | \"green\"\n | \"yellow\"\n | \"blue\"\n | \"magenta\"\n | \"cyan\"\n | \"white\";\n\nconst ansiColors: Record<AnsiColor, string> = {\n black: \"\\x1b[30m\",\n red: \"\\x1b[31m\",\n green: \"\\x1b[32m\",\n yellow: \"\\x1b[33m\",\n blue: \"\\x1b[34m\",\n magenta: \"\\x1b[35m\",\n cyan: \"\\x1b[36m\",\n white: \"\\x1b[37m\",\n};\n\n/**\n * The ANSI text styles.\n * @since 0.6.0\n */\nexport type AnsiStyle =\n | \"bold\"\n | \"dim\"\n | \"italic\"\n | \"underline\"\n | \"strikethrough\";\n\nconst ansiStyles: Record<AnsiStyle, string> = {\n bold: \"\\x1b[1m\",\n dim: \"\\x1b[2m\",\n italic: \"\\x1b[3m\",\n underline: \"\\x1b[4m\",\n strikethrough: \"\\x1b[9m\",\n};\n\nconst defaultLevelColors: Record<LogLevel, AnsiColor | null> = {\n trace: null,\n debug: \"blue\",\n info: \"green\",\n warning: \"yellow\",\n error: \"red\",\n fatal: \"magenta\",\n};\n\n/**\n * The various options for the ANSI color formatter.\n * @since 0.6.0\n */\nexport interface AnsiColorFormatterOptions extends TextFormatterOptions {\n /**\n * The timestamp format. This can be one of the following:\n *\n * - `\"date-time-timezone\"`: The date and time with the full timezone offset\n * (e.g., `\"2023-11-14 22:13:20.000 +00:00\"`).\n * - `\"date-time-tz\"`: The date and time with the short timezone offset\n * (e.g., `\"2023-11-14 22:13:20.000 +00\"`).\n * - `\"date-time\"`: The date and time without the timezone offset\n * (e.g., `\"2023-11-14 22:13:20.000\"`).\n * - `\"time-timezone\"`: The time with the full timezone offset but without\n * the date (e.g., `\"22:13:20.000 +00:00\"`).\n * - `\"time-tz\"`: The time with the short timezone offset but without the date\n * (e.g., `\"22:13:20.000 +00\"`).\n * - `\"time\"`: The time without the date or timezone offset\n * (e.g., `\"22:13:20.000\"`).\n * - `\"date\"`: The date without the time or timezone offset\n * (e.g., `\"2023-11-14\"`).\n * - `\"rfc3339\"`: The date and time in RFC 3339 format\n * (e.g., `\"2023-11-14T22:13:20.000Z\"`).\n *\n * Alternatively, this can be a function that accepts a timestamp and returns\n * a string.\n *\n * The default is `\"date-time-tz\"`.\n */\n timestamp?:\n | \"date-time-timezone\"\n | \"date-time-tz\"\n | \"date-time\"\n | \"time-timezone\"\n | \"time-tz\"\n | \"time\"\n | \"date\"\n | \"rfc3339\"\n | ((ts: number) => string);\n\n /**\n * The ANSI style for the timestamp. `\"dim\"` is used by default.\n */\n timestampStyle?: AnsiStyle | null;\n\n /**\n * The ANSI color for the timestamp. No color is used by default.\n */\n timestampColor?: AnsiColor | null;\n\n /**\n * The ANSI style for the log level. `\"bold\"` is used by default.\n */\n levelStyle?: AnsiStyle | null;\n\n /**\n * The ANSI colors for the log levels. The default colors are as follows:\n *\n * - `\"trace\"`: `null` (no color)\n * - `\"debug\"`: `\"blue\"`\n * - `\"info\"`: `\"green\"`\n * - `\"warning\"`: `\"yellow\"`\n * - `\"error\"`: `\"red\"`\n * - `\"fatal\"`: `\"magenta\"`\n */\n levelColors?: Record<LogLevel, AnsiColor | null>;\n\n /**\n * The ANSI style for the category. `\"dim\"` is used by default.\n */\n categoryStyle?: AnsiStyle | null;\n\n /**\n * The ANSI color for the category. No color is used by default.\n */\n categoryColor?: AnsiColor | null;\n}\n\n/**\n * Get an ANSI color formatter with the specified options.\n *\n * \n * @param option The options for the ANSI color formatter.\n * @returns The ANSI color formatter.\n * @since 0.6.0\n */\nexport function getAnsiColorFormatter(\n options: AnsiColorFormatterOptions = {},\n): TextFormatter {\n const format = options.format;\n const timestampStyle = typeof options.timestampStyle === \"undefined\"\n ? \"dim\"\n : options.timestampStyle;\n const timestampColor = options.timestampColor ?? null;\n const timestampPrefix = `${\n timestampStyle == null ? \"\" : ansiStyles[timestampStyle]\n }${timestampColor == null ? \"\" : ansiColors[timestampColor]}`;\n const timestampSuffix = timestampStyle == null && timestampColor == null\n ? \"\"\n : RESET;\n const levelStyle = typeof options.levelStyle === \"undefined\"\n ? \"bold\"\n : options.levelStyle;\n const levelColors = options.levelColors ?? defaultLevelColors;\n const categoryStyle = typeof options.categoryStyle === \"undefined\"\n ? \"dim\"\n : options.categoryStyle;\n const categoryColor = options.categoryColor ?? null;\n const categoryPrefix = `${\n categoryStyle == null ? \"\" : ansiStyles[categoryStyle]\n }${categoryColor == null ? \"\" : ansiColors[categoryColor]}`;\n const categorySuffix = categoryStyle == null && categoryColor == null\n ? \"\"\n : RESET;\n return getTextFormatter({\n timestamp: \"date-time-tz\",\n value(value: unknown): string {\n return inspect(value, { colors: true });\n },\n ...options,\n format({ timestamp, level, category, message, record }): string {\n const levelColor = levelColors[record.level];\n timestamp = `${timestampPrefix}${timestamp}${timestampSuffix}`;\n level = `${levelStyle == null ? \"\" : ansiStyles[levelStyle]}${\n levelColor == null ? \"\" : ansiColors[levelColor]\n }${level}${levelStyle == null && levelColor == null ? \"\" : RESET}`;\n return format == null\n ? `${timestamp} ${level} ${categoryPrefix}${category}:${categorySuffix} ${message}`\n : format({\n timestamp,\n level,\n category: `${categoryPrefix}${category}${categorySuffix}`,\n message,\n record,\n });\n },\n });\n}\n\n/**\n * A text formatter that uses ANSI colors to format log records.\n *\n * \n *\n * @param record The log record to format.\n * @returns The formatted log record.\n * @since 0.5.0\n */\nexport const ansiColorFormatter: TextFormatter = getAnsiColorFormatter();\n\n/**\n * Options for the {@link getJsonLinesFormatter} function.\n * @since 0.11.0\n */\nexport interface JsonLinesFormatterOptions {\n /**\n * The separator between category names. For example, if the separator is\n * `\".\"`, the category `[\"a\", \"b\", \"c\"]` will be formatted as `\"a.b.c\"`.\n * If this is a function, it will be called with the category array and\n * should return a string or an array of strings, which will be used\n * for rendering the category.\n *\n * @default `\".\"`\n */\n readonly categorySeparator?:\n | string\n | ((category: readonly string[]) => string | readonly string[]);\n\n /**\n * The message format. This can be one of the following:\n *\n * - `\"template\"`: The raw message template is used as the message.\n * - `\"rendered\"`: The message is rendered with the values.\n *\n * @default `\"rendered\"`\n */\n readonly message?: \"template\" | \"rendered\";\n\n /**\n * The properties format. This can be one of the following:\n *\n * - `\"flatten\"`: The properties are flattened into the root object.\n * - `\"prepend:<prefix>\"`: The properties are prepended with the given prefix\n * (e.g., `\"prepend:ctx_\"` will prepend `ctx_` to each property key).\n * - `\"nest:<key>\"`: The properties are nested under the given key\n * (e.g., `\"nest:properties\"` will nest the properties under the\n * `properties` key).\n *\n * @default `\"nest:properties\"`\n */\n readonly properties?: \"flatten\" | `prepend:${string}` | `nest:${string}`;\n}\n\n/**\n * Get a [JSON Lines] formatter with the specified options. The log records\n * will be rendered as JSON objects, one per line, which is a common format\n * for log files. This format is also known as Newline-Delimited JSON (NDJSON).\n * It looks like this:\n *\n * ```json\n * {\"@timestamp\":\"2023-11-14T22:13:20.000Z\",\"level\":\"INFO\",\"message\":\"Hello, world!\",\"logger\":\"my.logger\",\"properties\":{\"key\":\"value\"}}\n * ```\n *\n * [JSON Lines]: https://jsonlines.org/\n * @param options The options for the JSON Lines formatter.\n * @returns The JSON Lines formatter.\n * @since 0.11.0\n */\nexport function getJsonLinesFormatter(\n options: JsonLinesFormatterOptions = {},\n): TextFormatter {\n let joinCategory: (category: readonly string[]) => string | readonly string[];\n if (typeof options.categorySeparator === \"function\") {\n joinCategory = options.categorySeparator;\n } else {\n const separator = options.categorySeparator ?? \".\";\n joinCategory = (category: readonly string[]): string =>\n category.join(separator);\n }\n\n let getMessage: TextFormatter;\n if (options.message === \"template\") {\n getMessage = (record: LogRecord): string => {\n if (typeof record.rawMessage === \"string\") {\n return record.rawMessage;\n }\n let msg = \"\";\n for (let i = 0; i < record.rawMessage.length; i++) {\n msg += i % 2 < 1 ? record.rawMessage[i] : \"{}\";\n }\n return msg;\n };\n } else {\n getMessage = (record: LogRecord): string => {\n let msg = \"\";\n for (let i = 0; i < record.message.length; i++) {\n msg += i % 2 < 1\n ? record.message[i]\n : JSON.stringify(record.message[i]);\n }\n return msg;\n };\n }\n\n const propertiesOption = options.properties ?? \"nest:properties\";\n let getProperties: (\n properties: Record<string, unknown>,\n ) => Record<string, unknown>;\n if (propertiesOption === \"flatten\") {\n getProperties = (properties) => properties;\n } else if (propertiesOption.startsWith(\"prepend:\")) {\n const prefix = propertiesOption.substring(8);\n if (prefix === \"\") {\n throw new TypeError(\n `Invalid properties option: ${\n JSON.stringify(propertiesOption)\n }. It must be of the form \"prepend:<prefix>\" where <prefix> is a non-empty string.`,\n );\n }\n getProperties = (properties) => {\n const result: Record<string, unknown> = {};\n for (const key in properties) {\n result[`${prefix}${key}`] = properties[key];\n }\n return result;\n };\n } else if (propertiesOption.startsWith(\"nest:\")) {\n const key = propertiesOption.substring(5);\n getProperties = (properties) => ({ [key]: properties });\n } else {\n throw new TypeError(\n `Invalid properties option: ${\n JSON.stringify(propertiesOption)\n }. It must be \"flatten\", \"prepend:<prefix>\", or \"nest:<key>\".`,\n );\n }\n\n return (record: LogRecord): string => {\n return JSON.stringify({\n \"@timestamp\": new Date(record.timestamp).toISOString(),\n level: record.level === \"warning\" ? \"WARN\" : record.level.toUpperCase(),\n message: getMessage(record),\n logger: joinCategory(record.category),\n ...getProperties(record.properties),\n });\n };\n}\n\n/**\n * The default [JSON Lines] formatter. This formatter formats log records\n * as JSON objects, one per line, which is a common format for log files.\n * It looks like this:\n *\n * ```json\n * {\"@timestamp\":\"2023-11-14T22:13:20.000Z\",\"level\":\"INFO\",\"message\":\"Hello, world!\",\"logger\":\"my.logger\",\"properties\":{\"key\":\"value\"}}\n * ```\n *\n * You can customize the output by passing options to\n * {@link getJsonLinesFormatter}. For example, you can change the category\n * separator, the message format, and how the properties are formatted.\n *\n * [JSON Lines]: https://jsonlines.org/\n * @since 0.11.0\n */\nexport const jsonLinesFormatter: TextFormatter = getJsonLinesFormatter();\n\n/**\n * A console formatter is a function that accepts a log record and returns\n * an array of arguments to pass to {@link console.log}.\n *\n * @param record The log record to format.\n * @returns The formatted log record, as an array of arguments for\n * {@link console.log}.\n */\nexport type ConsoleFormatter = (record: LogRecord) => readonly unknown[];\n\n/**\n * The styles for the log level in the console.\n */\nconst logLevelStyles: Record<LogLevel, string> = {\n \"trace\": \"background-color: gray; color: white;\",\n \"debug\": \"background-color: gray; color: white;\",\n \"info\": \"background-color: white; color: black;\",\n \"warning\": \"background-color: orange; color: black;\",\n \"error\": \"background-color: red; color: white;\",\n \"fatal\": \"background-color: maroon; color: white;\",\n};\n\n/**\n * The default console formatter.\n *\n * @param record The log record to format.\n * @returns The formatted log record, as an array of arguments for\n * {@link console.log}.\n */\nexport function defaultConsoleFormatter(record: LogRecord): readonly unknown[] {\n let msg = \"\";\n const values: unknown[] = [];\n for (let i = 0; i < record.message.length; i++) {\n if (i % 2 === 0) msg += record.message[i];\n else {\n msg += \"%o\";\n values.push(record.message[i]);\n }\n }\n const date = new Date(record.timestamp);\n const time = `${date.getUTCHours().toString().padStart(2, \"0\")}:${\n date.getUTCMinutes().toString().padStart(2, \"0\")\n }:${date.getUTCSeconds().toString().padStart(2, \"0\")}.${\n date.getUTCMilliseconds().toString().padStart(3, \"0\")\n }`;\n return [\n `%c${time} %c${levelAbbreviations[record.level]}%c %c${\n record.category.join(\"\\xb7\")\n } %c${msg}`,\n \"color: gray;\",\n logLevelStyles[record.level],\n \"background-color: default;\",\n \"color: gray;\",\n \"color: default;\",\n ...values,\n ];\n}\n"],"mappings":";;;;;;AAgBA,MAAMA,qBAA+C;CACnD,SAAS;CACT,SAAS;CACT,QAAQ;CACR,WAAW;CACX,SAAS;CACT,SAAS;AACV;;;;;;;;;;;AAYD,MAAMC,iBAGG,aAAa,sBAGX,cAAc,eAAe,UAAU,YAAY,gBACxD,CAAC,MAAM,KAAK,UAAU,EAAE,GAGxB,UAAU,cAAc,aAAa,WAAW,eAGvC,WAAW,KAAK,YAAY,aACrC,CAAC,GAAG,SAGJ,WAAW,KAAK,QAAQ,GAAG;CACzB,mBAAmB;CACnB,eAAe;CACf,GAAG;AACJ,EAAC,GAGF,QAAQ,QAAQ,aAAa,eAAe,KAAK,YAAY,aAC7D,CAAC,GAAG,SAGJ,KAAK,QAAQ,GAAG;CACd,gBAAgB;CAChB,iBAAiB;CACjB,GAAG;AACJ,EAAC,GACF,CAAC,MAAM,KAAK,UAAU,EAAE;;;;;;;;;;;;;;;;;;AAgK9B,SAAgB,iBACdC,UAAgC,CAAE,GACnB;CACf,MAAM,oBACJ,QAAQ,aAAa,QAAQ,QAAQ,cAAc,uBAC/C,CAACC,OACD,IAAI,KAAK,IAAI,aAAa,CAAC,QAAQ,KAAK,IAAI,CAAC,QAAQ,KAAK,UAAU,GACpE,QAAQ,cAAc,iBACtB,CAACA,OACD,IAAI,KA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;;AAkBD,MAAae,qBAAoC,uBAAuB;;;;AAexE,MAAMC,iBAA2C;CAC/C,SAAS;CACT,SAAS;CACT,QAAQ;CACR,WAAW;CACX,SAAS;CACT,SAAS;AACV;;;;;;;;AASD,SAAgB,wBAAwBhB,QAAuC;CAC7E,IAAI,MAAM;CACV,MAAMiB,SAAoB,CAAE;AAC5B,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,QAAQ,IACzC,KAAI,IAAI,MAAM,EAAG,QAAO,OAAO,QAAQ;MAClC;AACH,SAAO;AACP,SAAO,KAAK,OAAO,QAAQ,GAAG;CAC/B;CAEH,MAAM,OAAO,IAAI,KAAK,OAAO;CAC7B,MAAM,QAAQ,EAAE,KAAK,aAAa,CAAC,UAAU,CAAC,SAAS,GAAG,IAAI,CAAC,GAC7D,KAAK,eAAe,CAAC,UAAU,CAAC,SAAS,GAAG,IAAI,CACjD,GAAG,KAAK,eAAe,CAAC,UAAU,CAAC,SAAS,GAAG,IAAI,CAAC,GACnD,KAAK,oBAAoB,CAAC,UAAU,CAAC,SAAS,GAAG,IAAI,CACtD;AACD,QAAO;GACJ,IAAI,KAAK,KAAK,mBAAmB,OAAO,OAAO,OAC9C,OAAO,SAAS,KAAK,IAAO,CAC7B,KAAK,IAAI;EACV;EACA,eAAe,OAAO;EACtB;EACA;EACA;EACA,GAAG;CACJ;AACF"}
|
package/dist/level.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
//#region level.ts
|
|
3
3
|
const logLevels = [
|
|
4
|
+
"trace",
|
|
4
5
|
"debug",
|
|
5
6
|
"info",
|
|
6
7
|
"warning",
|
|
@@ -17,6 +18,7 @@ const logLevels = [
|
|
|
17
18
|
function parseLogLevel(level) {
|
|
18
19
|
level = level.toLowerCase();
|
|
19
20
|
switch (level) {
|
|
21
|
+
case "trace":
|
|
20
22
|
case "debug":
|
|
21
23
|
case "info":
|
|
22
24
|
case "warning":
|
|
@@ -34,6 +36,7 @@ function parseLogLevel(level) {
|
|
|
34
36
|
*/
|
|
35
37
|
function isLogLevel(level) {
|
|
36
38
|
switch (level) {
|
|
39
|
+
case "trace":
|
|
37
40
|
case "debug":
|
|
38
41
|
case "info":
|
|
39
42
|
case "warning":
|
package/dist/level.d.cts
CHANGED
package/dist/level.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"level.d.cts","names":[],"sources":["../level.ts"],"sourcesContent":[],"mappings":";cAAM;;
|
|
1
|
+
{"version":3,"file":"level.d.cts","names":[],"sources":["../level.ts"],"sourcesContent":[],"mappings":";cAAM;;AAYN;AASA;AAsBgB,KA/BJ,QAAA,GA+Bc,OA/BI,SA+B8B,CAAA,MAAA,CAAA;AAsB5D;;;;AAAwD;;;iBA5CxC,aAAA,iBAA8B;;;;;;;;iBAsB9B,UAAA,0BAAoC;;;;;;;;;iBAsBpC,eAAA,IAAmB,aAAa"}
|
package/dist/level.d.ts
CHANGED
package/dist/level.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"level.d.ts","names":[],"sources":["../level.ts"],"sourcesContent":[],"mappings":";cAAM;;
|
|
1
|
+
{"version":3,"file":"level.d.ts","names":[],"sources":["../level.ts"],"sourcesContent":[],"mappings":";cAAM;;AAYN;AASA;AAsBgB,KA/BJ,QAAA,GA+Bc,OA/BI,SA+B8B,CAAA,MAAA,CAAA;AAsB5D;;;;AAAwD;;;iBA5CxC,aAAA,iBAA8B;;;;;;;;iBAsB9B,UAAA,0BAAoC;;;;;;;;;iBAsBpC,eAAA,IAAmB,aAAa"}
|
package/dist/level.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
//#region level.ts
|
|
2
2
|
const logLevels = [
|
|
3
|
+
"trace",
|
|
3
4
|
"debug",
|
|
4
5
|
"info",
|
|
5
6
|
"warning",
|
|
@@ -16,6 +17,7 @@ const logLevels = [
|
|
|
16
17
|
function parseLogLevel(level) {
|
|
17
18
|
level = level.toLowerCase();
|
|
18
19
|
switch (level) {
|
|
20
|
+
case "trace":
|
|
19
21
|
case "debug":
|
|
20
22
|
case "info":
|
|
21
23
|
case "warning":
|
|
@@ -33,6 +35,7 @@ function parseLogLevel(level) {
|
|
|
33
35
|
*/
|
|
34
36
|
function isLogLevel(level) {
|
|
35
37
|
switch (level) {
|
|
38
|
+
case "trace":
|
|
36
39
|
case "debug":
|
|
37
40
|
case "info":
|
|
38
41
|
case "warning":
|
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 = [\"debug\"
|
|
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 * 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;;;;;;;;AAcD,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.cjs
CHANGED
|
@@ -31,7 +31,7 @@ var LoggerImpl = class LoggerImpl {
|
|
|
31
31
|
sinks;
|
|
32
32
|
parentSinks = "inherit";
|
|
33
33
|
filters;
|
|
34
|
-
lowestLevel = "
|
|
34
|
+
lowestLevel = "trace";
|
|
35
35
|
contextLocalStorage;
|
|
36
36
|
static getLogger(category = []) {
|
|
37
37
|
let rootLogger = globalRootLoggerSymbol in globalThis ? globalThis[globalRootLoggerSymbol] ?? null : null;
|
|
@@ -68,7 +68,7 @@ var LoggerImpl = class LoggerImpl {
|
|
|
68
68
|
while (this.sinks.length > 0) this.sinks.shift();
|
|
69
69
|
this.parentSinks = "inherit";
|
|
70
70
|
while (this.filters.length > 0) this.filters.shift();
|
|
71
|
-
this.lowestLevel = "
|
|
71
|
+
this.lowestLevel = "trace";
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
74
|
* Reset the logger and all its descendants. This removes all sinks and
|
|
@@ -189,6 +189,12 @@ var LoggerImpl = class LoggerImpl {
|
|
|
189
189
|
}
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
|
+
trace(message, ...values) {
|
|
193
|
+
if (typeof message === "string") this.log("trace", message, values[0] ?? {});
|
|
194
|
+
else if (typeof message === "function") this.logLazily("trace", message);
|
|
195
|
+
else if (!Array.isArray(message)) this.log("trace", "{*}", message);
|
|
196
|
+
else this.logTemplate("trace", message, values);
|
|
197
|
+
}
|
|
192
198
|
debug(message, ...values) {
|
|
193
199
|
if (typeof message === "string") this.log("debug", message, values[0] ?? {});
|
|
194
200
|
else if (typeof message === "function") this.logLazily("debug", message);
|
|
@@ -265,6 +271,12 @@ var LoggerCtx = class LoggerCtx {
|
|
|
265
271
|
logTemplate(level, messageTemplate, values) {
|
|
266
272
|
this.logger.logTemplate(level, messageTemplate, values, this.properties);
|
|
267
273
|
}
|
|
274
|
+
trace(message, ...values) {
|
|
275
|
+
if (typeof message === "string") this.log("trace", message, values[0] ?? {});
|
|
276
|
+
else if (typeof message === "function") this.logLazily("trace", message);
|
|
277
|
+
else if (!Array.isArray(message)) this.log("trace", "{*}", message);
|
|
278
|
+
else this.logTemplate("trace", message, values);
|
|
279
|
+
}
|
|
268
280
|
debug(message, ...values) {
|
|
269
281
|
if (typeof message === "string") this.log("debug", message, values[0] ?? {});
|
|
270
282
|
else if (typeof message === "function") this.logLazily("debug", message);
|
package/dist/logger.d.cts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* ```typescript
|
|
8
8
|
* const logger = getLogger("category");
|
|
9
|
+
* logger.trace `A trace message with ${value}`
|
|
9
10
|
* logger.debug `A debug message with ${value}.`;
|
|
10
11
|
* logger.info `An info message with ${value}.`;
|
|
11
12
|
* logger.warn `A warning message with ${value}.`;
|
|
@@ -69,6 +70,87 @@ interface Logger {
|
|
|
69
70
|
* @since 0.5.0
|
|
70
71
|
*/
|
|
71
72
|
with(properties: Record<string, unknown>): Logger;
|
|
73
|
+
/**
|
|
74
|
+
* Log a trace message. Use this as a template string prefix.
|
|
75
|
+
*
|
|
76
|
+
* ```typescript
|
|
77
|
+
* logger.trace `A trace message with ${value}.`;
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @param message The message template strings array.
|
|
81
|
+
* @param values The message template values.
|
|
82
|
+
* @since 0.12.0
|
|
83
|
+
*/
|
|
84
|
+
trace(message: TemplateStringsArray, ...values: readonly unknown[]): void;
|
|
85
|
+
/**
|
|
86
|
+
* Log a trace message with properties.
|
|
87
|
+
*
|
|
88
|
+
* ```typescript
|
|
89
|
+
* logger.trace('A trace message with {value}.', { value });
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* If the properties are expensive to compute, you can pass a callback that
|
|
93
|
+
* returns the properties:
|
|
94
|
+
*
|
|
95
|
+
* ```typescript
|
|
96
|
+
* logger.trace(
|
|
97
|
+
* 'A trace message with {value}.',
|
|
98
|
+
* () => ({ value: expensiveComputation() })
|
|
99
|
+
* );
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* @param message The message template. Placeholders to be replaced with
|
|
103
|
+
* `values` are indicated by keys in curly braces (e.g.,
|
|
104
|
+
* `{value}`).
|
|
105
|
+
* @param properties The values to replace placeholders with. For lazy
|
|
106
|
+
* evaluation, this can be a callback that returns the
|
|
107
|
+
* properties.
|
|
108
|
+
* @since 0.12.0
|
|
109
|
+
*/
|
|
110
|
+
trace(message: string, properties?: Record<string, unknown> | (() => Record<string, unknown>)): void;
|
|
111
|
+
/**
|
|
112
|
+
* Log a trace values with no message. This is useful when you
|
|
113
|
+
* want to log properties without a message, e.g., when you want to log
|
|
114
|
+
* the context of a request or an operation.
|
|
115
|
+
*
|
|
116
|
+
* ```typescript
|
|
117
|
+
* logger.trace({ method: 'GET', url: '/api/v1/resource' });
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* Note that this is a shorthand for:
|
|
121
|
+
*
|
|
122
|
+
* ```typescript
|
|
123
|
+
* logger.trace('{*}', { method: 'GET', url: '/api/v1/resource' });
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* If the properties are expensive to compute, you cannot use this shorthand
|
|
127
|
+
* and should use the following syntax instead:
|
|
128
|
+
*
|
|
129
|
+
* ```typescript
|
|
130
|
+
* logger.trace('{*}', () => ({
|
|
131
|
+
* method: expensiveMethod(),
|
|
132
|
+
* url: expensiveUrl(),
|
|
133
|
+
* }));
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* @param properties The values to log. Note that this does not take
|
|
137
|
+
* a callback.
|
|
138
|
+
* @since 0.12.0
|
|
139
|
+
*/
|
|
140
|
+
trace(properties: Record<string, unknown>): void;
|
|
141
|
+
/**
|
|
142
|
+
* Lazily log a trace message. Use this when the message values are expensive
|
|
143
|
+
* to compute and should only be computed if the message is actually logged.
|
|
144
|
+
*
|
|
145
|
+
* ```typescript
|
|
146
|
+
* logger.trace(l => l`A trace message with ${expensiveValue()}.`);
|
|
147
|
+
* ```
|
|
148
|
+
*
|
|
149
|
+
* @param callback A callback that returns the message template prefix.
|
|
150
|
+
* @throws {TypeError} If no log record was made inside the callback.
|
|
151
|
+
* @since 0.12.0
|
|
152
|
+
*/
|
|
153
|
+
trace(callback: LogCallback): void;
|
|
72
154
|
/**
|
|
73
155
|
* Log a debug message. Use this as a template string prefix.
|
|
74
156
|
*
|
|
@@ -314,6 +396,7 @@ interface Logger {
|
|
|
314
396
|
*
|
|
315
397
|
* @param message The message template strings array.
|
|
316
398
|
* @param values The message template values.
|
|
399
|
+
* @since 0.12.0
|
|
317
400
|
*/
|
|
318
401
|
warning(message: TemplateStringsArray, ...values: readonly unknown[]): void;
|
|
319
402
|
/**
|
|
@@ -339,6 +422,7 @@ interface Logger {
|
|
|
339
422
|
* @param properties The values to replace placeholders with. For lazy
|
|
340
423
|
* evaluation, this can be a callback that returns the
|
|
341
424
|
* properties.
|
|
425
|
+
* @since 0.12.0
|
|
342
426
|
*/
|
|
343
427
|
warning(message: string, properties?: Record<string, unknown> | (() => Record<string, unknown>)): void;
|
|
344
428
|
/**
|
|
@@ -368,7 +452,7 @@ interface Logger {
|
|
|
368
452
|
*
|
|
369
453
|
* @param properties The values to log. Note that this does not take
|
|
370
454
|
* a callback.
|
|
371
|
-
* @since 0.
|
|
455
|
+
* @since 0.12.0
|
|
372
456
|
*/
|
|
373
457
|
warning(properties: Record<string, unknown>): void;
|
|
374
458
|
/**
|
|
@@ -382,6 +466,7 @@ interface Logger {
|
|
|
382
466
|
*
|
|
383
467
|
* @param callback A callback that returns the message template prefix.
|
|
384
468
|
* @throws {TypeError} If no log record was made inside the callback.
|
|
469
|
+
* @since 0.12.0
|
|
385
470
|
*/
|
|
386
471
|
warning(callback: LogCallback): void;
|
|
387
472
|
/**
|
package/dist/logger.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.cts","names":[],"sources":["../logger.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.d.cts","names":[],"sources":["../logger.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;AAqSkD,UAjRjC,MAAA,CAiRiC;EAAM;;;EA0DpB,SA4BnB,QAAA,EAAA,SAAA,MAAA,EAAA;EAAM;;;;EA2DgB,SA6BtB,MAAA,EArbE,MAqbF,GAAA,IAAA;EAAM;;;;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