@logtape/logtape 1.4.0-dev.443 → 1.4.0-dev.445

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.
@@ -157,6 +157,19 @@ const levelRenderersCache = {
157
157
  function getLineEndingValue(lineEnding) {
158
158
  return lineEnding === "crlf" ? "\r\n" : "\n";
159
159
  }
160
+ function jsonReplacer(_key, value) {
161
+ if (!(value instanceof Error)) return value;
162
+ const serialized = {
163
+ name: value.name,
164
+ message: value.message
165
+ };
166
+ if (typeof value.stack === "string") serialized.stack = value.stack;
167
+ const cause = value.cause;
168
+ if (cause !== void 0) serialized.cause = cause;
169
+ if (typeof AggregateError !== "undefined" && value instanceof AggregateError) serialized.errors = value.errors;
170
+ for (const key of Object.keys(value)) if (!(key in serialized)) serialized[key] = value[key];
171
+ return serialized;
172
+ }
160
173
  /**
161
174
  * Get a text formatter with the specified options. Although it's flexible
162
175
  * enough to create a custom formatter, if you want more control, you can
@@ -333,14 +346,14 @@ function getJsonLinesFormatter(options = {}) {
333
346
  message: record.message[0] + JSON.stringify(record.message[1]) + record.message[2],
334
347
  logger: record.category.join("."),
335
348
  properties: record.properties
336
- }) + lineEnding;
349
+ }, jsonReplacer) + lineEnding;
337
350
  if (record.message.length === 1) return JSON.stringify({
338
351
  "@timestamp": new Date(record.timestamp).toISOString(),
339
352
  level: record.level === "warning" ? "WARN" : record.level.toUpperCase(),
340
353
  message: record.message[0],
341
354
  logger: record.category.join("."),
342
355
  properties: record.properties
343
- }) + lineEnding;
356
+ }, jsonReplacer) + lineEnding;
344
357
  let msg = record.message[0];
345
358
  for (let i = 1; i < record.message.length; i++) msg += i & 1 ? JSON.stringify(record.message[i]) : record.message[i];
346
359
  return JSON.stringify({
@@ -349,7 +362,7 @@ function getJsonLinesFormatter(options = {}) {
349
362
  message: msg,
350
363
  logger: record.category.join("."),
351
364
  properties: record.properties
352
- }) + lineEnding;
365
+ }, jsonReplacer) + lineEnding;
353
366
  };
354
367
  const isTemplateMessage = options.message === "template";
355
368
  const propertiesOption = options.properties ?? "nest:properties";
@@ -394,7 +407,7 @@ function getJsonLinesFormatter(options = {}) {
394
407
  message: getMessage(record),
395
408
  logger: joinCategory(record.category),
396
409
  ...getProperties(record.properties)
397
- }) + lineEnding;
410
+ }, jsonReplacer) + lineEnding;
398
411
  };
399
412
  }
400
413
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"formatter.d.cts","names":[],"sources":["../src/formatter.ts"],"sourcesContent":[],"mappings":";;;;;;;AAWA;AA+DA;AA+BA;;;AAiIoB,KA/NR,aAAA,GA+NQ,CAAA,MAAA,EA/NiB,SA+NjB,EAAA,GAAA,MAAA;AAAe;AAoKnC;;;AAEG,UAtUc,eAAA,CAsUd;EAAa;AAqGhB;AAQA;EAyBY,SAAA,EAAA,MAAS,GAAA,IAAA;EA4BJ;;;EA0CW,KAKT,EAAA,MAAA;EAAS;;;EAiBc,QAA1B,EAAA,MAAA;EAAM;;;EAhEiD,OAAA,EAAA,MAAA;EAqFvD;;;EACyB,MACtC,EAviBO,SAuiBP;AAAa;AAgEhB;AAMA;AAiEA;;AACW,UAxqBM,oBAAA,CAwqBN;EAA8B;AACzB;AA6JhB;AAUA;AAqBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mEAvyBe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAmEK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoKJ,gBAAA,WACL,uBACR;;;;;;;;;;;cAqGU,sBAAsB;;;;;KAQvB,SAAA;;;;;KAyBA,SAAA;;;;;UA4BK,yBAAA,SAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA0ChC;;;;mBAKA;;;;eAKJ;;;;;;;;;;;gBAYC,OAAO,UAAU;;;;kBAKf;;;;kBAKA;;;;;;;;;;iBAWF,qBAAA,WACL,4BACR;;;;;;;;;;cAgEU,oBAAoB;;;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;;;;;;;;iBAiED,qBAAA,WACL,4BACR;;;;;;;;;;;;;;;;;cA6JU,oBAAoB;;;;;;;;;KAUrB,gBAAA,YAA4B;;;;;;;;iBAqBxB,uBAAA,SAAgC"}
package/dist/formatter.js CHANGED
@@ -156,6 +156,19 @@ const levelRenderersCache = {
156
156
  function getLineEndingValue(lineEnding) {
157
157
  return lineEnding === "crlf" ? "\r\n" : "\n";
158
158
  }
159
+ function jsonReplacer(_key, value) {
160
+ if (!(value instanceof Error)) return value;
161
+ const serialized = {
162
+ name: value.name,
163
+ message: value.message
164
+ };
165
+ if (typeof value.stack === "string") serialized.stack = value.stack;
166
+ const cause = value.cause;
167
+ if (cause !== void 0) serialized.cause = cause;
168
+ if (typeof AggregateError !== "undefined" && value instanceof AggregateError) serialized.errors = value.errors;
169
+ for (const key of Object.keys(value)) if (!(key in serialized)) serialized[key] = value[key];
170
+ return serialized;
171
+ }
159
172
  /**
160
173
  * Get a text formatter with the specified options. Although it's flexible
161
174
  * enough to create a custom formatter, if you want more control, you can
@@ -332,14 +345,14 @@ function getJsonLinesFormatter(options = {}) {
332
345
  message: record.message[0] + JSON.stringify(record.message[1]) + record.message[2],
333
346
  logger: record.category.join("."),
334
347
  properties: record.properties
335
- }) + lineEnding;
348
+ }, jsonReplacer) + lineEnding;
336
349
  if (record.message.length === 1) return JSON.stringify({
337
350
  "@timestamp": new Date(record.timestamp).toISOString(),
338
351
  level: record.level === "warning" ? "WARN" : record.level.toUpperCase(),
339
352
  message: record.message[0],
340
353
  logger: record.category.join("."),
341
354
  properties: record.properties
342
- }) + lineEnding;
355
+ }, jsonReplacer) + lineEnding;
343
356
  let msg = record.message[0];
344
357
  for (let i = 1; i < record.message.length; i++) msg += i & 1 ? JSON.stringify(record.message[i]) : record.message[i];
345
358
  return JSON.stringify({
@@ -348,7 +361,7 @@ function getJsonLinesFormatter(options = {}) {
348
361
  message: msg,
349
362
  logger: record.category.join("."),
350
363
  properties: record.properties
351
- }) + lineEnding;
364
+ }, jsonReplacer) + lineEnding;
352
365
  };
353
366
  const isTemplateMessage = options.message === "template";
354
367
  const propertiesOption = options.properties ?? "nest:properties";
@@ -393,7 +406,7 @@ function getJsonLinesFormatter(options = {}) {
393
406
  message: getMessage(record),
394
407
  logger: joinCategory(record.category),
395
408
  ...getProperties(record.properties)
396
- }) + lineEnding;
409
+ }, jsonReplacer) + lineEnding;
397
410
  };
398
411
  }
399
412
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"formatter.js","names":["levelAbbreviations: Record<LogLevel, string>","inspect: (value: unknown, options?: { colors?: boolean }) => string","num: number","ts: number","lineEnding?: \"lf\" | \"crlf\"","options: TextFormatterOptions","v: unknown","level: LogLevel","formatter: (values: FormattedValues) => string","record: LogRecord","message: string","parts: string[]","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[]","getProperties: (\n properties: Record<string, unknown>,\n ) => Record<string, unknown>","result: Record<string, unknown>","getMessage: (record: LogRecord) => string","jsonLinesFormatter: TextFormatter","logLevelStyles: Record<LogLevel, string>","values: unknown[]"],"sources":["../src/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 a cross-runtime\n * `inspect()` function that uses [`util.inspect()`] in Node.js/Bun,\n * [`Deno.inspect()`] in Deno, or falls back to {@link JSON.stringify} in\n * browsers.\n *\n * The second parameter provides access to the default cross-runtime\n * `inspect()` function, allowing you to fall back to the default behavior\n * for certain values while customizing others. You can ignore this\n * parameter if you don't need the fallback functionality.\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 * @param inspect The default cross-runtime inspect function that can be used\n * as a fallback. Accepts an optional `options` parameter\n * with a `colors` boolean field.\n * @returns The string representation of the value.\n * @example\n * ```typescript\n * getTextFormatter({\n * value(value, inspect) {\n * // Custom formatting for numbers\n * if (typeof value === 'number') {\n * return value.toFixed(2);\n * }\n * // Fall back to default for everything else\n * return inspect(value);\n * }\n * })\n * ```\n */\n value?: (\n value: unknown,\n inspect: (value: unknown, options?: { colors?: boolean }) => string,\n ) => 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 * Line ending style for formatted output.\n *\n * - `\"lf\"`: Unix-style line endings (`\\n`)\n * - `\"crlf\"`: Windows-style line endings (`\\r\\n`)\n *\n * @default \"lf\"\n * @since 1.4.0\n */\n lineEnding?: \"lf\" | \"crlf\";\n}\n\n// Optimized helper functions for timestamp formatting\nfunction padZero(num: number): string {\n return num < 10 ? `0${num}` : `${num}`;\n}\n\nfunction padThree(num: number): string {\n return num < 10 ? `00${num}` : num < 100 ? `0${num}` : `${num}`;\n}\n\n// Pre-optimized timestamp formatter functions\nconst timestampFormatters = {\n \"date-time-timezone\": (ts: number): string => {\n const d = new Date(ts);\n const year = d.getUTCFullYear();\n const month = padZero(d.getUTCMonth() + 1);\n const day = padZero(d.getUTCDate());\n const hour = padZero(d.getUTCHours());\n const minute = padZero(d.getUTCMinutes());\n const second = padZero(d.getUTCSeconds());\n const ms = padThree(d.getUTCMilliseconds());\n return `${year}-${month}-${day} ${hour}:${minute}:${second}.${ms} +00:00`;\n },\n \"date-time-tz\": (ts: number): string => {\n const d = new Date(ts);\n const year = d.getUTCFullYear();\n const month = padZero(d.getUTCMonth() + 1);\n const day = padZero(d.getUTCDate());\n const hour = padZero(d.getUTCHours());\n const minute = padZero(d.getUTCMinutes());\n const second = padZero(d.getUTCSeconds());\n const ms = padThree(d.getUTCMilliseconds());\n return `${year}-${month}-${day} ${hour}:${minute}:${second}.${ms} +00`;\n },\n \"date-time\": (ts: number): string => {\n const d = new Date(ts);\n const year = d.getUTCFullYear();\n const month = padZero(d.getUTCMonth() + 1);\n const day = padZero(d.getUTCDate());\n const hour = padZero(d.getUTCHours());\n const minute = padZero(d.getUTCMinutes());\n const second = padZero(d.getUTCSeconds());\n const ms = padThree(d.getUTCMilliseconds());\n return `${year}-${month}-${day} ${hour}:${minute}:${second}.${ms}`;\n },\n \"time-timezone\": (ts: number): string => {\n const d = new Date(ts);\n const hour = padZero(d.getUTCHours());\n const minute = padZero(d.getUTCMinutes());\n const second = padZero(d.getUTCSeconds());\n const ms = padThree(d.getUTCMilliseconds());\n return `${hour}:${minute}:${second}.${ms} +00:00`;\n },\n \"time-tz\": (ts: number): string => {\n const d = new Date(ts);\n const hour = padZero(d.getUTCHours());\n const minute = padZero(d.getUTCMinutes());\n const second = padZero(d.getUTCSeconds());\n const ms = padThree(d.getUTCMilliseconds());\n return `${hour}:${minute}:${second}.${ms} +00`;\n },\n \"time\": (ts: number): string => {\n const d = new Date(ts);\n const hour = padZero(d.getUTCHours());\n const minute = padZero(d.getUTCMinutes());\n const second = padZero(d.getUTCSeconds());\n const ms = padThree(d.getUTCMilliseconds());\n return `${hour}:${minute}:${second}.${ms}`;\n },\n \"date\": (ts: number): string => {\n const d = new Date(ts);\n const year = d.getUTCFullYear();\n const month = padZero(d.getUTCMonth() + 1);\n const day = padZero(d.getUTCDate());\n return `${year}-${month}-${day}`;\n },\n \"rfc3339\": (ts: number): string => new Date(ts).toISOString(),\n \"none\": (): null => null,\n} as const;\n\n// Pre-computed level renderers for common cases\nconst levelRenderersCache = {\n ABBR: levelAbbreviations,\n abbr: {\n trace: \"trc\",\n debug: \"dbg\",\n info: \"inf\",\n warning: \"wrn\",\n error: \"err\",\n fatal: \"ftl\",\n } as const,\n FULL: {\n trace: \"TRACE\",\n debug: \"DEBUG\",\n info: \"INFO\",\n warning: \"WARNING\",\n error: \"ERROR\",\n fatal: \"FATAL\",\n } as const,\n full: {\n trace: \"trace\",\n debug: \"debug\",\n info: \"info\",\n warning: \"warning\",\n error: \"error\",\n fatal: \"fatal\",\n } as const,\n L: {\n trace: \"T\",\n debug: \"D\",\n info: \"I\",\n warning: \"W\",\n error: \"E\",\n fatal: \"F\",\n } as const,\n l: {\n trace: \"t\",\n debug: \"d\",\n info: \"i\",\n warning: \"w\",\n error: \"e\",\n fatal: \"f\",\n } as const,\n} as const;\n\n/**\n * Helper function to get the line ending value based on the option.\n * @param lineEnding The line ending option.\n * @returns The line ending string.\n */\nfunction getLineEndingValue(lineEnding?: \"lf\" | \"crlf\"): string {\n return lineEnding === \"crlf\" ? \"\\r\\n\" : \"\\n\";\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 // Pre-compute timestamp formatter with optimized lookup\n const timestampRenderer = (() => {\n const tsOption = options.timestamp;\n if (tsOption == null) {\n return timestampFormatters[\"date-time-timezone\"];\n } else if (tsOption === \"disabled\") {\n return timestampFormatters[\"none\"];\n } else if (\n typeof tsOption === \"string\" && tsOption in timestampFormatters\n ) {\n return timestampFormatters[tsOption as keyof typeof timestampFormatters];\n } else {\n return tsOption as (ts: number) => string | null;\n }\n })();\n\n const categorySeparator = options.category ?? \"·\";\n const valueRenderer = options.value\n ? (v: unknown) => options.value!(v, inspect)\n : inspect;\n\n // Pre-compute level renderer for better performance\n const levelRenderer = (() => {\n const levelOption = options.level;\n if (levelOption == null || levelOption === \"ABBR\") {\n return (level: LogLevel): string => levelRenderersCache.ABBR[level];\n } else if (levelOption === \"abbr\") {\n return (level: LogLevel): string => levelRenderersCache.abbr[level];\n } else if (levelOption === \"FULL\") {\n return (level: LogLevel): string => levelRenderersCache.FULL[level];\n } else if (levelOption === \"full\") {\n return (level: LogLevel): string => levelRenderersCache.full[level];\n } else if (levelOption === \"L\") {\n return (level: LogLevel): string => levelRenderersCache.L[level];\n } else if (levelOption === \"l\") {\n return (level: LogLevel): string => levelRenderersCache.l[level];\n } else {\n return levelOption;\n }\n })();\n\n const lineEnding = getLineEndingValue(options.lineEnding);\n\n const formatter: (values: FormattedValues) => string = options.format ??\n (({ timestamp, level, category, message }: FormattedValues) =>\n `${timestamp ? `${timestamp} ` : \"\"}[${level}] ${category}: ${message}`);\n\n return (record: LogRecord): string => {\n // Optimized message building\n const msgParts = record.message;\n const msgLen = msgParts.length;\n\n let message: string;\n if (msgLen === 1) {\n // Fast path for simple messages with no interpolation\n message = msgParts[0] as string;\n } else if (msgLen <= 6) {\n // Fast path for small messages - direct concatenation\n message = \"\";\n for (let i = 0; i < msgLen; i++) {\n message += (i % 2 === 0) ? msgParts[i] : valueRenderer(msgParts[i]);\n }\n } else {\n // Optimized path for larger messages - array join\n const parts: string[] = new Array(msgLen);\n for (let i = 0; i < msgLen; i++) {\n parts[i] = (i % 2 === 0)\n ? msgParts[i] as string\n : valueRenderer(msgParts[i]);\n }\n message = parts.join(\"\");\n }\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\n const values: FormattedValues = {\n timestamp,\n level,\n category,\n message,\n record,\n };\n return `${formatter(values)}${lineEnding}`;\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 | \"none\"\n | \"disabled\"\n | ((ts: number) => string | null);\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 * ![A preview of an ANSI color formatter.](https://i.imgur.com/I8LlBUf.png)\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, fallbackInspect): string {\n return fallbackInspect(value, { colors: true });\n },\n ...options,\n format({ timestamp, level, category, message, record }): string {\n const levelColor = levelColors[record.level];\n timestamp = timestamp == null\n ? null\n : `${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 ? `${\n timestamp == null ? \"\" : `${timestamp} `\n }${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 * ![A preview of ansiColorFormatter.](https://i.imgur.com/I8LlBUf.png)\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 * Line ending style for formatted output.\n *\n * - `\"lf\"`: Unix-style line endings (`\\n`)\n * - `\"crlf\"`: Windows-style line endings (`\\r\\n`)\n *\n * @default \"lf\"\n * @since 1.4.0\n */\n readonly lineEnding?: \"lf\" | \"crlf\";\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 const lineEnding = getLineEndingValue(options.lineEnding);\n\n // Most common configuration - optimize for the default case\n if (!options.categorySeparator && !options.message && !options.properties) {\n // Ultra-minimalist path - eliminate all possible overhead\n return (record: LogRecord): string => {\n // Direct benchmark pattern match (most common case first)\n if (record.message.length === 3) {\n return JSON.stringify({\n \"@timestamp\": new Date(record.timestamp).toISOString(),\n level: record.level === \"warning\"\n ? \"WARN\"\n : record.level.toUpperCase(),\n message: record.message[0] + JSON.stringify(record.message[1]) +\n record.message[2],\n logger: record.category.join(\".\"),\n properties: record.properties,\n }) + lineEnding;\n }\n\n // Single message (second most common)\n if (record.message.length === 1) {\n return JSON.stringify({\n \"@timestamp\": new Date(record.timestamp).toISOString(),\n level: record.level === \"warning\"\n ? \"WARN\"\n : record.level.toUpperCase(),\n message: record.message[0],\n logger: record.category.join(\".\"),\n properties: record.properties,\n }) + lineEnding;\n }\n\n // Complex messages (fallback)\n let msg = record.message[0] as string;\n for (let i = 1; i < record.message.length; i++) {\n msg += (i & 1) ? JSON.stringify(record.message[i]) : record.message[i];\n }\n\n return JSON.stringify({\n \"@timestamp\": new Date(record.timestamp).toISOString(),\n level: record.level === \"warning\" ? \"WARN\" : record.level.toUpperCase(),\n message: msg,\n logger: record.category.join(\".\"),\n properties: record.properties,\n }) + lineEnding;\n };\n }\n\n // Pre-compile configuration for non-default cases\n const isTemplateMessage = options.message === \"template\";\n const propertiesOption = options.properties ?? \"nest:properties\";\n\n // Pre-compile category joining strategy\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 // Pre-compile properties handling strategy\n let getProperties: (\n properties: Record<string, unknown>,\n ) => Record<string, unknown>;\n\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 // Pre-compile message rendering function\n let getMessage: (record: LogRecord) => string;\n\n if (isTemplateMessage) {\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 const msgLen = record.message.length;\n\n if (msgLen === 1) {\n return record.message[0] as string;\n }\n\n let msg = \"\";\n for (let i = 0; i < msgLen; i++) {\n msg += (i % 2 < 1)\n ? record.message[i]\n : JSON.stringify(record.message[i]);\n }\n return msg;\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 }) + lineEnding;\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;AAqL9B,SAAS,QAAQC,KAAqB;AACpC,QAAO,MAAM,MAAM,GAAG,IAAI,KAAK,EAAE,IAAI;AACtC;AAED,SAAS,SAASA,KAAqB;AACrC,QAAO,MAAM,MAAM,IAAI,IAAI,IAAI,MAAM,OAAO,GAAG,IAAI,KAAK,EAAE,IAAI;AAC/D;AAGD,MAAM,sBAAsB;CAC1B,sBAAsB,CAACC,OAAuB;EAC5C,MAAM,IAAI,IAAI,KAAK;EACnB,MAAM,OAAO,EAAE,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BAAmB,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","num: number","ts: number","lineEnding?: \"lf\" | \"crlf\"","_key: string","value: unknown","serialized: Record<string, unknown>","options: TextFormatterOptions","v: unknown","level: LogLevel","formatter: (values: FormattedValues) => string","record: LogRecord","message: string","parts: string[]","values: FormattedValues","defaultTextFormatter: TextFormatter","ansiColors: Record<AnsiColor, string>","ansiStyles: Record<AnsiStyle, string>","defaultLevelColors: Record<LogLevel, AnsiColor | null>","options: AnsiColorFormatterOptions","ansiColorFormatter: TextFormatter","options: JsonLinesFormatterOptions","joinCategory: (category: readonly string[]) => string | readonly string[]","category: readonly string[]","getProperties: (\n properties: Record<string, unknown>,\n ) => Record<string, unknown>","result: Record<string, unknown>","getMessage: (record: LogRecord) => string","jsonLinesFormatter: TextFormatter","logLevelStyles: Record<LogLevel, string>","values: unknown[]"],"sources":["../src/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 a cross-runtime\n * `inspect()` function that uses [`util.inspect()`] in Node.js/Bun,\n * [`Deno.inspect()`] in Deno, or falls back to {@link JSON.stringify} in\n * browsers.\n *\n * The second parameter provides access to the default cross-runtime\n * `inspect()` function, allowing you to fall back to the default behavior\n * for certain values while customizing others. You can ignore this\n * parameter if you don't need the fallback functionality.\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 * @param inspect The default cross-runtime inspect function that can be used\n * as a fallback. Accepts an optional `options` parameter\n * with a `colors` boolean field.\n * @returns The string representation of the value.\n * @example\n * ```typescript\n * getTextFormatter({\n * value(value, inspect) {\n * // Custom formatting for numbers\n * if (typeof value === 'number') {\n * return value.toFixed(2);\n * }\n * // Fall back to default for everything else\n * return inspect(value);\n * }\n * })\n * ```\n */\n value?: (\n value: unknown,\n inspect: (value: unknown, options?: { colors?: boolean }) => string,\n ) => 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 * Line ending style for formatted output.\n *\n * - `\"lf\"`: Unix-style line endings (`\\n`)\n * - `\"crlf\"`: Windows-style line endings (`\\r\\n`)\n *\n * @default \"lf\"\n * @since 1.4.0\n */\n lineEnding?: \"lf\" | \"crlf\";\n}\n\n// Optimized helper functions for timestamp formatting\nfunction padZero(num: number): string {\n return num < 10 ? `0${num}` : `${num}`;\n}\n\nfunction padThree(num: number): string {\n return num < 10 ? `00${num}` : num < 100 ? `0${num}` : `${num}`;\n}\n\n// Pre-optimized timestamp formatter functions\nconst timestampFormatters = {\n \"date-time-timezone\": (ts: number): string => {\n const d = new Date(ts);\n const year = d.getUTCFullYear();\n const month = padZero(d.getUTCMonth() + 1);\n const day = padZero(d.getUTCDate());\n const hour = padZero(d.getUTCHours());\n const minute = padZero(d.getUTCMinutes());\n const second = padZero(d.getUTCSeconds());\n const ms = padThree(d.getUTCMilliseconds());\n return `${year}-${month}-${day} ${hour}:${minute}:${second}.${ms} +00:00`;\n },\n \"date-time-tz\": (ts: number): string => {\n const d = new Date(ts);\n const year = d.getUTCFullYear();\n const month = padZero(d.getUTCMonth() + 1);\n const day = padZero(d.getUTCDate());\n const hour = padZero(d.getUTCHours());\n const minute = padZero(d.getUTCMinutes());\n const second = padZero(d.getUTCSeconds());\n const ms = padThree(d.getUTCMilliseconds());\n return `${year}-${month}-${day} ${hour}:${minute}:${second}.${ms} +00`;\n },\n \"date-time\": (ts: number): string => {\n const d = new Date(ts);\n const year = d.getUTCFullYear();\n const month = padZero(d.getUTCMonth() + 1);\n const day = padZero(d.getUTCDate());\n const hour = padZero(d.getUTCHours());\n const minute = padZero(d.getUTCMinutes());\n const second = padZero(d.getUTCSeconds());\n const ms = padThree(d.getUTCMilliseconds());\n return `${year}-${month}-${day} ${hour}:${minute}:${second}.${ms}`;\n },\n \"time-timezone\": (ts: number): string => {\n const d = new Date(ts);\n const hour = padZero(d.getUTCHours());\n const minute = padZero(d.getUTCMinutes());\n const second = padZero(d.getUTCSeconds());\n const ms = padThree(d.getUTCMilliseconds());\n return `${hour}:${minute}:${second}.${ms} +00:00`;\n },\n \"time-tz\": (ts: number): string => {\n const d = new Date(ts);\n const hour = padZero(d.getUTCHours());\n const minute = padZero(d.getUTCMinutes());\n const second = padZero(d.getUTCSeconds());\n const ms = padThree(d.getUTCMilliseconds());\n return `${hour}:${minute}:${second}.${ms} +00`;\n },\n \"time\": (ts: number): string => {\n const d = new Date(ts);\n const hour = padZero(d.getUTCHours());\n const minute = padZero(d.getUTCMinutes());\n const second = padZero(d.getUTCSeconds());\n const ms = padThree(d.getUTCMilliseconds());\n return `${hour}:${minute}:${second}.${ms}`;\n },\n \"date\": (ts: number): string => {\n const d = new Date(ts);\n const year = d.getUTCFullYear();\n const month = padZero(d.getUTCMonth() + 1);\n const day = padZero(d.getUTCDate());\n return `${year}-${month}-${day}`;\n },\n \"rfc3339\": (ts: number): string => new Date(ts).toISOString(),\n \"none\": (): null => null,\n} as const;\n\n// Pre-computed level renderers for common cases\nconst levelRenderersCache = {\n ABBR: levelAbbreviations,\n abbr: {\n trace: \"trc\",\n debug: \"dbg\",\n info: \"inf\",\n warning: \"wrn\",\n error: \"err\",\n fatal: \"ftl\",\n } as const,\n FULL: {\n trace: \"TRACE\",\n debug: \"DEBUG\",\n info: \"INFO\",\n warning: \"WARNING\",\n error: \"ERROR\",\n fatal: \"FATAL\",\n } as const,\n full: {\n trace: \"trace\",\n debug: \"debug\",\n info: \"info\",\n warning: \"warning\",\n error: \"error\",\n fatal: \"fatal\",\n } as const,\n L: {\n trace: \"T\",\n debug: \"D\",\n info: \"I\",\n warning: \"W\",\n error: \"E\",\n fatal: \"F\",\n } as const,\n l: {\n trace: \"t\",\n debug: \"d\",\n info: \"i\",\n warning: \"w\",\n error: \"e\",\n fatal: \"f\",\n } as const,\n} as const;\n\n/**\n * Helper function to get the line ending value based on the option.\n * @param lineEnding The line ending option.\n * @returns The line ending string.\n */\nfunction getLineEndingValue(lineEnding?: \"lf\" | \"crlf\"): string {\n return lineEnding === \"crlf\" ? \"\\r\\n\" : \"\\n\";\n}\n\nfunction jsonReplacer(_key: string, value: unknown): unknown {\n if (!(value instanceof Error)) return value;\n\n const serialized: Record<string, unknown> = {\n name: value.name,\n message: value.message,\n };\n\n if (typeof value.stack === \"string\") {\n serialized.stack = value.stack;\n }\n\n const cause = (value as { cause?: unknown }).cause;\n if (cause !== undefined) {\n serialized.cause = cause;\n }\n\n if (\n typeof AggregateError !== \"undefined\" &&\n value instanceof AggregateError\n ) {\n serialized.errors = value.errors;\n }\n\n for (const key of Object.keys(value)) {\n if (!(key in serialized)) {\n serialized[key] = (value as unknown as Record<string, unknown>)[key];\n }\n }\n\n return serialized;\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 // Pre-compute timestamp formatter with optimized lookup\n const timestampRenderer = (() => {\n const tsOption = options.timestamp;\n if (tsOption == null) {\n return timestampFormatters[\"date-time-timezone\"];\n } else if (tsOption === \"disabled\") {\n return timestampFormatters[\"none\"];\n } else if (\n typeof tsOption === \"string\" && tsOption in timestampFormatters\n ) {\n return timestampFormatters[tsOption as keyof typeof timestampFormatters];\n } else {\n return tsOption as (ts: number) => string | null;\n }\n })();\n\n const categorySeparator = options.category ?? \"·\";\n const valueRenderer = options.value\n ? (v: unknown) => options.value!(v, inspect)\n : inspect;\n\n // Pre-compute level renderer for better performance\n const levelRenderer = (() => {\n const levelOption = options.level;\n if (levelOption == null || levelOption === \"ABBR\") {\n return (level: LogLevel): string => levelRenderersCache.ABBR[level];\n } else if (levelOption === \"abbr\") {\n return (level: LogLevel): string => levelRenderersCache.abbr[level];\n } else if (levelOption === \"FULL\") {\n return (level: LogLevel): string => levelRenderersCache.FULL[level];\n } else if (levelOption === \"full\") {\n return (level: LogLevel): string => levelRenderersCache.full[level];\n } else if (levelOption === \"L\") {\n return (level: LogLevel): string => levelRenderersCache.L[level];\n } else if (levelOption === \"l\") {\n return (level: LogLevel): string => levelRenderersCache.l[level];\n } else {\n return levelOption;\n }\n })();\n\n const lineEnding = getLineEndingValue(options.lineEnding);\n\n const formatter: (values: FormattedValues) => string = options.format ??\n (({ timestamp, level, category, message }: FormattedValues) =>\n `${timestamp ? `${timestamp} ` : \"\"}[${level}] ${category}: ${message}`);\n\n return (record: LogRecord): string => {\n // Optimized message building\n const msgParts = record.message;\n const msgLen = msgParts.length;\n\n let message: string;\n if (msgLen === 1) {\n // Fast path for simple messages with no interpolation\n message = msgParts[0] as string;\n } else if (msgLen <= 6) {\n // Fast path for small messages - direct concatenation\n message = \"\";\n for (let i = 0; i < msgLen; i++) {\n message += (i % 2 === 0) ? msgParts[i] : valueRenderer(msgParts[i]);\n }\n } else {\n // Optimized path for larger messages - array join\n const parts: string[] = new Array(msgLen);\n for (let i = 0; i < msgLen; i++) {\n parts[i] = (i % 2 === 0)\n ? msgParts[i] as string\n : valueRenderer(msgParts[i]);\n }\n message = parts.join(\"\");\n }\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\n const values: FormattedValues = {\n timestamp,\n level,\n category,\n message,\n record,\n };\n return `${formatter(values)}${lineEnding}`;\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 | \"none\"\n | \"disabled\"\n | ((ts: number) => string | null);\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 * ![A preview of an ANSI color formatter.](https://i.imgur.com/I8LlBUf.png)\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, fallbackInspect): string {\n return fallbackInspect(value, { colors: true });\n },\n ...options,\n format({ timestamp, level, category, message, record }): string {\n const levelColor = levelColors[record.level];\n timestamp = timestamp == null\n ? null\n : `${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 ? `${\n timestamp == null ? \"\" : `${timestamp} `\n }${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 * ![A preview of ansiColorFormatter.](https://i.imgur.com/I8LlBUf.png)\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 * Line ending style for formatted output.\n *\n * - `\"lf\"`: Unix-style line endings (`\\n`)\n * - `\"crlf\"`: Windows-style line endings (`\\r\\n`)\n *\n * @default \"lf\"\n * @since 1.4.0\n */\n readonly lineEnding?: \"lf\" | \"crlf\";\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 const lineEnding = getLineEndingValue(options.lineEnding);\n\n // Most common configuration - optimize for the default case\n if (!options.categorySeparator && !options.message && !options.properties) {\n // Ultra-minimalist path - eliminate all possible overhead\n return (record: LogRecord): string => {\n // Direct benchmark pattern match (most common case first)\n if (record.message.length === 3) {\n return JSON.stringify({\n \"@timestamp\": new Date(record.timestamp).toISOString(),\n level: record.level === \"warning\"\n ? \"WARN\"\n : record.level.toUpperCase(),\n message: record.message[0] + JSON.stringify(record.message[1]) +\n record.message[2],\n logger: record.category.join(\".\"),\n properties: record.properties,\n }, jsonReplacer) + lineEnding;\n }\n\n // Single message (second most common)\n if (record.message.length === 1) {\n return JSON.stringify({\n \"@timestamp\": new Date(record.timestamp).toISOString(),\n level: record.level === \"warning\"\n ? \"WARN\"\n : record.level.toUpperCase(),\n message: record.message[0],\n logger: record.category.join(\".\"),\n properties: record.properties,\n }, jsonReplacer) + lineEnding;\n }\n\n // Complex messages (fallback)\n let msg = record.message[0] as string;\n for (let i = 1; i < record.message.length; i++) {\n msg += (i & 1) ? JSON.stringify(record.message[i]) : record.message[i];\n }\n\n return JSON.stringify({\n \"@timestamp\": new Date(record.timestamp).toISOString(),\n level: record.level === \"warning\" ? \"WARN\" : record.level.toUpperCase(),\n message: msg,\n logger: record.category.join(\".\"),\n properties: record.properties,\n }, jsonReplacer) + lineEnding;\n };\n }\n\n // Pre-compile configuration for non-default cases\n const isTemplateMessage = options.message === \"template\";\n const propertiesOption = options.properties ?? \"nest:properties\";\n\n // Pre-compile category joining strategy\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 // Pre-compile properties handling strategy\n let getProperties: (\n properties: Record<string, unknown>,\n ) => Record<string, unknown>;\n\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 // Pre-compile message rendering function\n let getMessage: (record: LogRecord) => string;\n\n if (isTemplateMessage) {\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 const msgLen = record.message.length;\n\n if (msgLen === 1) {\n return record.message[0] as string;\n }\n\n let msg = \"\";\n for (let i = 0; i < msgLen; i++) {\n msg += (i % 2 < 1)\n ? record.message[i]\n : JSON.stringify(record.message[i]);\n }\n return msg;\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 }, jsonReplacer) + lineEnding;\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;AAqL9B,SA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;;;;;;;;;AAkBD,MAAagB,qBAAoC,uBAAuB;;;;AAexE,MAAMC,iBAA2C;CAC/C,SAAS;CACT,SAAS;CACT,QAAQ;CACR,WAAW;CACX,SAAS;CACT,SAAS;AACV;;;;;;;;AASD,SAAgB,wBAAwBjB,QAAuC;CAC7E,IAAI,MAAM;CACV,MAAMkB,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/logger.cjs CHANGED
@@ -219,22 +219,33 @@ var LoggerImpl = class LoggerImpl {
219
219
  else this.logTemplate("info", message, values);
220
220
  }
221
221
  warn(message, ...values) {
222
- if (typeof message === "string") this.log("warning", message, values[0] ?? {});
222
+ if (message instanceof Error) this.log("warning", "{error.message}", { error: message });
223
+ else if (typeof message === "string" && values[0] instanceof Error) this.log("warning", message, { error: values[0] });
224
+ else if (typeof message === "string") this.log("warning", message, values[0] ?? {});
223
225
  else if (typeof message === "function") this.logLazily("warning", message);
224
226
  else if (!Array.isArray(message)) this.log("warning", "{*}", message);
225
227
  else this.logTemplate("warning", message, values);
226
228
  }
227
229
  warning(message, ...values) {
228
- this.warn(message, ...values);
230
+ if (message instanceof Error) this.log("warning", "{error.message}", { error: message });
231
+ else if (typeof message === "string" && values[0] instanceof Error) this.log("warning", message, { error: values[0] });
232
+ else if (typeof message === "string") this.log("warning", message, values[0] ?? {});
233
+ else if (typeof message === "function") this.logLazily("warning", message);
234
+ else if (!Array.isArray(message)) this.log("warning", "{*}", message);
235
+ else this.logTemplate("warning", message, values);
229
236
  }
230
237
  error(message, ...values) {
231
- if (typeof message === "string") this.log("error", message, values[0] ?? {});
238
+ if (message instanceof Error) this.log("error", "{error.message}", { error: message });
239
+ else if (typeof message === "string" && values[0] instanceof Error) this.log("error", message, { error: values[0] });
240
+ else if (typeof message === "string") this.log("error", message, values[0] ?? {});
232
241
  else if (typeof message === "function") this.logLazily("error", message);
233
242
  else if (!Array.isArray(message)) this.log("error", "{*}", message);
234
243
  else this.logTemplate("error", message, values);
235
244
  }
236
245
  fatal(message, ...values) {
237
- if (typeof message === "string") this.log("fatal", message, values[0] ?? {});
246
+ if (message instanceof Error) this.log("fatal", "{error.message}", { error: message });
247
+ else if (typeof message === "string" && values[0] instanceof Error) this.log("fatal", message, { error: values[0] });
248
+ else if (typeof message === "string") this.log("fatal", message, values[0] ?? {});
238
249
  else if (typeof message === "function") this.logLazily("fatal", message);
239
250
  else if (!Array.isArray(message)) this.log("fatal", "{*}", message);
240
251
  else this.logTemplate("fatal", message, values);
@@ -311,22 +322,33 @@ var LoggerCtx = class LoggerCtx {
311
322
  else this.logTemplate("info", message, values);
312
323
  }
313
324
  warn(message, ...values) {
314
- if (typeof message === "string") this.log("warning", message, values[0] ?? {});
325
+ if (message instanceof Error) this.log("warning", "{error.message}", { error: message });
326
+ else if (typeof message === "string" && values[0] instanceof Error) this.log("warning", message, { error: values[0] });
327
+ else if (typeof message === "string") this.log("warning", message, values[0] ?? {});
315
328
  else if (typeof message === "function") this.logLazily("warning", message);
316
329
  else if (!Array.isArray(message)) this.log("warning", "{*}", message);
317
330
  else this.logTemplate("warning", message, values);
318
331
  }
319
332
  warning(message, ...values) {
320
- this.warn(message, ...values);
333
+ if (message instanceof Error) this.log("warning", "{error.message}", { error: message });
334
+ else if (typeof message === "string" && values[0] instanceof Error) this.log("warning", message, { error: values[0] });
335
+ else if (typeof message === "string") this.log("warning", message, values[0] ?? {});
336
+ else if (typeof message === "function") this.logLazily("warning", message);
337
+ else if (!Array.isArray(message)) this.log("warning", "{*}", message);
338
+ else this.logTemplate("warning", message, values);
321
339
  }
322
340
  error(message, ...values) {
323
- if (typeof message === "string") this.log("error", message, values[0] ?? {});
341
+ if (message instanceof Error) this.log("error", "{error.message}", { error: message });
342
+ else if (typeof message === "string" && values[0] instanceof Error) this.log("error", message, { error: values[0] });
343
+ else if (typeof message === "string") this.log("error", message, values[0] ?? {});
324
344
  else if (typeof message === "function") this.logLazily("error", message);
325
345
  else if (!Array.isArray(message)) this.log("error", "{*}", message);
326
346
  else this.logTemplate("error", message, values);
327
347
  }
328
348
  fatal(message, ...values) {
329
- if (typeof message === "string") this.log("fatal", message, values[0] ?? {});
349
+ if (message instanceof Error) this.log("fatal", "{error.message}", { error: message });
350
+ else if (typeof message === "string" && values[0] instanceof Error) this.log("fatal", message, { error: values[0] });
351
+ else if (typeof message === "string") this.log("fatal", message, values[0] ?? {});
330
352
  else if (typeof message === "function") this.logLazily("fatal", message);
331
353
  else if (!Array.isArray(message)) this.log("fatal", "{*}", message);
332
354
  else this.logTemplate("fatal", message, values);
package/dist/logger.d.cts CHANGED
@@ -310,6 +310,36 @@ interface Logger {
310
310
  * @throws {TypeError} If no log record was made inside the callback.
311
311
  */
312
312
  info(callback: LogCallback): void;
313
+ /**
314
+ * Log a warning.
315
+ *
316
+ * This overload is a shorthand for logging an {@link Error} instance as a
317
+ * structured property.
318
+ *
319
+ * ```typescript
320
+ * logger.warn(new Error("Oops"));
321
+ * ```
322
+ *
323
+ * Note that this uses `{error.message}` as the default message template.
324
+ * If you want to include the stack trace in text output, include `{error}`
325
+ * in the message template instead.
326
+ *
327
+ * @param error The error to log.
328
+ * @since 1.4.0
329
+ */
330
+ warn(error: Error): void;
331
+ /**
332
+ * Log a warning message with an {@link Error}.
333
+ *
334
+ * ```typescript
335
+ * logger.warn("Failed to do something", new Error("Oops"));
336
+ * ```
337
+ *
338
+ * @param message The message.
339
+ * @param error The error to log.
340
+ * @since 1.4.0
341
+ */
342
+ warn(message: string, error: Error): void;
313
343
  /**
314
344
  * Log a warning message. Use this as a template string prefix.
315
345
  *
@@ -389,6 +419,36 @@ interface Logger {
389
419
  * @throws {TypeError} If no log record was made inside the callback.
390
420
  */
391
421
  warn(callback: LogCallback): void;
422
+ /**
423
+ * Log a warning.
424
+ *
425
+ * This overload is a shorthand for logging an {@link Error} instance as a
426
+ * structured property.
427
+ *
428
+ * ```typescript
429
+ * logger.warning(new Error("Oops"));
430
+ * ```
431
+ *
432
+ * Note that this uses `{error.message}` as the default message template.
433
+ * If you want to include the stack trace in text output, include `{error}`
434
+ * in the message template instead.
435
+ *
436
+ * @param error The error to log.
437
+ * @since 1.4.0
438
+ */
439
+ warning(error: Error): void;
440
+ /**
441
+ * Log a warning message with an {@link Error}.
442
+ *
443
+ * ```typescript
444
+ * logger.warning("Failed to do something", new Error("Oops"));
445
+ * ```
446
+ *
447
+ * @param message The message.
448
+ * @param error The error to log.
449
+ * @since 1.4.0
450
+ */
451
+ warning(message: string, error: Error): void;
392
452
  /**
393
453
  * Log a warning message. Use this as a template string prefix.
394
454
  *
@@ -471,6 +531,36 @@ interface Logger {
471
531
  * @since 0.12.0
472
532
  */
473
533
  warning(callback: LogCallback): void;
534
+ /**
535
+ * Log an error.
536
+ *
537
+ * This overload is a shorthand for logging an {@link Error} instance as a
538
+ * structured property.
539
+ *
540
+ * ```typescript
541
+ * logger.error(new Error("Oops"));
542
+ * ```
543
+ *
544
+ * Note that this uses `{error.message}` as the default message template.
545
+ * If you want to include the stack trace in text output, include `{error}`
546
+ * in the message template instead.
547
+ *
548
+ * @param error The error to log.
549
+ * @since 1.4.0
550
+ */
551
+ error(error: Error): void;
552
+ /**
553
+ * Log an error message with an {@link Error}.
554
+ *
555
+ * ```typescript
556
+ * logger.error("Failed to do something", new Error("Oops"));
557
+ * ```
558
+ *
559
+ * @param message The message.
560
+ * @param error The error to log.
561
+ * @since 1.4.0
562
+ */
563
+ error(message: string, error: Error): void;
474
564
  /**
475
565
  * Log an error message. Use this as a template string prefix.
476
566
  *
@@ -550,6 +640,36 @@ interface Logger {
550
640
  * @throws {TypeError} If no log record was made inside the callback.
551
641
  */
552
642
  error(callback: LogCallback): void;
643
+ /**
644
+ * Log a fatal error.
645
+ *
646
+ * This overload is a shorthand for logging an {@link Error} instance as a
647
+ * structured property.
648
+ *
649
+ * ```typescript
650
+ * logger.fatal(new Error("Oops"));
651
+ * ```
652
+ *
653
+ * Note that this uses `{error.message}` as the default message template.
654
+ * If you want to include the stack trace in text output, include `{error}`
655
+ * in the message template instead.
656
+ *
657
+ * @param error The error to log.
658
+ * @since 1.4.0
659
+ */
660
+ fatal(error: Error): void;
661
+ /**
662
+ * Log a fatal error message with an {@link Error}.
663
+ *
664
+ * ```typescript
665
+ * logger.fatal("Failed to do something", new Error("Oops"));
666
+ * ```
667
+ *
668
+ * @param message The message.
669
+ * @param error The error to log.
670
+ * @since 1.4.0
671
+ */
672
+ fatal(message: string, error: Error): void;
553
673
  /**
554
674
  * Log a fatal error message. Use this as a template string prefix.
555
675
  *
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.cts","names":[],"sources":["../src/logger.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;AA6QgB,UArPC,MAAA,CAqPD;EAAoB;;;EA4DX,SAcR,QAAA,EAAA,SAAA,MAAA,EAAA;EAAW;;;;EAwEH,SAcR,MAAA,EA3YE,MA2YF,GAAA,IAAA;EAAW;;;;;;;;;;;;;;;;;AAoST;EASP,QAAA,CAAA,WAAW,EAAA,MAAY,GAAA,SAAA,CAA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;;;;;;;;;;;;;;wCA6BF,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAgC5B;;;;;;;;;;;;;;oBAeF;;;;;;;;;;;;;;;;;;eAmBL;;;;;;;;;;;;gCAaiB;;;;;;;;;;;iBAYf;;;;;;;;;;;;;;;;;;;;;;;;;sCA4BA,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAgC9B;;;;;;;;;;;;;kBAcF;;;;;;;;;;;;;;;;;;eAmBH;;;;;;;;;;;;gCAaiB;;;;;;;;;;;iBAYf;;;;;;;;;;;;;;;;;;;;;;;;;sCA4BA,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAgC9B;;;;;;;;;;;;;kBAcF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA+BH,KAAK;;;;;;;;KASR,WAAA,YAAuB;;;;;;;;KASvB,iBAAA,aACD;;;;;UAQM,SAAA;;;;;;YAOJ;;;;;;;;;;iCAeI,iCAAiC;;;;;;eAQnC;;;;;;aAOF;;;;;;;;;;;;;;iBAeG,SAAA,yCAAsD"}
package/dist/logger.d.ts CHANGED
@@ -310,6 +310,36 @@ interface Logger {
310
310
  * @throws {TypeError} If no log record was made inside the callback.
311
311
  */
312
312
  info(callback: LogCallback): void;
313
+ /**
314
+ * Log a warning.
315
+ *
316
+ * This overload is a shorthand for logging an {@link Error} instance as a
317
+ * structured property.
318
+ *
319
+ * ```typescript
320
+ * logger.warn(new Error("Oops"));
321
+ * ```
322
+ *
323
+ * Note that this uses `{error.message}` as the default message template.
324
+ * If you want to include the stack trace in text output, include `{error}`
325
+ * in the message template instead.
326
+ *
327
+ * @param error The error to log.
328
+ * @since 1.4.0
329
+ */
330
+ warn(error: Error): void;
331
+ /**
332
+ * Log a warning message with an {@link Error}.
333
+ *
334
+ * ```typescript
335
+ * logger.warn("Failed to do something", new Error("Oops"));
336
+ * ```
337
+ *
338
+ * @param message The message.
339
+ * @param error The error to log.
340
+ * @since 1.4.0
341
+ */
342
+ warn(message: string, error: Error): void;
313
343
  /**
314
344
  * Log a warning message. Use this as a template string prefix.
315
345
  *
@@ -389,6 +419,36 @@ interface Logger {
389
419
  * @throws {TypeError} If no log record was made inside the callback.
390
420
  */
391
421
  warn(callback: LogCallback): void;
422
+ /**
423
+ * Log a warning.
424
+ *
425
+ * This overload is a shorthand for logging an {@link Error} instance as a
426
+ * structured property.
427
+ *
428
+ * ```typescript
429
+ * logger.warning(new Error("Oops"));
430
+ * ```
431
+ *
432
+ * Note that this uses `{error.message}` as the default message template.
433
+ * If you want to include the stack trace in text output, include `{error}`
434
+ * in the message template instead.
435
+ *
436
+ * @param error The error to log.
437
+ * @since 1.4.0
438
+ */
439
+ warning(error: Error): void;
440
+ /**
441
+ * Log a warning message with an {@link Error}.
442
+ *
443
+ * ```typescript
444
+ * logger.warning("Failed to do something", new Error("Oops"));
445
+ * ```
446
+ *
447
+ * @param message The message.
448
+ * @param error The error to log.
449
+ * @since 1.4.0
450
+ */
451
+ warning(message: string, error: Error): void;
392
452
  /**
393
453
  * Log a warning message. Use this as a template string prefix.
394
454
  *
@@ -471,6 +531,36 @@ interface Logger {
471
531
  * @since 0.12.0
472
532
  */
473
533
  warning(callback: LogCallback): void;
534
+ /**
535
+ * Log an error.
536
+ *
537
+ * This overload is a shorthand for logging an {@link Error} instance as a
538
+ * structured property.
539
+ *
540
+ * ```typescript
541
+ * logger.error(new Error("Oops"));
542
+ * ```
543
+ *
544
+ * Note that this uses `{error.message}` as the default message template.
545
+ * If you want to include the stack trace in text output, include `{error}`
546
+ * in the message template instead.
547
+ *
548
+ * @param error The error to log.
549
+ * @since 1.4.0
550
+ */
551
+ error(error: Error): void;
552
+ /**
553
+ * Log an error message with an {@link Error}.
554
+ *
555
+ * ```typescript
556
+ * logger.error("Failed to do something", new Error("Oops"));
557
+ * ```
558
+ *
559
+ * @param message The message.
560
+ * @param error The error to log.
561
+ * @since 1.4.0
562
+ */
563
+ error(message: string, error: Error): void;
474
564
  /**
475
565
  * Log an error message. Use this as a template string prefix.
476
566
  *
@@ -550,6 +640,36 @@ interface Logger {
550
640
  * @throws {TypeError} If no log record was made inside the callback.
551
641
  */
552
642
  error(callback: LogCallback): void;
643
+ /**
644
+ * Log a fatal error.
645
+ *
646
+ * This overload is a shorthand for logging an {@link Error} instance as a
647
+ * structured property.
648
+ *
649
+ * ```typescript
650
+ * logger.fatal(new Error("Oops"));
651
+ * ```
652
+ *
653
+ * Note that this uses `{error.message}` as the default message template.
654
+ * If you want to include the stack trace in text output, include `{error}`
655
+ * in the message template instead.
656
+ *
657
+ * @param error The error to log.
658
+ * @since 1.4.0
659
+ */
660
+ fatal(error: Error): void;
661
+ /**
662
+ * Log a fatal error message with an {@link Error}.
663
+ *
664
+ * ```typescript
665
+ * logger.fatal("Failed to do something", new Error("Oops"));
666
+ * ```
667
+ *
668
+ * @param message The message.
669
+ * @param error The error to log.
670
+ * @since 1.4.0
671
+ */
672
+ fatal(message: string, error: Error): void;
553
673
  /**
554
674
  * Log a fatal error message. Use this as a template string prefix.
555
675
  *
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","names":[],"sources":["../src/logger.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;AA6QgB,UArPC,MAAA,CAqPD;EAAoB;;;EA4DX,SAcR,QAAA,EAAA,SAAA,MAAA,EAAA;EAAW;;;;EAwEH,SAcR,MAAA,EA3YE,MA2YF,GAAA,IAAA;EAAW;;;;;;;;;;;;;;;;;AAoST;EASP,QAAA,CAAA,WAAW,EAAA,MAAY,GAAA,SAAA,CAAA,MAAiB,CAAA,GAAA,SAAA,CAAA,MAAA,EAAA,GAAA,MAAA,EAAA,CAAA,CAAA,EAlqB/C,MAkqB+C;EASxC;AASZ;;;;;;;AAqCwB;AAexB;;;;;;;;;;;;;;;;;mBA5sBmB,0BAA0B;;;;;;;;;;;;iBAa5B;;;;;;;;;;;;;;;;;;;;;;;;;;sCA6BA,iCAAiC;;;;;;;;;;;;;;;;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gC9B;;;;;;;;;;;;;kBAcF;;;;;;;;;;;;;;;;;;eAmBH;;;;;;;;;;;;gCAaiB;;;;;;;;;;;iBAYf;;;;;;;;;;;;;;;;;;;;;;;;;sCA4BA,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAgC9B;;;;;;;;;;;;;kBAcF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA+BH,KAAK;;;;;;;;KASR,WAAA,YAAuB;;;;;;;;KASvB,iBAAA,aACD;;;;;UAQM,SAAA;;;;;;YAOJ;;;;;;;;;;iCAeI,iCAAiC;;;;;;eAQnC;;;;;;aAOF;;;;;;;;;;;;;;iBAeG,SAAA,yCAAsD"}
package/dist/logger.js CHANGED
@@ -219,22 +219,33 @@ var LoggerImpl = class LoggerImpl {
219
219
  else this.logTemplate("info", message, values);
220
220
  }
221
221
  warn(message, ...values) {
222
- if (typeof message === "string") this.log("warning", message, values[0] ?? {});
222
+ if (message instanceof Error) this.log("warning", "{error.message}", { error: message });
223
+ else if (typeof message === "string" && values[0] instanceof Error) this.log("warning", message, { error: values[0] });
224
+ else if (typeof message === "string") this.log("warning", message, values[0] ?? {});
223
225
  else if (typeof message === "function") this.logLazily("warning", message);
224
226
  else if (!Array.isArray(message)) this.log("warning", "{*}", message);
225
227
  else this.logTemplate("warning", message, values);
226
228
  }
227
229
  warning(message, ...values) {
228
- this.warn(message, ...values);
230
+ if (message instanceof Error) this.log("warning", "{error.message}", { error: message });
231
+ else if (typeof message === "string" && values[0] instanceof Error) this.log("warning", message, { error: values[0] });
232
+ else if (typeof message === "string") this.log("warning", message, values[0] ?? {});
233
+ else if (typeof message === "function") this.logLazily("warning", message);
234
+ else if (!Array.isArray(message)) this.log("warning", "{*}", message);
235
+ else this.logTemplate("warning", message, values);
229
236
  }
230
237
  error(message, ...values) {
231
- if (typeof message === "string") this.log("error", message, values[0] ?? {});
238
+ if (message instanceof Error) this.log("error", "{error.message}", { error: message });
239
+ else if (typeof message === "string" && values[0] instanceof Error) this.log("error", message, { error: values[0] });
240
+ else if (typeof message === "string") this.log("error", message, values[0] ?? {});
232
241
  else if (typeof message === "function") this.logLazily("error", message);
233
242
  else if (!Array.isArray(message)) this.log("error", "{*}", message);
234
243
  else this.logTemplate("error", message, values);
235
244
  }
236
245
  fatal(message, ...values) {
237
- if (typeof message === "string") this.log("fatal", message, values[0] ?? {});
246
+ if (message instanceof Error) this.log("fatal", "{error.message}", { error: message });
247
+ else if (typeof message === "string" && values[0] instanceof Error) this.log("fatal", message, { error: values[0] });
248
+ else if (typeof message === "string") this.log("fatal", message, values[0] ?? {});
238
249
  else if (typeof message === "function") this.logLazily("fatal", message);
239
250
  else if (!Array.isArray(message)) this.log("fatal", "{*}", message);
240
251
  else this.logTemplate("fatal", message, values);
@@ -311,22 +322,33 @@ var LoggerCtx = class LoggerCtx {
311
322
  else this.logTemplate("info", message, values);
312
323
  }
313
324
  warn(message, ...values) {
314
- if (typeof message === "string") this.log("warning", message, values[0] ?? {});
325
+ if (message instanceof Error) this.log("warning", "{error.message}", { error: message });
326
+ else if (typeof message === "string" && values[0] instanceof Error) this.log("warning", message, { error: values[0] });
327
+ else if (typeof message === "string") this.log("warning", message, values[0] ?? {});
315
328
  else if (typeof message === "function") this.logLazily("warning", message);
316
329
  else if (!Array.isArray(message)) this.log("warning", "{*}", message);
317
330
  else this.logTemplate("warning", message, values);
318
331
  }
319
332
  warning(message, ...values) {
320
- this.warn(message, ...values);
333
+ if (message instanceof Error) this.log("warning", "{error.message}", { error: message });
334
+ else if (typeof message === "string" && values[0] instanceof Error) this.log("warning", message, { error: values[0] });
335
+ else if (typeof message === "string") this.log("warning", message, values[0] ?? {});
336
+ else if (typeof message === "function") this.logLazily("warning", message);
337
+ else if (!Array.isArray(message)) this.log("warning", "{*}", message);
338
+ else this.logTemplate("warning", message, values);
321
339
  }
322
340
  error(message, ...values) {
323
- if (typeof message === "string") this.log("error", message, values[0] ?? {});
341
+ if (message instanceof Error) this.log("error", "{error.message}", { error: message });
342
+ else if (typeof message === "string" && values[0] instanceof Error) this.log("error", message, { error: values[0] });
343
+ else if (typeof message === "string") this.log("error", message, values[0] ?? {});
324
344
  else if (typeof message === "function") this.logLazily("error", message);
325
345
  else if (!Array.isArray(message)) this.log("error", "{*}", message);
326
346
  else this.logTemplate("error", message, values);
327
347
  }
328
348
  fatal(message, ...values) {
329
- if (typeof message === "string") this.log("fatal", message, values[0] ?? {});
349
+ if (message instanceof Error) this.log("fatal", "{error.message}", { error: message });
350
+ else if (typeof message === "string" && values[0] instanceof Error) this.log("fatal", message, { error: values[0] });
351
+ else if (typeof message === "string") this.log("fatal", message, values[0] ?? {});
330
352
  else if (typeof message === "function") this.logLazily("fatal", message);
331
353
  else if (!Array.isArray(message)) this.log("fatal", "{*}", message);
332
354
  else this.logTemplate("fatal", message, values);
@@ -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","record: Omit<LogRecord, \"category\"> | LogRecord","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","record: Omit<LogRecord, \"category\">","key: string","obj: unknown","path: string","fromIndex: number","segment: string | number","current: unknown","template: string","message: unknown[]","prop: unknown","template: TemplateStringsArray","values: readonly unknown[]"],"sources":["../src/logger.ts"],"sourcesContent":["import {\n type ContextLocalStorage,\n getCategoryPrefix,\n getImplicitContext,\n} 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 * Emits a log record with custom fields while using this logger's\n * category.\n *\n * This is a low-level API for integration scenarios where you need full\n * control over the log record, particularly for preserving timestamps\n * from external systems.\n *\n * ```typescript\n * const logger = getLogger([\"my-app\", \"integration\"]);\n *\n * // Emit a log with a custom timestamp\n * logger.emit({\n * timestamp: kafkaLog.originalTimestamp,\n * level: \"info\",\n * message: [kafkaLog.message],\n * rawMessage: kafkaLog.message,\n * properties: {\n * source: \"kafka\",\n * partition: kafkaLog.partition,\n * offset: kafkaLog.offset,\n * },\n * });\n * ```\n *\n * @param record Log record without category field (category comes from\n * the logger instance)\n * @since 1.1.0\n */\n emit(record: Omit<LogRecord, \"category\">): void;\n}\n\n/**\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: Omit<LogRecord, \"category\">): void;\n emit(record: LogRecord, bypassSinks?: Set<Sink>): void;\n emit(\n record: Omit<LogRecord, \"category\"> | LogRecord,\n bypassSinks?: Set<Sink>,\n ): void {\n const categoryPrefix = getCategoryPrefix();\n const baseCategory = \"category\" in record\n ? (record as LogRecord).category\n : this.category;\n const fullCategory = categoryPrefix.length > 0\n ? [...categoryPrefix, ...baseCategory]\n : baseCategory;\n\n // Create the full record by copying property descriptors from the original\n // record, which preserves getters without invoking them (unlike spread).\n const descriptors = Object.getOwnPropertyDescriptors(record) as\n & PropertyDescriptorMap\n & { category?: PropertyDescriptor };\n descriptors.category = {\n value: fullCategory,\n enumerable: true,\n configurable: true,\n };\n const fullRecord = Object.defineProperties({}, descriptors) as LogRecord;\n\n if (\n this.lowestLevel === null ||\n compareLogLevel(fullRecord.level, this.lowestLevel) < 0 ||\n !this.filter(fullRecord)\n ) {\n return;\n }\n for (const sink of this.getSinks(fullRecord.level)) {\n if (bypassSinks?.has(sink)) continue;\n try {\n sink(fullRecord);\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: fullRecord },\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 = getImplicitContext();\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 = getImplicitContext();\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 = getImplicitContext();\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 emit(record: Omit<LogRecord, \"category\">): void {\n const recordWithContext = {\n ...record,\n properties: { ...this.properties, ...record.properties },\n };\n this.logger.emit(recordWithContext);\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 * Check if a property access key contains nested access patterns.\n * @param key The property key to check.\n * @returns True if the key contains nested access patterns.\n */\nfunction isNestedAccess(key: string): boolean {\n return key.includes(\".\") || key.includes(\"[\") || key.includes(\"?.\");\n}\n\n/**\n * Safely access an own property from an object, blocking prototype pollution.\n *\n * @param obj The object to access the property from.\n * @param key The property key to access.\n * @returns The property value or undefined if not accessible.\n */\nfunction getOwnProperty(obj: unknown, key: string): unknown {\n // Block dangerous prototype keys\n if (key === \"__proto__\" || key === \"prototype\" || key === \"constructor\") {\n return undefined;\n }\n\n if ((typeof obj === \"object\" || typeof obj === \"function\") && obj !== null) {\n return Object.prototype.hasOwnProperty.call(obj, key)\n ? (obj as Record<string, unknown>)[key]\n : undefined;\n }\n\n return undefined;\n}\n\n/**\n * Result of parsing a single segment from a property path.\n */\ninterface ParseSegmentResult {\n segment: string | number;\n nextIndex: number;\n}\n\n/**\n * Parse the next segment from a property path string.\n *\n * @param path The full property path string.\n * @param fromIndex The index to start parsing from.\n * @returns The parsed segment and next index, or null if parsing fails.\n */\nfunction parseNextSegment(\n path: string,\n fromIndex: number,\n): ParseSegmentResult | null {\n const len = path.length;\n let i = fromIndex;\n\n if (i >= len) return null;\n\n let segment: string | number;\n\n if (path[i] === \"[\") {\n // Bracket notation: [0] or [\"prop\"]\n i++;\n if (i >= len) return null;\n\n if (path[i] === '\"' || path[i] === \"'\") {\n // Quoted property name: [\"prop-name\"]\n const quote = path[i];\n i++;\n // Build segment with proper escape handling\n let segmentStr = \"\";\n while (i < len && path[i] !== quote) {\n if (path[i] === \"\\\\\") {\n i++; // Skip backslash\n if (i < len) {\n // Handle escape sequences according to JavaScript spec\n const escapeChar = path[i];\n switch (escapeChar) {\n case \"n\":\n segmentStr += \"\\n\";\n break;\n case \"t\":\n segmentStr += \"\\t\";\n break;\n case \"r\":\n segmentStr += \"\\r\";\n break;\n case \"b\":\n segmentStr += \"\\b\";\n break;\n case \"f\":\n segmentStr += \"\\f\";\n break;\n case \"v\":\n segmentStr += \"\\v\";\n break;\n case \"0\":\n segmentStr += \"\\0\";\n break;\n case \"\\\\\":\n segmentStr += \"\\\\\";\n break;\n case '\"':\n segmentStr += '\"';\n break;\n case \"'\":\n segmentStr += \"'\";\n break;\n case \"u\":\n // Unicode escape: \\uXXXX\n if (i + 4 < len) {\n const hex = path.slice(i + 1, i + 5);\n const codePoint = Number.parseInt(hex, 16);\n if (!Number.isNaN(codePoint)) {\n segmentStr += String.fromCharCode(codePoint);\n i += 4; // Skip the 4 hex digits\n } else {\n // Invalid unicode escape, keep as-is\n segmentStr += escapeChar;\n }\n } else {\n // Not enough characters for unicode escape\n segmentStr += escapeChar;\n }\n break;\n default:\n // For any other character after \\, just add it as-is\n segmentStr += escapeChar;\n }\n i++;\n }\n } else {\n segmentStr += path[i];\n i++;\n }\n }\n if (i >= len) return null;\n segment = segmentStr;\n i++; // Skip closing quote\n } else {\n // Array index: [0]\n const startIndex = i;\n while (\n i < len && path[i] !== \"]\" && path[i] !== \"'\" && path[i] !== '\"'\n ) {\n i++;\n }\n if (i >= len) return null;\n const indexStr = path.slice(startIndex, i);\n // Empty bracket is invalid\n if (indexStr.length === 0) return null;\n const indexNum = Number(indexStr);\n segment = Number.isNaN(indexNum) ? indexStr : indexNum;\n }\n\n // Skip closing bracket\n while (i < len && path[i] !== \"]\") i++;\n if (i < len) i++;\n } else {\n // Dot notation: prop\n const startIndex = i;\n while (\n i < len && path[i] !== \".\" && path[i] !== \"[\" && path[i] !== \"?\" &&\n path[i] !== \"]\"\n ) {\n i++;\n }\n segment = path.slice(startIndex, i);\n // Empty segment is invalid (e.g., leading dot, double dot, trailing dot)\n if (segment.length === 0) return null;\n }\n\n // Skip dot separator\n if (i < len && path[i] === \".\") i++;\n\n return { segment, nextIndex: i };\n}\n\n/**\n * Access a property or index on an object or array.\n *\n * @param obj The object or array to access.\n * @param segment The property key or array index.\n * @returns The accessed value or undefined if not accessible.\n */\nfunction accessProperty(obj: unknown, segment: string | number): unknown {\n if (typeof segment === \"string\") {\n return getOwnProperty(obj, segment);\n }\n\n // Numeric index for arrays\n if (Array.isArray(obj) && segment >= 0 && segment < obj.length) {\n return obj[segment];\n }\n\n return undefined;\n}\n\n/**\n * Resolve a nested property path from an object.\n *\n * There are two types of property access patterns:\n * 1. Array/index access: [0] or [\"prop\"]\n * 2. Property access: prop or prop?.next\n *\n * @param obj The object to traverse.\n * @param path The property path (e.g., \"user.name\", \"users[0].email\", \"user['full-name']\").\n * @returns The resolved value or undefined if path doesn't exist.\n */\nfunction resolvePropertyPath(obj: unknown, path: string): unknown {\n if (obj == null) return undefined;\n\n // Check for invalid paths\n if (path.length === 0 || path.endsWith(\".\")) return undefined;\n\n let current: unknown = obj;\n let i = 0;\n const len = path.length;\n\n while (i < len) {\n // Handle optional chaining\n const isOptional = path.slice(i, i + 2) === \"?.\";\n if (isOptional) {\n i += 2;\n if (current == null) return undefined;\n } else if (current == null) {\n return undefined;\n }\n\n // Parse the next segment\n const result = parseNextSegment(path, i);\n if (result === null) return undefined;\n\n const { segment, nextIndex } = result;\n i = nextIndex;\n\n // Access the property/index\n current = accessProperty(current, segment);\n if (current === undefined) {\n return undefined;\n }\n }\n\n return current;\n}\n\n/**\n * Parse a message template into a message template array and a values array.\n *\n * Placeholders to be replaced with `values` are indicated by keys in curly braces\n * (e.g., `{value}`). The system supports both simple property access and nested\n * property access patterns:\n *\n * **Simple property access:**\n * ```ts\n * parseMessageTemplate(\"Hello, {user}!\", { user: \"foo\" })\n * // Returns: [\"Hello, \", \"foo\", \"!\"]\n * ```\n *\n * **Nested property access (dot notation):**\n * ```ts\n * parseMessageTemplate(\"Hello, {user.name}!\", {\n * user: { name: \"foo\", email: \"foo@example.com\" }\n * })\n * // Returns: [\"Hello, \", \"foo\", \"!\"]\n * ```\n *\n * **Array indexing:**\n * ```ts\n * parseMessageTemplate(\"First: {users[0]}\", {\n * users: [\"foo\", \"bar\", \"baz\"]\n * })\n * // Returns: [\"First: \", \"foo\", \"\"]\n * ```\n *\n * **Bracket notation for special property names:**\n * ```ts\n * parseMessageTemplate(\"Name: {user[\\\"full-name\\\"]}\", {\n * user: { \"full-name\": \"foo bar\" }\n * })\n * // Returns: [\"Name: \", \"foo bar\", \"\"]\n * ```\n *\n * **Optional chaining for safe navigation:**\n * ```ts\n * parseMessageTemplate(\"Email: {user?.profile?.email}\", {\n * user: { name: \"foo\" }\n * })\n * // Returns: [\"Email: \", undefined, \"\"]\n * ```\n *\n * **Wildcard patterns:**\n * - `{*}` - Replaced with the entire properties object\n * - `{ key-with-whitespace }` - Whitespace is trimmed when looking up keys\n *\n * **Escaping:**\n * - `{{` and `}}` are escaped literal braces\n *\n * **Error handling:**\n * - Non-existent paths return `undefined`\n * - Malformed expressions resolve to `undefined` without throwing errors\n * - Out of bounds array access returns `undefined`\n *\n * @param template The message template string containing placeholders.\n * @param properties The values to replace placeholders with.\n * @returns The message template array with values interleaved between text segments.\n */\nexport function parseMessageTemplate(\n template: string,\n properties: Record<string, unknown>,\n): readonly unknown[] {\n const length = template.length;\n if (length === 0) return [\"\"];\n\n // Fast path: no placeholders\n if (!template.includes(\"{\")) return [template];\n\n const message: unknown[] = [];\n let startIndex = 0;\n\n for (let i = 0; i < length; i++) {\n const char = template[i];\n\n if (char === \"{\") {\n const nextChar = i + 1 < length ? template[i + 1] : \"\";\n\n if (nextChar === \"{\") {\n // Escaped { character - skip and continue\n i++; // Skip the next {\n continue;\n }\n\n // Find the closing }\n const closeIndex = template.indexOf(\"}\", i + 1);\n if (closeIndex === -1) {\n // No closing } found, treat as literal text\n continue;\n }\n\n // Add text before placeholder\n const beforeText = template.slice(startIndex, i);\n message.push(beforeText.replace(/{{/g, \"{\").replace(/}}/g, \"}\"));\n\n // Extract and process placeholder key\n const key = template.slice(i + 1, closeIndex);\n\n // Resolve property value\n let prop: unknown;\n\n // Check for wildcard patterns\n const trimmedKey = key.trim();\n if (trimmedKey === \"*\") {\n // This is a wildcard pattern\n prop = key in properties\n ? properties[key]\n : \"*\" in properties\n ? properties[\"*\"]\n : properties;\n } else {\n // Regular property lookup with possible whitespace handling\n if (key !== trimmedKey) {\n // Key has leading/trailing whitespace\n prop = key in properties ? properties[key] : properties[trimmedKey];\n } else {\n // Key has no leading/trailing whitespace\n prop = properties[key];\n }\n\n // If property not found directly and this looks like nested access, try nested resolution\n if (prop === undefined && isNestedAccess(trimmedKey)) {\n prop = resolvePropertyPath(properties, trimmedKey);\n }\n }\n\n message.push(prop);\n i = closeIndex; // Move to the }\n startIndex = i + 1;\n } else if (char === \"}\" && i + 1 < length && template[i + 1] === \"}\") {\n // Escaped } character - skip\n i++; // Skip the next }\n }\n }\n\n // Add remaining text\n const remainingText = template.slice(startIndex);\n message.push(remainingText.replace(/{{/g, \"{\").replace(/}}/g, \"}\"));\n\n return message;\n}\n\n/**\n * Render a message template with values.\n * @param template The message template.\n * @param values The message template values.\n * @returns The message template values interleaved between the substitution\n * values.\n */\nexport function renderMessage(\n template: TemplateStringsArray,\n values: readonly unknown[],\n): unknown[] {\n const args = [];\n for (let i = 0; i < template.length; i++) {\n args.push(template[i]);\n if (i < values.length) args.push(values[i]);\n }\n return args;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgyBA,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,CAAE;AACf,OAAK,UAAU,CAAE;CAClB;CAED,SACEC,aAIY;EACZ,MAAM,cAAc,gBAAgB,WAAW,cAAc,YAAY;EACzE,MAAM,WAAW,KAAK,SAAS;EAC/B,IAAIC,QAAgC,oBAAoB,aACpD,WACA,UAAU,OAAO;AACrB,MAAI,SAAS,MAAM;AACjB,WAAQ,IAAI,WAAW,MAAM,CAAC,GAAG,KAAK,UAAU,IAAK;AACrD,QAAK,SAAS,QAAQ,aAAa,aAC/B,IAAI,QAAQ,SACZ;EACL;AACD,aAAW,gBAAgB,YAAY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W;AAChD,SAAQ,KAAK,cAAc,QAAQ,OAAO,IAAI,CAAC,QAAQ,OAAO,IAAI,CAAC;AAEnE,QAAO;AACR;;;;;;;;AASD,SAAgB,cACdC,UACAC,QACW;CACX,MAAM,OAAO,CAAE;AACf,MAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;AACxC,OAAK,KAAK,SAAS,GAAG;AACtB,MAAI,IAAI,OAAO,OAAQ,MAAK,KAAK,OAAO,GAAG;CAC5C;AACD,QAAO;AACR"}
1
+ {"version":3,"file":"logger.js","names":["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","record: Omit<LogRecord, \"category\"> | LogRecord","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>","message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error","logger: LoggerImpl","subcategory: string | readonly [string] | readonly [string, ...string[]]","message: string","record: Omit<LogRecord, \"category\">","key: string","obj: unknown","path: string","fromIndex: number","segment: string | number","current: unknown","template: string","message: unknown[]","prop: unknown","template: TemplateStringsArray","values: readonly unknown[]"],"sources":["../src/logger.ts"],"sourcesContent":["import {\n type ContextLocalStorage,\n getCategoryPrefix,\n getImplicitContext,\n} 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.\n *\n * This overload is a shorthand for logging an {@link Error} instance as a\n * structured property.\n *\n * ```typescript\n * logger.warn(new Error(\"Oops\"));\n * ```\n *\n * Note that this uses `{error.message}` as the default message template.\n * If you want to include the stack trace in text output, include `{error}`\n * in the message template instead.\n *\n * @param error The error to log.\n * @since 1.4.0\n */\n warn(error: Error): void;\n\n /**\n * Log a warning message with an {@link Error}.\n *\n * ```typescript\n * logger.warn(\"Failed to do something\", new Error(\"Oops\"));\n * ```\n *\n * @param message The message.\n * @param error The error to log.\n * @since 1.4.0\n */\n warn(message: string, error: Error): void;\n\n /**\n * Log a warning message. Use this as a template string prefix.\n *\n * ```typescript\n * logger.warn `A warning message with ${value}.`;\n * ```\n *\n * @param message The message template strings array.\n * @param values The message template values.\n */\n warn(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n\n /**\n * Log a warning message with properties.\n *\n * ```typescript\n * logger.warn('A warning message with {value}.', { value });\n * ```\n *\n * If the properties are expensive to compute, you can pass a callback that\n * returns the properties:\n *\n * ```typescript\n * logger.warn(\n * 'A warning message with {value}.',\n * () => ({ value: expensiveComputation() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties The values to replace placeholders with. For lazy\n * evaluation, this can be a callback that returns the\n * properties.\n */\n warn(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log a warning values with no message. This is useful when you\n * want to log properties without a message, e.g., when you want to log\n * the context of a request or an operation.\n *\n * ```typescript\n * logger.warn({ method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * Note that this is a shorthand for:\n *\n * ```typescript\n * logger.warn('{*}', { method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * If the properties are expensive to compute, you cannot use this shorthand\n * and should use the following syntax instead:\n *\n * ```typescript\n * logger.warn('{*}', () => ({\n * method: expensiveMethod(),\n * url: expensiveUrl(),\n * }));\n * ```\n *\n * @param properties The values to log. Note that this does not take\n * a callback.\n * @since 0.11.0\n */\n warn(properties: Record<string, unknown>): void;\n\n /**\n * Lazily log a warning message. Use this when the message values are\n * expensive to compute and should only be computed if the message is actually\n * logged.\n *\n * ```typescript\n * logger.warn(l => l`A warning message with ${expensiveValue()}.`);\n * ```\n *\n * @param callback A callback that returns the message template prefix.\n * @throws {TypeError} If no log record was made inside the callback.\n */\n warn(callback: LogCallback): void;\n\n /**\n * Log a warning.\n *\n * This overload is a shorthand for logging an {@link Error} instance as a\n * structured property.\n *\n * ```typescript\n * logger.warning(new Error(\"Oops\"));\n * ```\n *\n * Note that this uses `{error.message}` as the default message template.\n * If you want to include the stack trace in text output, include `{error}`\n * in the message template instead.\n *\n * @param error The error to log.\n * @since 1.4.0\n */\n warning(error: Error): void;\n\n /**\n * Log a warning message with an {@link Error}.\n *\n * ```typescript\n * logger.warning(\"Failed to do something\", new Error(\"Oops\"));\n * ```\n *\n * @param message The message.\n * @param error The error to log.\n * @since 1.4.0\n */\n warning(message: string, error: Error): void;\n\n /**\n * Log a warning message. Use this as a template string prefix.\n *\n * ```typescript\n * logger.warning `A warning message with ${value}.`;\n * ```\n *\n * @param message The message template strings array.\n * @param values The message template values.\n * @since 0.12.0\n */\n warning(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n\n /**\n * Log a warning message with properties.\n *\n * ```typescript\n * logger.warning('A warning message with {value}.', { value });\n * ```\n *\n * If the properties are expensive to compute, you can pass a callback that\n * returns the properties:\n *\n * ```typescript\n * logger.warning(\n * 'A warning message with {value}.',\n * () => ({ value: expensiveComputation() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties The values to replace placeholders with. For lazy\n * evaluation, this can be a callback that returns the\n * properties.\n * @since 0.12.0\n */\n warning(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log a warning values with no message. This is useful when you\n * want to log properties without a message, e.g., when you want to log\n * the context of a request or an operation.\n *\n * ```typescript\n * logger.warning({ method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * Note that this is a shorthand for:\n *\n * ```typescript\n * logger.warning('{*}', { method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * If the properties are expensive to compute, you cannot use this shorthand\n * and should use the following syntax instead:\n *\n * ```typescript\n * logger.warning('{*}', () => ({\n * method: expensiveMethod(),\n * url: expensiveUrl(),\n * }));\n * ```\n *\n * @param properties The values to log. Note that this does not take\n * a callback.\n * @since 0.12.0\n */\n warning(properties: Record<string, unknown>): void;\n\n /**\n * Lazily log a warning message. Use this when the message values are\n * expensive to compute and should only be computed if the message is actually\n * logged.\n *\n * ```typescript\n * logger.warning(l => l`A warning message with ${expensiveValue()}.`);\n * ```\n *\n * @param callback A callback that returns the message template prefix.\n * @throws {TypeError} If no log record was made inside the callback.\n * @since 0.12.0\n */\n warning(callback: LogCallback): void;\n\n /**\n * Log an error.\n *\n * This overload is a shorthand for logging an {@link Error} instance as a\n * structured property.\n *\n * ```typescript\n * logger.error(new Error(\"Oops\"));\n * ```\n *\n * Note that this uses `{error.message}` as the default message template.\n * If you want to include the stack trace in text output, include `{error}`\n * in the message template instead.\n *\n * @param error The error to log.\n * @since 1.4.0\n */\n error(error: Error): void;\n\n /**\n * Log an error message with an {@link Error}.\n *\n * ```typescript\n * logger.error(\"Failed to do something\", new Error(\"Oops\"));\n * ```\n *\n * @param message The message.\n * @param error The error to log.\n * @since 1.4.0\n */\n error(message: string, error: Error): void;\n\n /**\n * Log an error message. Use this as a template string prefix.\n *\n * ```typescript\n * logger.error `An error message with ${value}.`;\n * ```\n *\n * @param message The message template strings array.\n * @param values The message template values.\n */\n error(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n\n /**\n * Log an error message with properties.\n *\n * ```typescript\n * logger.warn('An error message with {value}.', { value });\n * ```\n *\n * If the properties are expensive to compute, you can pass a callback that\n * returns the properties:\n *\n * ```typescript\n * logger.error(\n * 'An error message with {value}.',\n * () => ({ value: expensiveComputation() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties The values to replace placeholders with. For lazy\n * evaluation, this can be a callback that returns the\n * properties.\n */\n error(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log an error values with no message. This is useful when you\n * want to log properties without a message, e.g., when you want to log\n * the context of a request or an operation.\n *\n * ```typescript\n * logger.error({ method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * Note that this is a shorthand for:\n *\n * ```typescript\n * logger.error('{*}', { method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * If the properties are expensive to compute, you cannot use this shorthand\n * and should use the following syntax instead:\n *\n * ```typescript\n * logger.error('{*}', () => ({\n * method: expensiveMethod(),\n * url: expensiveUrl(),\n * }));\n * ```\n *\n * @param properties The values to log. Note that this does not take\n * a callback.\n * @since 0.11.0\n */\n error(properties: Record<string, unknown>): void;\n\n /**\n * Lazily log an error message. Use this when the message values are\n * expensive to compute and should only be computed if the message is actually\n * logged.\n *\n * ```typescript\n * logger.error(l => l`An error message with ${expensiveValue()}.`);\n * ```\n *\n * @param callback A callback that returns the message template prefix.\n * @throws {TypeError} If no log record was made inside the callback.\n */\n error(callback: LogCallback): void;\n\n /**\n * Log a fatal error.\n *\n * This overload is a shorthand for logging an {@link Error} instance as a\n * structured property.\n *\n * ```typescript\n * logger.fatal(new Error(\"Oops\"));\n * ```\n *\n * Note that this uses `{error.message}` as the default message template.\n * If you want to include the stack trace in text output, include `{error}`\n * in the message template instead.\n *\n * @param error The error to log.\n * @since 1.4.0\n */\n fatal(error: Error): void;\n\n /**\n * Log a fatal error message with an {@link Error}.\n *\n * ```typescript\n * logger.fatal(\"Failed to do something\", new Error(\"Oops\"));\n * ```\n *\n * @param message The message.\n * @param error The error to log.\n * @since 1.4.0\n */\n fatal(message: string, error: Error): void;\n\n /**\n * Log a fatal error message. Use this as a template string prefix.\n *\n * ```typescript\n * logger.fatal `A fatal error message with ${value}.`;\n * ```\n *\n * @param message The message template strings array.\n * @param values The message template values.\n */\n fatal(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n\n /**\n * Log a fatal error message with properties.\n *\n * ```typescript\n * logger.warn('A fatal error message with {value}.', { value });\n * ```\n *\n * If the properties are expensive to compute, you can pass a callback that\n * returns the properties:\n *\n * ```typescript\n * logger.fatal(\n * 'A fatal error message with {value}.',\n * () => ({ value: expensiveComputation() })\n * );\n * ```\n *\n * @param message The message template. Placeholders to be replaced with\n * `values` are indicated by keys in curly braces (e.g.,\n * `{value}`).\n * @param properties The values to replace placeholders with. For lazy\n * evaluation, this can be a callback that returns the\n * properties.\n */\n fatal(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n\n /**\n * Log a fatal error values with no message. This is useful when you\n * want to log properties without a message, e.g., when you want to log\n * the context of a request or an operation.\n *\n * ```typescript\n * logger.fatal({ method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * Note that this is a shorthand for:\n *\n * ```typescript\n * logger.fatal('{*}', { method: 'GET', url: '/api/v1/resource' });\n * ```\n *\n * If the properties are expensive to compute, you cannot use this shorthand\n * and should use the following syntax instead:\n *\n * ```typescript\n * logger.fatal('{*}', () => ({\n * method: expensiveMethod(),\n * url: expensiveUrl(),\n * }));\n * ```\n *\n * @param properties The values to log. Note that this does not take\n * a callback.\n * @since 0.11.0\n */\n fatal(properties: Record<string, unknown>): void;\n\n /**\n * Lazily log a fatal error message. Use this when the message values are\n * expensive to compute and should only be computed if the message is actually\n * logged.\n *\n * ```typescript\n * logger.fatal(l => l`A fatal error message with ${expensiveValue()}.`);\n * ```\n *\n * @param callback A callback that returns the message template prefix.\n * @throws {TypeError} If no log record was made inside the callback.\n */\n fatal(callback: LogCallback): void;\n\n /**\n * Emits a log record with custom fields while using this logger's\n * category.\n *\n * This is a low-level API for integration scenarios where you need full\n * control over the log record, particularly for preserving timestamps\n * from external systems.\n *\n * ```typescript\n * const logger = getLogger([\"my-app\", \"integration\"]);\n *\n * // Emit a log with a custom timestamp\n * logger.emit({\n * timestamp: kafkaLog.originalTimestamp,\n * level: \"info\",\n * message: [kafkaLog.message],\n * rawMessage: kafkaLog.message,\n * properties: {\n * source: \"kafka\",\n * partition: kafkaLog.partition,\n * offset: kafkaLog.offset,\n * },\n * });\n * ```\n *\n * @param record Log record without category field (category comes from\n * the logger instance)\n * @since 1.1.0\n */\n emit(record: Omit<LogRecord, \"category\">): void;\n}\n\n/**\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: Omit<LogRecord, \"category\">): void;\n emit(record: LogRecord, bypassSinks?: Set<Sink>): void;\n emit(\n record: Omit<LogRecord, \"category\"> | LogRecord,\n bypassSinks?: Set<Sink>,\n ): void {\n const categoryPrefix = getCategoryPrefix();\n const baseCategory = \"category\" in record\n ? (record as LogRecord).category\n : this.category;\n const fullCategory = categoryPrefix.length > 0\n ? [...categoryPrefix, ...baseCategory]\n : baseCategory;\n\n // Create the full record by copying property descriptors from the original\n // record, which preserves getters without invoking them (unlike spread).\n const descriptors = Object.getOwnPropertyDescriptors(record) as\n & PropertyDescriptorMap\n & { category?: PropertyDescriptor };\n descriptors.category = {\n value: fullCategory,\n enumerable: true,\n configurable: true,\n };\n const fullRecord = Object.defineProperties({}, descriptors) as LogRecord;\n\n if (\n this.lowestLevel === null ||\n compareLogLevel(fullRecord.level, this.lowestLevel) < 0 ||\n !this.filter(fullRecord)\n ) {\n return;\n }\n for (const sink of this.getSinks(fullRecord.level)) {\n if (bypassSinks?.has(sink)) continue;\n try {\n sink(fullRecord);\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: fullRecord },\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 = getImplicitContext();\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 = getImplicitContext();\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 = getImplicitContext();\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(error: Error): void;\n warn(message: string, error: Error): void;\n warn(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n warn(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n warn(properties: Record<string, unknown>): void;\n warn(callback: LogCallback): void;\n warn(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error,\n ...values: unknown[]\n ): void {\n if (message instanceof Error) {\n this.log(\"warning\", \"{error.message}\", { error: message });\n } else if (typeof message === \"string\" && values[0] instanceof Error) {\n this.log(\"warning\", message, { error: values[0] });\n } else if (typeof message === \"string\") {\n 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(error: Error): void;\n warning(message: string, error: Error): void;\n warning(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n warning(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n warning(properties: Record<string, unknown>): void;\n warning(callback: LogCallback): void;\n warning(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error,\n ...values: unknown[]\n ): void {\n if (message instanceof Error) {\n this.log(\"warning\", \"{error.message}\", { error: message });\n } else if (typeof message === \"string\" && values[0] instanceof Error) {\n this.log(\"warning\", message, { error: values[0] });\n } else if (typeof message === \"string\") {\n 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 error(error: Error): void;\n error(message: string, error: Error): void;\n error(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n error(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n error(properties: Record<string, unknown>): void;\n error(callback: LogCallback): void;\n error(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error,\n ...values: unknown[]\n ): void {\n if (message instanceof Error) {\n this.log(\"error\", \"{error.message}\", { error: message });\n } else if (typeof message === \"string\" && values[0] instanceof Error) {\n this.log(\"error\", message, { error: values[0] });\n } else if (typeof message === \"string\") {\n 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(error: Error): void;\n fatal(message: string, error: Error): void;\n fatal(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n fatal(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n fatal(properties: Record<string, unknown>): void;\n fatal(callback: LogCallback): void;\n fatal(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error,\n ...values: unknown[]\n ): void {\n if (message instanceof Error) {\n this.log(\"fatal\", \"{error.message}\", { error: message });\n } else if (typeof message === \"string\" && values[0] instanceof Error) {\n this.log(\"fatal\", message, { error: values[0] });\n } else if (typeof message === \"string\") {\n 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 emit(record: Omit<LogRecord, \"category\">): void {\n const recordWithContext = {\n ...record,\n properties: { ...this.properties, ...record.properties },\n };\n this.logger.emit(recordWithContext);\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(error: Error): void;\n warn(message: string, error: Error): void;\n warn(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n warn(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n warn(properties: Record<string, unknown>): void;\n warn(callback: LogCallback): void;\n warn(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error,\n ...values: unknown[]\n ): void {\n if (message instanceof Error) {\n this.log(\"warning\", \"{error.message}\", { error: message });\n } else if (typeof message === \"string\" && values[0] instanceof Error) {\n this.log(\"warning\", message, { error: values[0] });\n } else if (typeof message === \"string\") {\n 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(error: Error): void;\n warning(message: string, error: Error): void;\n warning(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n warning(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n warning(properties: Record<string, unknown>): void;\n warning(callback: LogCallback): void;\n warning(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error,\n ...values: unknown[]\n ): void {\n if (message instanceof Error) {\n this.log(\"warning\", \"{error.message}\", { error: message });\n } else if (typeof message === \"string\" && values[0] instanceof Error) {\n this.log(\"warning\", message, { error: values[0] });\n } else if (typeof message === \"string\") {\n 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 error(error: Error): void;\n error(message: string, error: Error): void;\n error(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n error(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n error(properties: Record<string, unknown>): void;\n error(callback: LogCallback): void;\n error(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error,\n ...values: unknown[]\n ): void {\n if (message instanceof Error) {\n this.log(\"error\", \"{error.message}\", { error: message });\n } else if (typeof message === \"string\" && values[0] instanceof Error) {\n this.log(\"error\", message, { error: values[0] });\n } else if (typeof message === \"string\") {\n 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(error: Error): void;\n fatal(message: string, error: Error): void;\n fatal(message: TemplateStringsArray, ...values: readonly unknown[]): void;\n fatal(\n message: string,\n properties?: Record<string, unknown> | (() => Record<string, unknown>),\n ): void;\n fatal(properties: Record<string, unknown>): void;\n fatal(callback: LogCallback): void;\n fatal(\n message:\n | TemplateStringsArray\n | string\n | LogCallback\n | Record<string, unknown>\n | Error,\n ...values: unknown[]\n ): void {\n if (message instanceof Error) {\n this.log(\"fatal\", \"{error.message}\", { error: message });\n } else if (typeof message === \"string\" && values[0] instanceof Error) {\n this.log(\"fatal\", message, { error: values[0] });\n } else if (typeof message === \"string\") {\n 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 * Check if a property access key contains nested access patterns.\n * @param key The property key to check.\n * @returns True if the key contains nested access patterns.\n */\nfunction isNestedAccess(key: string): boolean {\n return key.includes(\".\") || key.includes(\"[\") || key.includes(\"?.\");\n}\n\n/**\n * Safely access an own property from an object, blocking prototype pollution.\n *\n * @param obj The object to access the property from.\n * @param key The property key to access.\n * @returns The property value or undefined if not accessible.\n */\nfunction getOwnProperty(obj: unknown, key: string): unknown {\n // Block dangerous prototype keys\n if (key === \"__proto__\" || key === \"prototype\" || key === \"constructor\") {\n return undefined;\n }\n\n if ((typeof obj === \"object\" || typeof obj === \"function\") && obj !== null) {\n return Object.prototype.hasOwnProperty.call(obj, key)\n ? (obj as Record<string, unknown>)[key]\n : undefined;\n }\n\n return undefined;\n}\n\n/**\n * Result of parsing a single segment from a property path.\n */\ninterface ParseSegmentResult {\n segment: string | number;\n nextIndex: number;\n}\n\n/**\n * Parse the next segment from a property path string.\n *\n * @param path The full property path string.\n * @param fromIndex The index to start parsing from.\n * @returns The parsed segment and next index, or null if parsing fails.\n */\nfunction parseNextSegment(\n path: string,\n fromIndex: number,\n): ParseSegmentResult | null {\n const len = path.length;\n let i = fromIndex;\n\n if (i >= len) return null;\n\n let segment: string | number;\n\n if (path[i] === \"[\") {\n // Bracket notation: [0] or [\"prop\"]\n i++;\n if (i >= len) return null;\n\n if (path[i] === '\"' || path[i] === \"'\") {\n // Quoted property name: [\"prop-name\"]\n const quote = path[i];\n i++;\n // Build segment with proper escape handling\n let segmentStr = \"\";\n while (i < len && path[i] !== quote) {\n if (path[i] === \"\\\\\") {\n i++; // Skip backslash\n if (i < len) {\n // Handle escape sequences according to JavaScript spec\n const escapeChar = path[i];\n switch (escapeChar) {\n case \"n\":\n segmentStr += \"\\n\";\n break;\n case \"t\":\n segmentStr += \"\\t\";\n break;\n case \"r\":\n segmentStr += \"\\r\";\n break;\n case \"b\":\n segmentStr += \"\\b\";\n break;\n case \"f\":\n segmentStr += \"\\f\";\n break;\n case \"v\":\n segmentStr += \"\\v\";\n break;\n case \"0\":\n segmentStr += \"\\0\";\n break;\n case \"\\\\\":\n segmentStr += \"\\\\\";\n break;\n case '\"':\n segmentStr += '\"';\n break;\n case \"'\":\n segmentStr += \"'\";\n break;\n case \"u\":\n // Unicode escape: \\uXXXX\n if (i + 4 < len) {\n const hex = path.slice(i + 1, i + 5);\n const codePoint = Number.parseInt(hex, 16);\n if (!Number.isNaN(codePoint)) {\n segmentStr += String.fromCharCode(codePoint);\n i += 4; // Skip the 4 hex digits\n } else {\n // Invalid unicode escape, keep as-is\n segmentStr += escapeChar;\n }\n } else {\n // Not enough characters for unicode escape\n segmentStr += escapeChar;\n }\n break;\n default:\n // For any other character after \\, just add it as-is\n segmentStr += escapeChar;\n }\n i++;\n }\n } else {\n segmentStr += path[i];\n i++;\n }\n }\n if (i >= len) return null;\n segment = segmentStr;\n i++; // Skip closing quote\n } else {\n // Array index: [0]\n const startIndex = i;\n while (\n i < len && path[i] !== \"]\" && path[i] !== \"'\" && path[i] !== '\"'\n ) {\n i++;\n }\n if (i >= len) return null;\n const indexStr = path.slice(startIndex, i);\n // Empty bracket is invalid\n if (indexStr.length === 0) return null;\n const indexNum = Number(indexStr);\n segment = Number.isNaN(indexNum) ? indexStr : indexNum;\n }\n\n // Skip closing bracket\n while (i < len && path[i] !== \"]\") i++;\n if (i < len) i++;\n } else {\n // Dot notation: prop\n const startIndex = i;\n while (\n i < len && path[i] !== \".\" && path[i] !== \"[\" && path[i] !== \"?\" &&\n path[i] !== \"]\"\n ) {\n i++;\n }\n segment = path.slice(startIndex, i);\n // Empty segment is invalid (e.g., leading dot, double dot, trailing dot)\n if (segment.length === 0) return null;\n }\n\n // Skip dot separator\n if (i < len && path[i] === \".\") i++;\n\n return { segment, nextIndex: i };\n}\n\n/**\n * Access a property or index on an object or array.\n *\n * @param obj The object or array to access.\n * @param segment The property key or array index.\n * @returns The accessed value or undefined if not accessible.\n */\nfunction accessProperty(obj: unknown, segment: string | number): unknown {\n if (typeof segment === \"string\") {\n return getOwnProperty(obj, segment);\n }\n\n // Numeric index for arrays\n if (Array.isArray(obj) && segment >= 0 && segment < obj.length) {\n return obj[segment];\n }\n\n return undefined;\n}\n\n/**\n * Resolve a nested property path from an object.\n *\n * There are two types of property access patterns:\n * 1. Array/index access: [0] or [\"prop\"]\n * 2. Property access: prop or prop?.next\n *\n * @param obj The object to traverse.\n * @param path The property path (e.g., \"user.name\", \"users[0].email\", \"user['full-name']\").\n * @returns The resolved value or undefined if path doesn't exist.\n */\nfunction resolvePropertyPath(obj: unknown, path: string): unknown {\n if (obj == null) return undefined;\n\n // Check for invalid paths\n if (path.length === 0 || path.endsWith(\".\")) return undefined;\n\n let current: unknown = obj;\n let i = 0;\n const len = path.length;\n\n while (i < len) {\n // Handle optional chaining\n const isOptional = path.slice(i, i + 2) === \"?.\";\n if (isOptional) {\n i += 2;\n if (current == null) return undefined;\n } else if (current == null) {\n return undefined;\n }\n\n // Parse the next segment\n const result = parseNextSegment(path, i);\n if (result === null) return undefined;\n\n const { segment, nextIndex } = result;\n i = nextIndex;\n\n // Access the property/index\n current = accessProperty(current, segment);\n if (current === undefined) {\n return undefined;\n }\n }\n\n return current;\n}\n\n/**\n * Parse a message template into a message template array and a values array.\n *\n * Placeholders to be replaced with `values` are indicated by keys in curly braces\n * (e.g., `{value}`). The system supports both simple property access and nested\n * property access patterns:\n *\n * **Simple property access:**\n * ```ts\n * parseMessageTemplate(\"Hello, {user}!\", { user: \"foo\" })\n * // Returns: [\"Hello, \", \"foo\", \"!\"]\n * ```\n *\n * **Nested property access (dot notation):**\n * ```ts\n * parseMessageTemplate(\"Hello, {user.name}!\", {\n * user: { name: \"foo\", email: \"foo@example.com\" }\n * })\n * // Returns: [\"Hello, \", \"foo\", \"!\"]\n * ```\n *\n * **Array indexing:**\n * ```ts\n * parseMessageTemplate(\"First: {users[0]}\", {\n * users: [\"foo\", \"bar\", \"baz\"]\n * })\n * // Returns: [\"First: \", \"foo\", \"\"]\n * ```\n *\n * **Bracket notation for special property names:**\n * ```ts\n * parseMessageTemplate(\"Name: {user[\\\"full-name\\\"]}\", {\n * user: { \"full-name\": \"foo bar\" }\n * })\n * // Returns: [\"Name: \", \"foo bar\", \"\"]\n * ```\n *\n * **Optional chaining for safe navigation:**\n * ```ts\n * parseMessageTemplate(\"Email: {user?.profile?.email}\", {\n * user: { name: \"foo\" }\n * })\n * // Returns: [\"Email: \", undefined, \"\"]\n * ```\n *\n * **Wildcard patterns:**\n * - `{*}` - Replaced with the entire properties object\n * - `{ key-with-whitespace }` - Whitespace is trimmed when looking up keys\n *\n * **Escaping:**\n * - `{{` and `}}` are escaped literal braces\n *\n * **Error handling:**\n * - Non-existent paths return `undefined`\n * - Malformed expressions resolve to `undefined` without throwing errors\n * - Out of bounds array access returns `undefined`\n *\n * @param template The message template string containing placeholders.\n * @param properties The values to replace placeholders with.\n * @returns The message template array with values interleaved between text segments.\n */\nexport function parseMessageTemplate(\n template: string,\n properties: Record<string, unknown>,\n): readonly unknown[] {\n const length = template.length;\n if (length === 0) return [\"\"];\n\n // Fast path: no placeholders\n if (!template.includes(\"{\")) return [template];\n\n const message: unknown[] = [];\n let startIndex = 0;\n\n for (let i = 0; i < length; i++) {\n const char = template[i];\n\n if (char === \"{\") {\n const nextChar = i + 1 < length ? template[i + 1] : \"\";\n\n if (nextChar === \"{\") {\n // Escaped { character - skip and continue\n i++; // Skip the next {\n continue;\n }\n\n // Find the closing }\n const closeIndex = template.indexOf(\"}\", i + 1);\n if (closeIndex === -1) {\n // No closing } found, treat as literal text\n continue;\n }\n\n // Add text before placeholder\n const beforeText = template.slice(startIndex, i);\n message.push(beforeText.replace(/{{/g, \"{\").replace(/}}/g, \"}\"));\n\n // Extract and process placeholder key\n const key = template.slice(i + 1, closeIndex);\n\n // Resolve property value\n let prop: unknown;\n\n // Check for wildcard patterns\n const trimmedKey = key.trim();\n if (trimmedKey === \"*\") {\n // This is a wildcard pattern\n prop = key in properties\n ? properties[key]\n : \"*\" in properties\n ? properties[\"*\"]\n : properties;\n } else {\n // Regular property lookup with possible whitespace handling\n if (key !== trimmedKey) {\n // Key has leading/trailing whitespace\n prop = key in properties ? properties[key] : properties[trimmedKey];\n } else {\n // Key has no leading/trailing whitespace\n prop = properties[key];\n }\n\n // If property not found directly and this looks like nested access, try nested resolution\n if (prop === undefined && isNestedAccess(trimmedKey)) {\n prop = resolvePropertyPath(properties, trimmedKey);\n }\n }\n\n message.push(prop);\n i = closeIndex; // Move to the }\n startIndex = i + 1;\n } else if (char === \"}\" && i + 1 < length && template[i + 1] === \"}\") {\n // Escaped } character - skip\n i++; // Skip the next }\n }\n }\n\n // Add remaining text\n const remainingText = template.slice(startIndex);\n message.push(remainingText.replace(/{{/g, \"{\").replace(/}}/g, \"}\"));\n\n return message;\n}\n\n/**\n * Render a message template with values.\n * @param template The message template.\n * @param values The message template values.\n * @returns The message template values interleaved between the substitution\n * values.\n */\nexport function renderMessage(\n template: TemplateStringsArray,\n values: readonly unknown[],\n): unknown[] {\n const args = [];\n for (let i = 0; i < template.length; i++) {\n args.push(template[i]);\n if (i < values.length) args.push(values[i]);\n }\n return args;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAg6BA,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,Q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443+a433d415",
3
+ "version": "1.4.0-dev.445+f5a711d4",
4
4
  "description": "Simple logging library with zero dependencies for Deno/Node.js/Bun/browsers",
5
5
  "keywords": [
6
6
  "logging",