@dxos/log 0.9.0 → 0.9.1-staging.ee54ba693a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/log",
3
- "version": "0.9.0",
3
+ "version": "0.9.1-staging.ee54ba693a",
4
4
  "description": "Logger",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -62,8 +62,8 @@
62
62
  "chalk": "^4.1.2",
63
63
  "js-yaml": "4.1.1",
64
64
  "lodash.defaultsdeep": "^4.6.1",
65
- "@dxos/node-std": "0.9.0",
66
- "@dxos/util": "0.9.0"
65
+ "@dxos/node-std": "0.9.1-staging.ee54ba693a",
66
+ "@dxos/util": "0.9.1-staging.ee54ba693a"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@types/js-yaml": "^4.0.5",
package/src/config.ts CHANGED
@@ -20,12 +20,12 @@ export enum LogLevel {
20
20
 
21
21
  export const levels: Record<string, LogLevel> = {
22
22
  '*': LogLevel.TRACE,
23
- trace: LogLevel.TRACE,
24
- debug: LogLevel.DEBUG,
25
- verbose: LogLevel.VERBOSE,
26
- info: LogLevel.INFO,
27
- warn: LogLevel.WARN,
28
- error: LogLevel.ERROR,
23
+ 'trace': LogLevel.TRACE,
24
+ 'debug': LogLevel.DEBUG,
25
+ 'verbose': LogLevel.VERBOSE,
26
+ 'info': LogLevel.INFO,
27
+ 'warn': LogLevel.WARN,
28
+ 'error': LogLevel.ERROR,
29
29
  };
30
30
 
31
31
  export const shortLevelName = {
package/src/meta.ts CHANGED
@@ -27,29 +27,29 @@ export interface CallMetadata {
27
27
  /**
28
28
  * File name.
29
29
  */
30
- F: string;
30
+ 'F': string;
31
31
 
32
32
  /**
33
33
  * Line number.
34
34
  */
35
- L: number;
35
+ 'L': number;
36
36
 
37
37
  /**
38
38
  * Value of `this` at the site of the log call.
39
39
  * Will be set to the class instance if the call is inside a method, or to the `globalThis` (`window` or `global`) otherwise.
40
40
  */
41
- S: any | undefined;
41
+ 'S': any | undefined;
42
42
 
43
43
  /**
44
44
  * A callback that will invoke the provided function with provided arguments.
45
45
  * Useful in the browser to force a `console.log` call to have a certain stack-trace.
46
46
  */
47
- C?: (fn: Function, args: any[]) => void;
47
+ 'C'?: (fn: Function, args: any[]) => void;
48
48
 
49
49
  /**
50
50
  * Source code of the argument list.
51
51
  */
52
- A?: string[];
52
+ 'A'?: string[];
53
53
  }
54
54
 
55
55
  /**
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/config.ts", "../../../src/processors/common.ts", "../../../src/scope.ts", "../../../src/context.ts"],
4
- "sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { type LogProcessor } from './context';\n\n/**\n * Standard levels.\n * NOTE: Keep aligned with LogLevel in @dxos/protocols.\n */\n// TODO(burdon): Update numbers?\nexport enum LogLevel {\n TRACE = 5,\n DEBUG = 10,\n VERBOSE = 11,\n INFO = 12,\n WARN = 13,\n ERROR = 14,\n}\n\nexport const levels: Record<string, LogLevel> = {\n '*': LogLevel.TRACE,\n trace: LogLevel.TRACE,\n debug: LogLevel.DEBUG,\n verbose: LogLevel.VERBOSE,\n info: LogLevel.INFO,\n warn: LogLevel.WARN,\n error: LogLevel.ERROR,\n};\n\nexport const shortLevelName = {\n [LogLevel.TRACE]: 'T',\n [LogLevel.DEBUG]: 'D',\n [LogLevel.VERBOSE]: 'V',\n [LogLevel.INFO]: 'I',\n [LogLevel.WARN]: 'W',\n [LogLevel.ERROR]: 'E',\n};\n\nexport enum LogProcessorType {\n CONSOLE = 'console',\n BROWSER = 'browser',\n DEBUG = 'debug',\n}\n\n/**\n * Individual filter condition.\n */\nexport type LogFilter = {\n level: LogLevel;\n pattern?: string;\n};\n\n/**\n * Options to set inline or load from the YML file.\n */\nexport type LogOptions = {\n file?: string;\n filter?: string | string[] | LogLevel;\n captureFilter?: string | string[] | LogLevel;\n depth?: number; // Context object depth.\n processor?: string | LogProcessorType;\n formatter?: {\n column: number;\n timestamp: boolean;\n timestampFirst: boolean;\n };\n prefix?: string;\n};\n\n/**\n * Runtime config.\n */\nexport interface LogConfig {\n options: LogOptions;\n filters?: LogFilter[];\n captureFilters?: LogFilter[];\n processors: LogProcessor[];\n prefix?: string;\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nexport const getRelativeFilename = (filename: string) => {\n // TODO(burdon): Hack uses \"packages\" as an anchor (pre-parse NX?)\n // Including `packages/` part of the path so that excluded paths (e.g. from dist) are clickable in vscode.\n const match = filename.match(/.+\\/(packages\\/.+\\/.+)/);\n if (match) {\n const [, filePath] = match;\n return filePath;\n }\n\n return filename;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nconst logInfoProperties = Symbol('logInfoProperties');\n\n/**\n * Decorate fields, properties, or methods to automatically include their values in log messages.\n *\n * Example:\n *\n * ```typescript\n * class Example {\n * @logInfo\n * peerId: PublicKey;\n * }\n * ```\n */\nexport const logInfo = (target: any, propertyKey: string, descriptor?: PropertyDescriptor) => {\n // console.log(target, propertyKey, descriptor);\n (target[logInfoProperties] ??= []).push(propertyKey);\n};\n\n/**\n * Introspects class instance to find decorated metadata.\n * @param scope Class instance.\n */\nexport const gatherLogInfoFromScope = (scope: any): Record<string, any> => {\n if (!scope) {\n return {};\n }\n\n const res: Record<string, any> = {};\n\n const prototype = Object.getPrototypeOf(scope);\n const infoProps = (typeof prototype === 'object' && prototype !== null ? prototype[logInfoProperties] : []) ?? [];\n for (const prop of infoProps) {\n try {\n res[prop] = typeof scope[prop] === 'function' ? scope[prop]() : scope[prop];\n } catch (err: any) {\n res[prop] = err.message;\n }\n }\n\n return res;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { getDebugName } from '@dxos/util';\n\nimport { type LogConfig, type LogFilter, type LogLevel } from './config';\nimport { type CallMetadata } from './meta';\nimport { getRelativeFilename } from './processors/common';\nimport { gatherLogInfoFromScope } from './scope';\n\n/**\n * Optional object passed to the logging API.\n */\nexport type LogContext = Record<string, any> | Error | any;\n\n/**\n * Normalized call-site metadata suitable for display and serialization.\n */\nexport interface ComputedLogMeta {\n /** Relative filename (normalized via {@link getRelativeFilename}). */\n filename?: string;\n\n /** Line number within the file. */\n line?: number;\n\n /** Debug name of the enclosing scope (class instance), e.g. `MyClass#3`. */\n context?: string;\n}\n\n/**\n * Fields required to construct a {@link LogEntry}.\n */\nexport interface LogEntryInit {\n level: LogLevel;\n message?: string;\n context?: LogContext;\n meta?: CallMetadata;\n error?: Error;\n /** Overrides the default timestamp ({@link Date.now}). */\n timestamp?: number;\n}\n\n/**\n * Record for a single log line processed by the logging pipeline.\n *\n * Raw fields (`level`, `message`, `context`, `meta`, `error`) are preserved so processors\n * can access unmodified inputs. Derived, lazily computed getters\n * ({@link computedContext}, {@link computedError}, {@link computedMeta}) centralize\n * the formatting logic shared across processors that write to serialized stores.\n */\nexport class LogEntry {\n /** Severity of this entry. */\n readonly level: LogLevel;\n\n /** Human-readable log message, if any. */\n readonly message?: string;\n\n /**\n * Raw context value passed at the call site. May be a record, an Error, a function\n * returning either, or any other value. Processors that need the flattened /\n * JSON-safe view should prefer {@link computedContext}.\n */\n readonly context?: LogContext;\n\n /** Raw call-site metadata injected by the log transform plugin. */\n readonly meta?: CallMetadata;\n\n /** Error passed to `log.catch()` / `log.error(err)`, if any. */\n readonly error?: Error;\n\n /** Unix timestamp in milliseconds of when the entry was created. */\n readonly timestamp: number;\n\n #computedContext: Record<string, unknown> | undefined;\n #computedContextComputed = false;\n #computedError: string | undefined;\n #computedErrorComputed = false;\n #computedMeta: ComputedLogMeta | undefined;\n #resolvedContext: unknown;\n #resolvedContextComputed = false;\n\n constructor(init: LogEntryInit) {\n this.level = init.level;\n this.message = init.message;\n this.context = init.context;\n this.meta = init.meta;\n this.error = init.error;\n this.timestamp = init.timestamp ?? Date.now();\n }\n\n /**\n * Resolve a function-valued {@link context} once and cache, so getters that\n * independently consult the raw context don't trigger duplicate evaluation.\n */\n #resolveContext(): unknown {\n if (!this.#resolvedContextComputed) {\n this.#resolvedContext = typeof this.context === 'function' ? this.context() : this.context;\n this.#resolvedContextComputed = true;\n }\n return this.#resolvedContext;\n }\n\n /**\n * Flattened, JSON-safe context intended for serialized stores.\n *\n * - Single-level key-value map.\n * - Primitives (`boolean`, `number`, `string`, `null`, `undefined`) pass through.\n * - Non-primitive values are stringified one level deep via `JSON.stringify` (no recursion).\n * - The reserved `error` / `err` keys are stripped — use {@link computedError} instead.\n * - Properties from `@logInfo`-decorated members of the scope (`meta.S`) are inlined.\n *\n * Lazily computed and memoized on first access.\n */\n get computedContext(): Record<string, unknown> {\n if (!this.#computedContextComputed) {\n this.#computedContext = computeContext(this, this.#resolveContext());\n this.#computedContextComputed = true;\n }\n return this.#computedContext ?? {};\n }\n\n /**\n * Stringified error for this entry, sourced (in priority order) from:\n * 1. {@link error} (e.g. `log.catch(err)`),\n * 2. {@link context} when the context itself is an {@link Error},\n * 3. `context.error` or `context.err`.\n *\n * Formatted as `.stack` when available, falling back to `.message` or `String(err)`.\n *\n * Lazily computed and memoized on first access.\n */\n get computedError(): string | undefined {\n if (!this.#computedErrorComputed) {\n this.#computedError = computeError(this, this.#resolveContext());\n this.#computedErrorComputed = true;\n }\n return this.#computedError;\n }\n\n /**\n * Normalized call-site metadata suitable for display / serialization.\n *\n * Lazily computed and memoized on first access.\n */\n get computedMeta(): ComputedLogMeta {\n if (this.#computedMeta === undefined) {\n this.#computedMeta = computeMeta(this);\n }\n return this.#computedMeta;\n }\n}\n\n/**\n * Processes (e.g., prints, forwards) log entries.\n */\nexport type LogProcessor = (config: LogConfig, entry: LogEntry) => void;\n\n/**\n * Returns:\n * true if the log entry matches the filter,\n * false if should be excluded, or\n * undefined if it the filter doesn't match the level.\n */\nconst matchFilter = (filter: LogFilter, level: LogLevel, path?: string): boolean | undefined => {\n // TODO(burdon): Support regexp.\n if (filter.pattern?.startsWith('-')) {\n // Exclude.\n if (path?.includes(filter.pattern.slice(1))) {\n if (level >= filter.level) {\n return false;\n }\n }\n } else {\n // Include.\n if (filter.pattern?.length) {\n if (path?.includes(filter.pattern)) {\n return level >= filter.level;\n }\n } else {\n if (level >= filter.level) {\n return true;\n }\n }\n }\n};\n\n/**\n * Determines if the current line should be logged (called by the processor).\n */\nexport const shouldLog = (entry: LogEntry, filters?: LogFilter[]): boolean => {\n if (filters === undefined) {\n return false;\n }\n\n const results = filters\n .map((filter) => matchFilter(filter, entry.level, entry.meta?.F))\n .filter((result): result is boolean => result !== undefined);\n\n // Skip if any are explicitely false.\n // console.log({ level: entry.level, path: entry.meta?.F }, filters, results, results.length);\n return results.length > 0 && !results.some((results) => results === false);\n};\n\n/**\n * Merges scope info, entry context, and error into a single record — preserving nested\n * objects and Error instances so rich consumers (console inspect, devtools) can format them.\n *\n * Prefer {@link LogEntry.computedContext} for serialized / JSON outputs.\n */\nexport const getContextFromEntry = (entry: LogEntry): Record<string, any> | undefined => {\n let context;\n if (entry.meta) {\n const scopeInfo = gatherLogInfoFromScope(entry.meta.S);\n if (Object.keys(scopeInfo).length > 0) {\n context = Object.assign(context ?? {}, scopeInfo);\n }\n }\n\n const entryContext = typeof entry.context === 'function' ? entry.context() : entry.context;\n if (entryContext) {\n if (entryContext instanceof Error) {\n // Additional context from Error.\n const c = (entryContext as any).context;\n // If ERROR then show stacktrace.\n context = Object.assign(context ?? {}, { error: entryContext.stack, ...c });\n } else if (typeof entryContext === 'object') {\n context = Object.assign(context ?? {}, entryContext);\n }\n }\n\n if (entry.error) {\n context = Object.assign(context ?? {}, { error: entry.error });\n }\n\n return context && Object.keys(context).length > 0 ? context : undefined;\n};\n\nconst RESERVED_ERROR_KEYS = new Set(['error', 'err']);\n\nconst stringifyOneLevel = (value: unknown): unknown => {\n if (value === null || value === undefined) {\n return value;\n }\n const type = typeof value;\n if (type === 'boolean' || type === 'number' || type === 'string') {\n return value;\n }\n if (type === 'bigint') {\n return (value as bigint).toString();\n }\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n};\n\nconst computeContext = (entry: LogEntry, rawContext: unknown): Record<string, unknown> => {\n const result: Record<string, unknown> = {};\n\n const mergeInto = (source: unknown): void => {\n if (!source || typeof source !== 'object') {\n return;\n }\n for (const [key, value] of Object.entries(source)) {\n if (RESERVED_ERROR_KEYS.has(key)) {\n continue;\n }\n result[key] = stringifyOneLevel(value);\n }\n };\n\n if (entry.meta?.S !== undefined && entry.meta.S !== null) {\n mergeInto(gatherLogInfoFromScope(entry.meta.S));\n }\n\n if (rawContext instanceof Error) {\n // Structured debug info attached to thrown errors lives on `.context`.\n mergeInto((rawContext as any).context);\n } else {\n mergeInto(rawContext);\n }\n\n if (entry.error) {\n mergeInto((entry.error as any).context);\n }\n\n return result;\n};\n\nconst stringifyError = (err: unknown): string | undefined => {\n if (err === null || err === undefined) {\n return undefined;\n }\n if (err instanceof Error) {\n return err.stack ?? err.message;\n }\n return String(err);\n};\n\nconst computeError = (entry: LogEntry, rawContext: unknown): string | undefined => {\n if (entry.error !== undefined) {\n return stringifyError(entry.error);\n }\n\n if (rawContext instanceof Error) {\n return stringifyError(rawContext);\n }\n if (rawContext && typeof rawContext === 'object') {\n const ctxErr = (rawContext as any).error ?? (rawContext as any).err;\n if (ctxErr !== undefined && ctxErr !== null) {\n return stringifyError(ctxErr);\n }\n }\n\n return undefined;\n};\n\nconst computeMeta = (entry: LogEntry): ComputedLogMeta => {\n if (!entry.meta) {\n return {};\n }\n\n const scope = entry.meta.S;\n // Skip globalThis and plain object scopes (module-level logs); only report class instances.\n let scopeContext: string | undefined;\n if (\n typeof scope === 'object' &&\n scope !== null &&\n scope !== globalThis &&\n Object.getPrototypeOf(scope) !== Object.prototype\n ) {\n scopeContext = getDebugName(scope);\n }\n\n return {\n filename: getRelativeFilename(entry.meta.F),\n line: entry.meta.L,\n context: scopeContext,\n };\n};\n"],
5
- "mappings": ";AAWO,IAAKA,WAAAA,0BAAAA,WAAAA;;;;;;;SAAAA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AACrC,WAAOA;EACT;AACA,MAAI6C,eAAenB,OAAO;AACxB,WAAOmB,IAAIjB,SAASiB,IAAI1D;EAC1B;AACA,SAAOkD,OAAOQ,GAAAA;AAChB;AAEA,IAAM/C,eAAe,CAACa,OAAiB2B,eAAAA;AACrC,MAAI3B,MAAMrB,UAAUU,QAAW;AAC7B,WAAO4C,eAAejC,MAAMrB,KAAK;EACnC;AAEA,MAAIgD,sBAAsBZ,OAAO;AAC/B,WAAOkB,eAAeN,UAAAA;EACxB;AACA,MAAIA,cAAc,OAAOA,eAAe,UAAU;AAChD,UAAMQ,SAAUR,WAAmBhD,SAAUgD,WAAmBO;AAChE,QAAIC,WAAW9C,UAAa8C,WAAW,MAAM;AAC3C,aAAOF,eAAeE,MAAAA;IACxB;EACF;AAEA,SAAO9C;AACT;AAEA,IAAMC,cAAc,CAACU,UAAAA;AACnB,MAAI,CAACA,MAAMtB,MAAM;AACf,WAAO,CAAC;EACV;AAEA,QAAM0D,QAAQpC,MAAMtB,KAAKgC;AAEzB,MAAI2B;AACJ,MACE,OAAOD,UAAU,YACjBA,UAAU,QACVA,UAAUE,cACV3B,OAAO4B,eAAeH,KAAAA,MAAWzB,OAAO6B,WACxC;AACAH,mBAAeI,aAAaL,KAAAA;EAC9B;AAEA,SAAO;IACLM,UAAUC,oBAAoB3C,MAAMtB,KAAK0B,CAAC;IAC1CwC,MAAM5C,MAAMtB,KAAKmE;IACjBpE,SAAS4D;EACX;AACF;",
6
- "names": ["LogLevel", "levels", "trace", "debug", "verbose", "info", "warn", "error", "shortLevelName", "LogProcessorType", "getRelativeFilename", "filename", "match", "filePath", "logInfoProperties", "Symbol", "logInfo", "target", "propertyKey", "descriptor", "push", "gatherLogInfoFromScope", "scope", "res", "prototype", "Object", "getPrototypeOf", "infoProps", "prop", "err", "message", "getDebugName", "LogEntry", "level", "message", "context", "meta", "error", "timestamp", "init", "Date", "now", "computedContext", "computeContext", "computedError", "computeError", "computedMeta", "undefined", "computeMeta", "matchFilter", "filter", "path", "pattern", "startsWith", "includes", "slice", "length", "shouldLog", "entry", "filters", "results", "map", "F", "result", "some", "getContextFromEntry", "scopeInfo", "gatherLogInfoFromScope", "S", "Object", "keys", "assign", "entryContext", "Error", "c", "stack", "RESERVED_ERROR_KEYS", "Set", "stringifyOneLevel", "value", "type", "toString", "JSON", "stringify", "String", "rawContext", "mergeInto", "source", "key", "entries", "has", "stringifyError", "err", "ctxErr", "scope", "scopeContext", "globalThis", "getPrototypeOf", "prototype", "getDebugName", "filename", "getRelativeFilename", "line", "L"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/config.ts", "../../../src/processors/common.ts", "../../../src/scope.ts", "../../../src/context.ts"],
4
- "sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { type LogProcessor } from './context';\n\n/**\n * Standard levels.\n * NOTE: Keep aligned with LogLevel in @dxos/protocols.\n */\n// TODO(burdon): Update numbers?\nexport enum LogLevel {\n TRACE = 5,\n DEBUG = 10,\n VERBOSE = 11,\n INFO = 12,\n WARN = 13,\n ERROR = 14,\n}\n\nexport const levels: Record<string, LogLevel> = {\n '*': LogLevel.TRACE,\n trace: LogLevel.TRACE,\n debug: LogLevel.DEBUG,\n verbose: LogLevel.VERBOSE,\n info: LogLevel.INFO,\n warn: LogLevel.WARN,\n error: LogLevel.ERROR,\n};\n\nexport const shortLevelName = {\n [LogLevel.TRACE]: 'T',\n [LogLevel.DEBUG]: 'D',\n [LogLevel.VERBOSE]: 'V',\n [LogLevel.INFO]: 'I',\n [LogLevel.WARN]: 'W',\n [LogLevel.ERROR]: 'E',\n};\n\nexport enum LogProcessorType {\n CONSOLE = 'console',\n BROWSER = 'browser',\n DEBUG = 'debug',\n}\n\n/**\n * Individual filter condition.\n */\nexport type LogFilter = {\n level: LogLevel;\n pattern?: string;\n};\n\n/**\n * Options to set inline or load from the YML file.\n */\nexport type LogOptions = {\n file?: string;\n filter?: string | string[] | LogLevel;\n captureFilter?: string | string[] | LogLevel;\n depth?: number; // Context object depth.\n processor?: string | LogProcessorType;\n formatter?: {\n column: number;\n timestamp: boolean;\n timestampFirst: boolean;\n };\n prefix?: string;\n};\n\n/**\n * Runtime config.\n */\nexport interface LogConfig {\n options: LogOptions;\n filters?: LogFilter[];\n captureFilters?: LogFilter[];\n processors: LogProcessor[];\n prefix?: string;\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nexport const getRelativeFilename = (filename: string) => {\n // TODO(burdon): Hack uses \"packages\" as an anchor (pre-parse NX?)\n // Including `packages/` part of the path so that excluded paths (e.g. from dist) are clickable in vscode.\n const match = filename.match(/.+\\/(packages\\/.+\\/.+)/);\n if (match) {\n const [, filePath] = match;\n return filePath;\n }\n\n return filename;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nconst logInfoProperties = Symbol('logInfoProperties');\n\n/**\n * Decorate fields, properties, or methods to automatically include their values in log messages.\n *\n * Example:\n *\n * ```typescript\n * class Example {\n * @logInfo\n * peerId: PublicKey;\n * }\n * ```\n */\nexport const logInfo = (target: any, propertyKey: string, descriptor?: PropertyDescriptor) => {\n // console.log(target, propertyKey, descriptor);\n (target[logInfoProperties] ??= []).push(propertyKey);\n};\n\n/**\n * Introspects class instance to find decorated metadata.\n * @param scope Class instance.\n */\nexport const gatherLogInfoFromScope = (scope: any): Record<string, any> => {\n if (!scope) {\n return {};\n }\n\n const res: Record<string, any> = {};\n\n const prototype = Object.getPrototypeOf(scope);\n const infoProps = (typeof prototype === 'object' && prototype !== null ? prototype[logInfoProperties] : []) ?? [];\n for (const prop of infoProps) {\n try {\n res[prop] = typeof scope[prop] === 'function' ? scope[prop]() : scope[prop];\n } catch (err: any) {\n res[prop] = err.message;\n }\n }\n\n return res;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { getDebugName } from '@dxos/util';\n\nimport { type LogConfig, type LogFilter, type LogLevel } from './config';\nimport { type CallMetadata } from './meta';\nimport { getRelativeFilename } from './processors/common';\nimport { gatherLogInfoFromScope } from './scope';\n\n/**\n * Optional object passed to the logging API.\n */\nexport type LogContext = Record<string, any> | Error | any;\n\n/**\n * Normalized call-site metadata suitable for display and serialization.\n */\nexport interface ComputedLogMeta {\n /** Relative filename (normalized via {@link getRelativeFilename}). */\n filename?: string;\n\n /** Line number within the file. */\n line?: number;\n\n /** Debug name of the enclosing scope (class instance), e.g. `MyClass#3`. */\n context?: string;\n}\n\n/**\n * Fields required to construct a {@link LogEntry}.\n */\nexport interface LogEntryInit {\n level: LogLevel;\n message?: string;\n context?: LogContext;\n meta?: CallMetadata;\n error?: Error;\n /** Overrides the default timestamp ({@link Date.now}). */\n timestamp?: number;\n}\n\n/**\n * Record for a single log line processed by the logging pipeline.\n *\n * Raw fields (`level`, `message`, `context`, `meta`, `error`) are preserved so processors\n * can access unmodified inputs. Derived, lazily computed getters\n * ({@link computedContext}, {@link computedError}, {@link computedMeta}) centralize\n * the formatting logic shared across processors that write to serialized stores.\n */\nexport class LogEntry {\n /** Severity of this entry. */\n readonly level: LogLevel;\n\n /** Human-readable log message, if any. */\n readonly message?: string;\n\n /**\n * Raw context value passed at the call site. May be a record, an Error, a function\n * returning either, or any other value. Processors that need the flattened /\n * JSON-safe view should prefer {@link computedContext}.\n */\n readonly context?: LogContext;\n\n /** Raw call-site metadata injected by the log transform plugin. */\n readonly meta?: CallMetadata;\n\n /** Error passed to `log.catch()` / `log.error(err)`, if any. */\n readonly error?: Error;\n\n /** Unix timestamp in milliseconds of when the entry was created. */\n readonly timestamp: number;\n\n #computedContext: Record<string, unknown> | undefined;\n #computedContextComputed = false;\n #computedError: string | undefined;\n #computedErrorComputed = false;\n #computedMeta: ComputedLogMeta | undefined;\n #resolvedContext: unknown;\n #resolvedContextComputed = false;\n\n constructor(init: LogEntryInit) {\n this.level = init.level;\n this.message = init.message;\n this.context = init.context;\n this.meta = init.meta;\n this.error = init.error;\n this.timestamp = init.timestamp ?? Date.now();\n }\n\n /**\n * Resolve a function-valued {@link context} once and cache, so getters that\n * independently consult the raw context don't trigger duplicate evaluation.\n */\n #resolveContext(): unknown {\n if (!this.#resolvedContextComputed) {\n this.#resolvedContext = typeof this.context === 'function' ? this.context() : this.context;\n this.#resolvedContextComputed = true;\n }\n return this.#resolvedContext;\n }\n\n /**\n * Flattened, JSON-safe context intended for serialized stores.\n *\n * - Single-level key-value map.\n * - Primitives (`boolean`, `number`, `string`, `null`, `undefined`) pass through.\n * - Non-primitive values are stringified one level deep via `JSON.stringify` (no recursion).\n * - The reserved `error` / `err` keys are stripped — use {@link computedError} instead.\n * - Properties from `@logInfo`-decorated members of the scope (`meta.S`) are inlined.\n *\n * Lazily computed and memoized on first access.\n */\n get computedContext(): Record<string, unknown> {\n if (!this.#computedContextComputed) {\n this.#computedContext = computeContext(this, this.#resolveContext());\n this.#computedContextComputed = true;\n }\n return this.#computedContext ?? {};\n }\n\n /**\n * Stringified error for this entry, sourced (in priority order) from:\n * 1. {@link error} (e.g. `log.catch(err)`),\n * 2. {@link context} when the context itself is an {@link Error},\n * 3. `context.error` or `context.err`.\n *\n * Formatted as `.stack` when available, falling back to `.message` or `String(err)`.\n *\n * Lazily computed and memoized on first access.\n */\n get computedError(): string | undefined {\n if (!this.#computedErrorComputed) {\n this.#computedError = computeError(this, this.#resolveContext());\n this.#computedErrorComputed = true;\n }\n return this.#computedError;\n }\n\n /**\n * Normalized call-site metadata suitable for display / serialization.\n *\n * Lazily computed and memoized on first access.\n */\n get computedMeta(): ComputedLogMeta {\n if (this.#computedMeta === undefined) {\n this.#computedMeta = computeMeta(this);\n }\n return this.#computedMeta;\n }\n}\n\n/**\n * Processes (e.g., prints, forwards) log entries.\n */\nexport type LogProcessor = (config: LogConfig, entry: LogEntry) => void;\n\n/**\n * Returns:\n * true if the log entry matches the filter,\n * false if should be excluded, or\n * undefined if it the filter doesn't match the level.\n */\nconst matchFilter = (filter: LogFilter, level: LogLevel, path?: string): boolean | undefined => {\n // TODO(burdon): Support regexp.\n if (filter.pattern?.startsWith('-')) {\n // Exclude.\n if (path?.includes(filter.pattern.slice(1))) {\n if (level >= filter.level) {\n return false;\n }\n }\n } else {\n // Include.\n if (filter.pattern?.length) {\n if (path?.includes(filter.pattern)) {\n return level >= filter.level;\n }\n } else {\n if (level >= filter.level) {\n return true;\n }\n }\n }\n};\n\n/**\n * Determines if the current line should be logged (called by the processor).\n */\nexport const shouldLog = (entry: LogEntry, filters?: LogFilter[]): boolean => {\n if (filters === undefined) {\n return false;\n }\n\n const results = filters\n .map((filter) => matchFilter(filter, entry.level, entry.meta?.F))\n .filter((result): result is boolean => result !== undefined);\n\n // Skip if any are explicitely false.\n // console.log({ level: entry.level, path: entry.meta?.F }, filters, results, results.length);\n return results.length > 0 && !results.some((results) => results === false);\n};\n\n/**\n * Merges scope info, entry context, and error into a single record — preserving nested\n * objects and Error instances so rich consumers (console inspect, devtools) can format them.\n *\n * Prefer {@link LogEntry.computedContext} for serialized / JSON outputs.\n */\nexport const getContextFromEntry = (entry: LogEntry): Record<string, any> | undefined => {\n let context;\n if (entry.meta) {\n const scopeInfo = gatherLogInfoFromScope(entry.meta.S);\n if (Object.keys(scopeInfo).length > 0) {\n context = Object.assign(context ?? {}, scopeInfo);\n }\n }\n\n const entryContext = typeof entry.context === 'function' ? entry.context() : entry.context;\n if (entryContext) {\n if (entryContext instanceof Error) {\n // Additional context from Error.\n const c = (entryContext as any).context;\n // If ERROR then show stacktrace.\n context = Object.assign(context ?? {}, { error: entryContext.stack, ...c });\n } else if (typeof entryContext === 'object') {\n context = Object.assign(context ?? {}, entryContext);\n }\n }\n\n if (entry.error) {\n context = Object.assign(context ?? {}, { error: entry.error });\n }\n\n return context && Object.keys(context).length > 0 ? context : undefined;\n};\n\nconst RESERVED_ERROR_KEYS = new Set(['error', 'err']);\n\nconst stringifyOneLevel = (value: unknown): unknown => {\n if (value === null || value === undefined) {\n return value;\n }\n const type = typeof value;\n if (type === 'boolean' || type === 'number' || type === 'string') {\n return value;\n }\n if (type === 'bigint') {\n return (value as bigint).toString();\n }\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n};\n\nconst computeContext = (entry: LogEntry, rawContext: unknown): Record<string, unknown> => {\n const result: Record<string, unknown> = {};\n\n const mergeInto = (source: unknown): void => {\n if (!source || typeof source !== 'object') {\n return;\n }\n for (const [key, value] of Object.entries(source)) {\n if (RESERVED_ERROR_KEYS.has(key)) {\n continue;\n }\n result[key] = stringifyOneLevel(value);\n }\n };\n\n if (entry.meta?.S !== undefined && entry.meta.S !== null) {\n mergeInto(gatherLogInfoFromScope(entry.meta.S));\n }\n\n if (rawContext instanceof Error) {\n // Structured debug info attached to thrown errors lives on `.context`.\n mergeInto((rawContext as any).context);\n } else {\n mergeInto(rawContext);\n }\n\n if (entry.error) {\n mergeInto((entry.error as any).context);\n }\n\n return result;\n};\n\nconst stringifyError = (err: unknown): string | undefined => {\n if (err === null || err === undefined) {\n return undefined;\n }\n if (err instanceof Error) {\n return err.stack ?? err.message;\n }\n return String(err);\n};\n\nconst computeError = (entry: LogEntry, rawContext: unknown): string | undefined => {\n if (entry.error !== undefined) {\n return stringifyError(entry.error);\n }\n\n if (rawContext instanceof Error) {\n return stringifyError(rawContext);\n }\n if (rawContext && typeof rawContext === 'object') {\n const ctxErr = (rawContext as any).error ?? (rawContext as any).err;\n if (ctxErr !== undefined && ctxErr !== null) {\n return stringifyError(ctxErr);\n }\n }\n\n return undefined;\n};\n\nconst computeMeta = (entry: LogEntry): ComputedLogMeta => {\n if (!entry.meta) {\n return {};\n }\n\n const scope = entry.meta.S;\n // Skip globalThis and plain object scopes (module-level logs); only report class instances.\n let scopeContext: string | undefined;\n if (\n typeof scope === 'object' &&\n scope !== null &&\n scope !== globalThis &&\n Object.getPrototypeOf(scope) !== Object.prototype\n ) {\n scopeContext = getDebugName(scope);\n }\n\n return {\n filename: getRelativeFilename(entry.meta.F),\n line: entry.meta.L,\n context: scopeContext,\n };\n};\n"],
5
- "mappings": ";;;AAWO,IAAKA,WAAAA,0BAAAA,WAAAA;;;;;;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,QAAW;AACrC,WAAOA;EACT;AACA,MAAI6C,eAAenB,OAAO;AACxB,WAAOmB,IAAIjB,SAASiB,IAAI1D;EAC1B;AACA,SAAOkD,OAAOQ,GAAAA;AAChB;AAEA,IAAM/C,eAAe,CAACa,OAAiB2B,eAAAA;AACrC,MAAI3B,MAAMrB,UAAUU,QAAW;AAC7B,WAAO4C,eAAejC,MAAMrB,KAAK;EACnC;AAEA,MAAIgD,sBAAsBZ,OAAO;AAC/B,WAAOkB,eAAeN,UAAAA;EACxB;AACA,MAAIA,cAAc,OAAOA,eAAe,UAAU;AAChD,UAAMQ,SAAUR,WAAmBhD,SAAUgD,WAAmBO;AAChE,QAAIC,WAAW9C,UAAa8C,WAAW,MAAM;AAC3C,aAAOF,eAAeE,MAAAA;IACxB;EACF;AAEA,SAAO9C;AACT;AAEA,IAAMC,cAAc,CAACU,UAAAA;AACnB,MAAI,CAACA,MAAMtB,MAAM;AACf,WAAO,CAAC;EACV;AAEA,QAAM0D,QAAQpC,MAAMtB,KAAKgC;AAEzB,MAAI2B;AACJ,MACE,OAAOD,UAAU,YACjBA,UAAU,QACVA,UAAUE,cACV3B,OAAO4B,eAAeH,KAAAA,MAAWzB,OAAO6B,WACxC;AACAH,mBAAeI,aAAaL,KAAAA;EAC9B;AAEA,SAAO;IACLM,UAAUC,oBAAoB3C,MAAMtB,KAAK0B,CAAC;IAC1CwC,MAAM5C,MAAMtB,KAAKmE;IACjBpE,SAAS4D;EACX;AACF;",
6
- "names": ["LogLevel", "levels", "trace", "debug", "verbose", "info", "warn", "error", "shortLevelName", "LogProcessorType", "getRelativeFilename", "filename", "match", "filePath", "logInfoProperties", "Symbol", "logInfo", "target", "propertyKey", "descriptor", "push", "gatherLogInfoFromScope", "scope", "res", "prototype", "Object", "getPrototypeOf", "infoProps", "prop", "err", "message", "getDebugName", "LogEntry", "level", "message", "context", "meta", "error", "timestamp", "init", "Date", "now", "computedContext", "computeContext", "computedError", "computeError", "computedMeta", "undefined", "computeMeta", "matchFilter", "filter", "path", "pattern", "startsWith", "includes", "slice", "length", "shouldLog", "entry", "filters", "results", "map", "F", "result", "some", "getContextFromEntry", "scopeInfo", "gatherLogInfoFromScope", "S", "Object", "keys", "assign", "entryContext", "Error", "c", "stack", "RESERVED_ERROR_KEYS", "Set", "stringifyOneLevel", "value", "type", "toString", "JSON", "stringify", "String", "rawContext", "mergeInto", "source", "key", "entries", "has", "stringifyError", "err", "ctxErr", "scope", "scopeContext", "globalThis", "getPrototypeOf", "prototype", "getDebugName", "filename", "getRelativeFilename", "line", "L"]
7
- }