@dxos/log 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6

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.
@@ -9,7 +9,7 @@ import {
9
9
  logInfo,
10
10
  shortLevelName,
11
11
  shouldLog
12
- } from "./chunk-QPYJZ4SO.mjs";
12
+ } from "./chunk-62VKC2WQ.mjs";
13
13
  import {
14
14
  __export,
15
15
  __reExport
@@ -21,10 +21,12 @@ __export(index_exports, {
21
21
  BROWSER_PROCESSOR: () => BROWSER_PROCESSOR,
22
22
  DEBUG_PROCESSOR: () => DEBUG_PROCESSOR,
23
23
  FILE_PROCESSOR: () => FILE_PROCESSOR,
24
+ LogBuffer: () => LogBuffer,
24
25
  LogLevel: () => LogLevel,
25
26
  LogProcessorType: () => LogProcessorType,
26
27
  createFileProcessor: () => createFileProcessor,
27
28
  createLog: () => createLog,
29
+ dbg: () => dbg,
28
30
  debug: () => debug,
29
31
  gatherLogInfoFromScope: () => gatherLogInfoFromScope,
30
32
  getContextFromEntry: () => getContextFromEntry,
@@ -39,8 +41,7 @@ __export(index_exports, {
39
41
  shortLevelName: () => shortLevelName,
40
42
  shouldLog: () => shouldLog
41
43
  });
42
- import omit from "lodash.omit";
43
- import { pick } from "@dxos/util";
44
+ import { omit, pick } from "@dxos/util";
44
45
 
45
46
  // src/decorators.ts
46
47
  import { inspect } from "node:util";
@@ -431,7 +432,7 @@ var createLog = () => {
431
432
  * NOTE: Preserves any processors that were already added to this logger instance
432
433
  * unless an explicit processor option is provided.
433
434
  */
434
- config: ({ processor, ...options }) => {
435
+ config: ({ processor, ...options } = {}) => {
435
436
  const config = createConfig(options);
436
437
  const processors2 = processor ? config.processors : log2._config.processors;
437
438
  log2._config = {
@@ -488,11 +489,89 @@ var getFormattedStackTrace = () => new Error().stack.split("\n").slice(3).join("
488
489
  // src/index.ts
489
490
  __reExport(index_exports, processors_exports);
490
491
 
492
+ // src/dbg.ts
493
+ var dbg = (arg, meta) => {
494
+ if (meta?.A) {
495
+ console.log(`${meta.A[0]} =`, arg);
496
+ } else {
497
+ console.log(arg);
498
+ }
499
+ return arg;
500
+ };
501
+
502
+ // src/log-buffer.ts
503
+ import { CircularBuffer, getDebugName as getDebugName2 } from "@dxos/util";
504
+ var DEFAULT_BUFFER_SIZE = 2e3;
505
+ var MAX_CONTEXT_LENGTH = 500;
506
+ var LogBuffer = class {
507
+ _buffer;
508
+ constructor(size = DEFAULT_BUFFER_SIZE) {
509
+ this._buffer = new CircularBuffer(size);
510
+ }
511
+ /** Log processor that can be registered with `log.runtimeConfig.processors`. */
512
+ logProcessor = (_config, entry) => {
513
+ if (entry.level <= LogLevel.TRACE) {
514
+ return;
515
+ }
516
+ const record = {
517
+ t: (/* @__PURE__ */ new Date()).toISOString(),
518
+ l: shortLevelName[entry.level] ?? "?",
519
+ m: entry.message ?? ""
520
+ };
521
+ if (entry.meta) {
522
+ record.f = getRelativeFilename3(entry.meta.F);
523
+ record.n = entry.meta.L;
524
+ }
525
+ if (entry.error) {
526
+ record.e = entry.error.stack ?? entry.error.message;
527
+ }
528
+ if (entry.context != null) {
529
+ try {
530
+ const ctx = typeof entry.context === "function" ? entry.context() : entry.context;
531
+ if (ctx != null && !(ctx instanceof Error)) {
532
+ let json = JSON.stringify(ctx);
533
+ if (json.length > MAX_CONTEXT_LENGTH) {
534
+ json = json.slice(0, MAX_CONTEXT_LENGTH);
535
+ }
536
+ record.c = json;
537
+ }
538
+ } catch {
539
+ }
540
+ }
541
+ const scope = entry.meta?.S;
542
+ if (typeof scope === "object" && scope !== null && Object.getPrototypeOf(scope) !== Object.prototype) {
543
+ record.o = getDebugName2(scope);
544
+ }
545
+ this._buffer.push(record);
546
+ };
547
+ /** Number of entries currently in the buffer. */
548
+ get size() {
549
+ return this._buffer.elementCount;
550
+ }
551
+ /** Discard all buffered entries. */
552
+ clear() {
553
+ this._buffer.clear();
554
+ }
555
+ /** Serialize buffer contents as NDJSON (newline-delimited JSON). */
556
+ serialize() {
557
+ const lines = [];
558
+ for (const record of this._buffer) {
559
+ lines.push(JSON.stringify(record));
560
+ }
561
+ return lines.join("\n");
562
+ }
563
+ };
564
+ var getRelativeFilename3 = (filename) => {
565
+ const match = filename.match(/.+\/(packages\/.+\/.+)/);
566
+ if (match) {
567
+ return match[1];
568
+ }
569
+ return filename;
570
+ };
571
+
491
572
  // src/experimental/ownership.ts
492
573
  import { inspect as inspect3 } from "node:util";
493
- var kOwnershipScope = Symbol("kOwnershipScope");
494
- var kCurrentOwnershipScope = Symbol("kCurrentOwnershipScope");
495
- var kDebugInfoProperties = Symbol("kDebugInfoProperties");
574
+ var kDebugInfoProperties = /* @__PURE__ */ Symbol("kDebugInfoProperties");
496
575
  var OwnershipScope = class {
497
576
  constr;
498
577
  parent;
@@ -525,10 +604,12 @@ export {
525
604
  BROWSER_PROCESSOR,
526
605
  DEBUG_PROCESSOR,
527
606
  FILE_PROCESSOR,
607
+ LogBuffer,
528
608
  LogLevel,
529
609
  LogProcessorType,
530
610
  createFileProcessor,
531
611
  createLog,
612
+ dbg,
532
613
  debug,
533
614
  gatherLogInfoFromScope,
534
615
  getContextFromEntry,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/index.ts", "../../../src/decorators.ts", "../../../src/options.ts", "../../../src/platform/index.ts", "../../../src/processors/index.ts", "../../../src/processors/browser-processor.ts", "../../../src/processors/debug-processor.ts", "../../../src/processors/file-processor.ts", "../../../src/log.ts", "../../../src/experimental/ownership.ts"],
4
- "sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport omit from 'lodash.omit';\n\nimport { pick } from '@dxos/util';\n\nexport { omit, pick };\n\nexport * from './config';\nexport * from './context';\nexport * from './log';\nexport { parseFilter } from './options';\nexport * from './processors';\nexport * from './scope';\nexport type * from './meta';\n\nexport { getCurrentOwnershipScope } from './experimental/ownership';\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { inspect } from 'node:util';\n\nimport chalk from 'chalk';\n\nimport { type LogMethods } from './log';\nimport { type CallMetadata } from './meta';\n\nlet nextPromiseId = 0;\n\nexport const createMethodLogDecorator =\n (log: LogMethods) =>\n (arg0?: never, arg1?: never, meta?: CallMetadata): MethodDecorator =>\n (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const method = descriptor.value!;\n const methodName = propertyKey as string;\n descriptor.value = function (this: any, ...args: any) {\n const combinedMeta = {\n F: '',\n L: 0,\n ...(meta ?? {}),\n S: this as any,\n } as CallMetadata;\n\n const formattedArgs = args.map((arg: any) => inspect(arg, false, 1, true)).join(', ');\n\n try {\n const startTime = performance.now();\n const result = method.apply(this, args);\n\n if (isThenable(result)) {\n const id = nextPromiseId++;\n logAsyncBegin(log, methodName, formattedArgs, id, combinedMeta);\n result.then(\n (resolvedValue) => {\n logAsyncResolved(log, methodName, resolvedValue, id, startTime, combinedMeta);\n },\n (err) => {\n logAsyncRejected(log, methodName, err, id, startTime, combinedMeta);\n },\n );\n } else {\n logSyncCall(log, methodName, formattedArgs, result, combinedMeta);\n }\n\n return result;\n } catch (err: any) {\n logSyncError(log, methodName, formattedArgs, err, combinedMeta);\n throw err;\n }\n };\n Object.defineProperty(descriptor.value, 'name', { value: methodName + '$log' });\n };\n\nexport const createFunctionLogDecorator =\n (log: LogMethods) =>\n <F extends (...args: any[]) => any>(\n name: string,\n fn: F,\n opts: { transformOutput?: (result: ReturnType<F>) => Promise<any> | any } = {},\n ): F => {\n const decoratedFn = function (this: any, ...args: any) {\n const combinedMeta = {\n F: '',\n L: 0,\n } as CallMetadata;\n\n const formattedArgs = args.map((arg: any) => inspect(arg, false, 1, true)).join(', ');\n\n try {\n const startTime = performance.now();\n const result = fn.apply(this, args);\n\n let transformedResult = result;\n if (opts.transformOutput) {\n if (isThenable(result)) {\n transformedResult = result.then(opts.transformOutput as any);\n } else {\n transformedResult = opts.transformOutput(result);\n }\n }\n\n if (isThenable(transformedResult)) {\n const id = nextPromiseId++;\n logAsyncBegin(log, name, formattedArgs, id, combinedMeta);\n transformedResult.then(\n (resolvedValue) => {\n logAsyncResolved(log, name, resolvedValue, id, startTime, combinedMeta);\n },\n (err) => {\n logAsyncRejected(log, name, err, id, startTime, combinedMeta);\n },\n );\n } else {\n logSyncCall(log, name, formattedArgs, transformedResult, combinedMeta);\n }\n\n return result;\n } catch (err: any) {\n logSyncError(log, name, formattedArgs, err, combinedMeta);\n throw err;\n }\n };\n Object.defineProperty(decoratedFn, 'name', { value: name + '$log' });\n return decoratedFn as F;\n };\n\nconst isThenable = (obj: any): obj is Promise<unknown> => obj && typeof obj.then === 'function';\n\nconst logSyncCall = (\n log: LogMethods,\n methodName: string,\n formattedArgs: string,\n result: unknown,\n combinedMeta: CallMetadata,\n) => {\n log.info(\n `.${formatFunction(methodName)} (${formattedArgs}) ${chalk.gray('=>')} ${inspect(result, false, 1, true)}`,\n {},\n combinedMeta,\n );\n};\n\nconst logSyncError = (\n log: LogMethods,\n methodName: string,\n formattedArgs: string,\n err: Error,\n combinedMeta: CallMetadata,\n) => {\n log.error(`.${formatFunction(methodName)} (${formattedArgs}) 🔥 ${err}`, {}, combinedMeta);\n};\n\nconst logAsyncBegin = (\n log: LogMethods,\n methodName: string,\n formattedArgs: string,\n promiseId: number,\n combinedMeta: CallMetadata,\n) => {\n log.info(\n `.${formatFunction(methodName)} ↴ (${formattedArgs}) ${chalk.gray('=>')} ${formatPromise(promiseId)}`,\n {},\n combinedMeta,\n );\n};\n\nconst logAsyncResolved = (\n log: LogMethods,\n methodName: string,\n resolvedValue: unknown | undefined,\n promiseId: number,\n startTime: number,\n combinedMeta: CallMetadata,\n) => {\n if (resolvedValue !== undefined) {\n log.info(\n `.${formatFunction(methodName)} ↲ ${greenCheck} ${chalk.gray('resolve')} ${formatPromise(promiseId)} ${formatTimeElapsed(startTime)} ${chalk.gray('=>')} ${inspect(\n resolvedValue,\n false,\n 1,\n true,\n )}`,\n {},\n combinedMeta,\n );\n } else {\n log.info(\n `.${formatFunction(methodName)} ↲ ${greenCheck} ${chalk.gray('resolve')} ${formatPromise(promiseId)} ${formatTimeElapsed(startTime)}`,\n {},\n combinedMeta,\n );\n }\n};\n\nconst logAsyncRejected = (\n log: LogMethods,\n methodName: string,\n err: Error,\n promiseId: number,\n startTime: number,\n combinedMeta: CallMetadata,\n) => {\n log.info(\n `.${formatFunction(methodName)} ↲ 🔥 ${chalk.gray('reject')} ${formatPromise(promiseId)} ${formatTimeElapsed(startTime)} ${chalk.gray('=>')} ${err}`,\n {},\n combinedMeta,\n );\n};\n\nconst COLOR_FUNCTION = [220, 220, 170] as const;\n\n// https://github.com/dxos/dxos/issues/7286\nconst greenCheck = typeof chalk.green === 'function' ? chalk.green('✔') : '✔';\n\nconst formatTimeElapsed = (startTime: number) => chalk.gray(`${(performance.now() - startTime).toFixed(0)}ms`);\n\nconst formatFunction = (name: string) => chalk.bold(chalk.rgb(...COLOR_FUNCTION)(name));\n\nconst formatPromise = (id: number) => chalk.blue(`Promise#${id}`);\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport defaultsDeep from 'lodash.defaultsdeep';\n\nimport { type LogConfig, type LogFilter, LogLevel, type LogOptions, LogProcessorType, levels } from './config';\nimport { type LogProcessor } from './context';\nimport { loadOptions } from './platform';\nimport { BROWSER_PROCESSOR, CONSOLE_PROCESSOR, DEBUG_PROCESSOR } from './processors';\n\n/**\n * Processor variants.\n */\nexport const processors: Record<string, LogProcessor> = {\n [LogProcessorType.CONSOLE]: CONSOLE_PROCESSOR,\n [LogProcessorType.BROWSER]: BROWSER_PROCESSOR,\n [LogProcessorType.DEBUG]: DEBUG_PROCESSOR,\n};\n\nconst browser =\n (typeof window !== 'undefined' || typeof navigator !== 'undefined') &&\n !(typeof process !== 'undefined' && process?.env?.VITEST);\n\nexport const DEFAULT_PROCESSORS = [browser ? BROWSER_PROCESSOR : CONSOLE_PROCESSOR];\n\nconst parseLogLevel = (level: string, defValue = LogLevel.WARN) => levels[level.toLowerCase()] ?? defValue;\n\n/**\n * @internal\n */\nexport const parseFilter = (filter: string | string[] | LogLevel): LogFilter[] => {\n if (typeof filter === 'number') {\n return [{ level: filter }];\n }\n\n const lines = typeof filter === 'string' ? filter.split(/,\\s*/) : filter;\n return lines.map((filter) => {\n const [pattern, level] = filter.split(':');\n return level\n ? {\n level: parseLogLevel(level),\n pattern,\n }\n : {\n level: parseLogLevel(pattern),\n };\n });\n};\n\n/**\n * @internal\n */\nexport const createConfig = (options?: LogOptions): LogConfig => {\n // Node only.\n const envOptions: LogOptions | undefined =\n 'process' in globalThis\n ? {\n file: process!.env.LOG_CONFIG,\n filter: process!.env.LOG_FILTER,\n processor: process!.env.LOG_PROCESSOR,\n }\n : undefined;\n\n const mergedOptions: LogOptions = defaultsDeep({}, loadOptions(envOptions?.file), envOptions, options);\n return {\n options: mergedOptions,\n filters: parseFilter(mergedOptions.filter ?? LogLevel.INFO),\n captureFilters: parseFilter(mergedOptions.captureFilter ?? LogLevel.WARN),\n processors: mergedOptions.processor ? [processors[mergedOptions.processor]] : [...DEFAULT_PROCESSORS],\n prefix: mergedOptions.prefix,\n };\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nexport * from '#platform';\n", "//\n// Copyright 2022 DXOS.org\n//\n\nexport * from './browser-processor';\nexport * from './common';\nexport * from '#console-processor';\nexport * from './debug-processor';\nexport * from './file-processor';\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { getDebugName, safariCheck } from '@dxos/util';\n\nimport { LogLevel } from '../config';\nimport { type LogProcessor, getContextFromEntry, shouldLog } from '../context';\n\nconst 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\ntype Config = {\n useTestProcessor: boolean;\n printFileLinks: boolean;\n};\n\nconst CONFIG: Config = {\n useTestProcessor: false,\n printFileLinks: false,\n};\n\n/**\n * For running apps in the browser normally.\n */\nconst APP_BROWSER_PROCESSOR: LogProcessor = (config, entry) => {\n if (!shouldLog(entry, config.filters)) {\n return;\n }\n\n // Example local editor prefix: 'vscode://file/Users/burdon/Code/dxos/dxos/'.\n const LOG_BROWSER_PREFIX = config.prefix ?? 'https://vscode.dev/github.com/dxos/dxos/blob/main/';\n\n // TODO(burdon): CSS breaks formatting (e.g., [Object] rather than expandable property).\n // TODO(burdon): Consider custom formatters.\n // https://www.mattzeunert.com/2016/02/19/custom-chrome-devtools-object-formatters.html\n // NOTE: Cannot change color of link (from bright white).\n // const LOG_BROWSER_CSS = ['color:gray; font-size:10px; padding-bottom: 4px', 'color:#B97852; font-size:14px;'];\n const LOG_BROWSER_CSS: string[] = [];\n\n let link = '';\n if (entry.meta) {\n const filename = getRelativeFilename(entry.meta.F);\n const filepath = `${LOG_BROWSER_PREFIX.replace(/\\/$/, '')}/${filename}`;\n // TODO(burdon): Line numbers not working for app link, even with colons.\n // https://stackoverflow.com/a/54459820/2804332\n link = `${filepath}#L${entry.meta.L}`;\n }\n\n let args = [];\n\n if (entry.meta?.S) {\n const scope = entry.meta?.S;\n const scopeName = scope.name || getDebugName(scope);\n const processPrefix = entry.meta.S?.hostSessionId ? '[worker] ' : '';\n // TODO(dmaretskyi): Those can be made clickable with a custom formatter.\n args.push(`%c${processPrefix}${scopeName}`, 'color:#C026D3;font-weight:bold');\n }\n\n if (entry.message) {\n args.push(entry.message);\n }\n\n const context = getContextFromEntry(entry);\n if (context) {\n if (Object.keys(context).length === 1 && 'error' in context) {\n args.push(context.error);\n } else if (Object.keys(context).length === 1 && 'err' in context) {\n args.push(context.err);\n } else {\n args.push(context);\n }\n }\n\n // https://github.com/cloudflare/workers-sdk/issues/5591\n const levels: any = {\n [LogLevel.ERROR]: console.error.bind(console),\n [LogLevel.WARN]: console.warn.bind(console),\n [LogLevel.DEBUG]: console.log.bind(console),\n };\n\n // Safari prints source code location as this file, not the caller.\n if (CONFIG.printFileLinks || safariCheck()) {\n if (LOG_BROWSER_CSS?.length) {\n args = [`%c${link}\\n%c${args.join(' ')}`, ...LOG_BROWSER_CSS];\n } else {\n args = [link + '\\n', ...args];\n }\n }\n\n // https://github.com/cloudflare/workers-sdk/issues/5591\n const level = levels[entry.level] ?? console.log.bind(console);\n if (typeof entry.meta?.C === 'function') {\n entry.meta.C(level, args);\n } else {\n level(...args);\n }\n};\n\n/**\n * For running unit tests in the headless browser.\n */\nconst TEST_BROWSER_PROCESSOR: LogProcessor = (config, entry) => {\n if (!shouldLog(entry, config.filters)) {\n return;\n }\n\n let path = '';\n if (entry.meta) {\n path = `${getRelativeFilename(entry.meta.F)}:${entry.meta.L}`;\n }\n\n let args = [];\n\n const processPrefix = entry.meta?.S?.hostSessionId ? '[worker] ' : '';\n args.push(`${processPrefix}${entry.message}`);\n\n const context = getContextFromEntry(entry);\n if (context) {\n args.push(context);\n }\n\n const levels: any = {\n [LogLevel.ERROR]: console.error,\n [LogLevel.WARN]: console.warn,\n [LogLevel.DEBUG]: console.log,\n };\n\n if (CONFIG.printFileLinks) {\n args = [path, ...args];\n }\n\n const level = levels[entry.level] ?? console.log;\n if (typeof entry.meta?.C === 'function') {\n entry.meta.C(level, args);\n } else {\n level(...args);\n }\n};\n\nexport const BROWSER_PROCESSOR: LogProcessor = CONFIG.useTestProcessor ? TEST_BROWSER_PROCESSOR : APP_BROWSER_PROCESSOR;\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { inspect } from 'node:util';\n\nimport { type LogProcessor } from '../context';\n\nexport const DEBUG_PROCESSOR: LogProcessor = (config, entry) => {\n console.log(inspect(entry, false, null, true));\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { appendFileSync, mkdirSync, openSync } from 'node:fs';\nimport { dirname } from 'node:path';\n\nimport { jsonlogify } from '@dxos/util';\n\nimport { type LogFilter, LogLevel } from '../config';\nimport { type LogProcessor, getContextFromEntry, shouldLog } from '../context';\n\nimport { getRelativeFilename } from './common';\n\n// Amount of time to retry writing after encountering EAGAIN before giving up.\nconst EAGAIN_MAX_DURATION = 1000;\n\n/**\n * Create a file processor.\n * @param path - Path to log file to create or append to, or existing open file descriptor e.g. stdout.\n * @param levels - Log levels to process. Takes preference over Filters.\n * @param filters - Filters to apply.\n */\nexport const createFileProcessor = ({\n pathOrFd,\n levels,\n filters,\n}: {\n pathOrFd: string | number;\n levels: LogLevel[];\n filters?: LogFilter[];\n}): LogProcessor => {\n let fd: number | undefined;\n\n return (config, entry) => {\n if (levels.length > 0 && !levels.includes(entry.level)) {\n return;\n }\n if (!shouldLog(entry, filters)) {\n return;\n }\n\n if (typeof pathOrFd === 'number') {\n fd = pathOrFd;\n } else {\n try {\n mkdirSync(dirname(pathOrFd));\n } catch {}\n fd = openSync(pathOrFd, 'a');\n }\n\n const record = {\n ...entry,\n timestamp: Date.now(),\n ...(entry.meta ? { meta: { file: getRelativeFilename(entry.meta.F), line: entry.meta.L } } : {}),\n context: jsonlogify(getContextFromEntry(entry)),\n };\n let retryTS: number = 0;\n\n // Retry writing if EAGAIN is encountered.\n //\n // Node may set stdout and stderr to non-blocking. https://github.com/nodejs/node/issues/42826\n // This can cause EAGAIN errors when writing to them.\n // In order to not drop logs, make log methods asynchronous, or deal with buffering/delayed writes, spin until write succeeds.\n\n while (true) {\n try {\n return appendFileSync(fd, JSON.stringify(record) + '\\n');\n } catch (err: any) {\n if (err.code !== 'EAGAIN') {\n throw err;\n }\n if (retryTS === 0) {\n retryTS = performance.now();\n } else {\n if (performance.now() - retryTS > EAGAIN_MAX_DURATION) {\n console.log(`could not write after ${EAGAIN_MAX_DURATION}ms of EAGAIN failures, giving up`);\n throw err;\n }\n }\n }\n }\n };\n};\n\nlet logFilePath: string | undefined;\nconst getLogFilePath = () => {\n logFilePath ??=\n process.env.LOG_FILE ??\n (process.env.HOME ? `${process.env.HOME}/.dxlog/${new Date().toISOString()}.log` : undefined);\n\n return logFilePath!;\n};\n\nexport const FILE_PROCESSOR: LogProcessor = createFileProcessor({\n pathOrFd: getLogFilePath(),\n levels: [LogLevel.ERROR, LogLevel.WARN, LogLevel.INFO, LogLevel.TRACE],\n});\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { type LogConfig, LogLevel, type LogOptions } from './config';\nimport { type LogContext, type LogProcessor } from './context';\nimport { createFunctionLogDecorator, createMethodLogDecorator } from './decorators';\nimport { type CallMetadata } from './meta';\nimport { createConfig } from './options';\n\n/**\n * Accessible from browser console.\n */\ndeclare global {\n const DX_LOG: Log;\n}\n\n/**\n * Logging function.\n */\ntype LogFunction = (message: string, context?: LogContext, meta?: CallMetadata) => void;\n\n/**\n * Logging methods.\n */\nexport interface LogMethods {\n config: (options: LogOptions) => Log;\n addProcessor: (processor: LogProcessor, addDefault?: boolean) => () => void;\n\n trace: LogFunction;\n debug: LogFunction;\n verbose: LogFunction;\n info: LogFunction;\n warn: LogFunction;\n error: LogFunction;\n catch: (error: Error | any, context?: LogContext, meta?: CallMetadata) => void;\n\n method: (arg0?: never, arg1?: never, meta?: CallMetadata) => MethodDecorator;\n function: <F extends (...args: any[]) => any>(\n name: string,\n fn: F,\n opts?: {\n transformOutput?: (result: ReturnType<F>) => Promise<any> | any;\n },\n ) => F;\n\n break: () => void;\n stack: (message?: string, context?: never, meta?: CallMetadata) => void;\n}\n\n/**\n * Properties accessible on the logging function.\n * @internal\n */\nexport interface Log extends LogFunction, LogMethods {\n readonly runtimeConfig: LogConfig;\n}\n\n/**\n * @internal\n */\ninterface LogImp extends Log {\n _id: string;\n _config: LogConfig;\n}\n\nlet logCount = 0;\n\n/**\n * Create a logging function with properties.\n * @internal\n */\nexport const createLog = (): LogImp => {\n // Default function.\n const log: LogImp = ((...params) => processLog(LogLevel.DEBUG, ...params)) as LogImp;\n\n // Add private properties.\n Object.assign<LogImp, Partial<LogImp>>(log, {\n _id: `log-${++logCount}`,\n _config: createConfig(),\n });\n\n // TODO(burdon): Document.\n Object.defineProperty(log, 'runtimeConfig', {\n get: () => log._config,\n });\n\n /**\n * Process the current log call.\n */\n const processLog = (\n level: LogLevel,\n message: string | undefined,\n context: LogContext = {},\n meta?: CallMetadata,\n error?: Error,\n ) => {\n // TODO(burdon): Do the filter matching upstream (here) rather than in each processor?\n log._config.processors.forEach((processor) =>\n processor(log._config, {\n level,\n message,\n context,\n meta,\n error,\n }),\n );\n };\n\n /**\n * API.\n */\n Object.assign<Log, LogMethods>(log, {\n /**\n * Update config.\n * NOTE: Preserves any processors that were already added to this logger instance\n * unless an explicit processor option is provided.\n */\n config: ({ processor, ...options }) => {\n const config = createConfig(options);\n // TODO(burdon): This could be buggy since the behavior is not reentrant.\n const processors = processor ? config.processors : log._config.processors;\n log._config = { ...config, processors };\n return log;\n },\n\n /**\n * Adds a processor to the logger.\n */\n addProcessor: (processor) => {\n if (log._config.processors.filter((p) => p === processor).length === 0) {\n log._config.processors.push(processor);\n }\n\n return () => {\n log._config.processors = log._config.processors.filter((p) => p !== processor);\n };\n },\n\n trace: (...params) => processLog(LogLevel.TRACE, ...params),\n debug: (...params) => processLog(LogLevel.DEBUG, ...params),\n verbose: (...params) => processLog(LogLevel.VERBOSE, ...params),\n info: (...params) => processLog(LogLevel.INFO, ...params),\n warn: (...params) => processLog(LogLevel.WARN, ...params),\n error: (...params) => processLog(LogLevel.ERROR, ...params),\n catch: (error, context, meta) => processLog(LogLevel.ERROR, undefined, context, meta, error),\n\n method: createMethodLogDecorator(log),\n function: createFunctionLogDecorator(log),\n\n break: () => log.info('-'.repeat(80)),\n stack: (message, context, meta) => {\n return processLog(LogLevel.INFO, `${message ?? 'Stack Dump'}\\n${getFormattedStackTrace()}`, context, meta);\n },\n });\n\n return log;\n};\n\n/**\n * Global logging function.\n */\nexport const log: Log = ((globalThis as any).DX_LOG ??= createLog());\n\nconst start = Date.now();\nlet last = start;\n\n/**\n * Log debug stack.\n */\nexport const debug = (label?: any, args?: any) => {\n const now = Date.now();\n const err = new Error();\n console.group(\n `DEBUG[${label}]`,\n JSON.stringify({ t: Number(now - start).toLocaleString(), dt: Number(now - last).toLocaleString(), ...args }),\n );\n console.warn(err.stack);\n console.groupEnd();\n last = Date.now();\n};\n\nconst getFormattedStackTrace = () => new Error().stack!.split('\\n').slice(3).join('\\n');\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { inspect } from 'node:util';\n\nconst kOwnershipScope = Symbol('kOwnershipScope');\nconst kCurrentOwnershipScope = Symbol('kCurrentOwnershipScope');\nconst kDebugInfoProperties = Symbol('kDebugInfoProperties');\n\n/**\n *\n */\n// TODO(burdon): Document.\nexport class OwnershipScope {\n public instance: any;\n\n constructor(\n public constr: any,\n public parent?: OwnershipScope,\n ) {}\n\n getInfo() {\n if (!this.instance) {\n return {};\n }\n const props = this.constr.prototype[kDebugInfoProperties] ?? [];\n const info: any = {};\n for (const prop of props) {\n info[prop] = this.instance[prop];\n }\n return info;\n }\n\n [inspect.custom]() {\n return {\n className: this.constr.name,\n info: this.getInfo(),\n parent: this.parent,\n };\n }\n}\n\nfunction decorateMethodWeakReturnOwnership(prototype: any, key: string) {\n const original = prototype[key];\n prototype[key] = function (...args: any) {\n const res = original.apply(this, ...args);\n\n if (res && typeof res.then === 'function') {\n res.then((value: any) => {\n if (kOwnershipScope in value) {\n value[kOwnershipScope].parent ??= this[kOwnershipScope];\n }\n });\n } else {\n if (res && kOwnershipScope in res) {\n res[kOwnershipScope].parent ??= this[kOwnershipScope];\n }\n }\n\n return res;\n };\n}\n\nexport function ownershipClass<T extends { new (...args: any[]): {} }>(constr: T) {\n for (const key of Object.getOwnPropertyNames(constr.prototype)) {\n if (key !== 'constructor' && typeof constr.prototype[key] === 'function') {\n decorateMethodWeakReturnOwnership(constr.prototype, key);\n }\n }\n\n return class extends constr {\n constructor(...args: any[]) {\n const currentCausality = (globalThis as any)[kCurrentOwnershipScope];\n (globalThis as any)[kCurrentOwnershipScope] = new OwnershipScope(constr, currentCausality);\n super(...args);\n (this as any)[kOwnershipScope] = (globalThis as any)[kCurrentOwnershipScope];\n (this as any)[kOwnershipScope].instance = this;\n (globalThis as any)[kCurrentOwnershipScope] = currentCausality;\n }\n };\n}\n\nexport const debugInfo = (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {\n // console.log(target, propertyKey, descriptor);\n (target[kDebugInfoProperties] ??= []).push(propertyKey);\n};\n\nexport const getCurrentOwnershipScope = (thisRef: any) => thisRef;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;AAIA,OAAOA,UAAU;AAEjB,SAASC,YAAY;;;ACFrB,SAASC,eAAe;AAExB,OAAOC,WAAW;AAKlB,IAAIC,gBAAgB;AAEb,IAAMC,2BACX,CAACC,SACD,CAACC,MAAcC,MAAcC,SAC7B,CAACC,QAAaC,aAA8BC,eAAAA;AAC1C,QAAMC,SAASD,WAAWE;AAC1B,QAAMC,aAAaJ;AACnBC,aAAWE,QAAQ,YAAwBE,MAAS;AAClD,UAAMC,eAAe;MACnBC,GAAG;MACHC,GAAG;MACH,GAAIV,QAAQ,CAAC;MACbW,GAAG;IACL;AAEA,UAAMC,gBAAgBL,KAAKM,IAAI,CAACC,QAAaC,QAAQD,KAAK,OAAO,GAAG,IAAA,CAAA,EAAOE,KAAK,IAAA;AAEhF,QAAI;AACF,YAAMC,YAAYC,YAAYC,IAAG;AACjC,YAAMC,SAAShB,OAAOiB,MAAM,MAAMd,IAAAA;AAElC,UAAIe,WAAWF,MAAAA,GAAS;AACtB,cAAMG,KAAK5B;AACX6B,sBAAc3B,MAAKS,YAAYM,eAAeW,IAAIf,YAAAA;AAClDY,eAAOK,KACL,CAACC,kBAAAA;AACCC,2BAAiB9B,MAAKS,YAAYoB,eAAeH,IAAIN,WAAWT,YAAAA;QAClE,GACA,CAACoB,QAAAA;AACCC,2BAAiBhC,MAAKS,YAAYsB,KAAKL,IAAIN,WAAWT,YAAAA;QACxD,CAAA;MAEJ,OAAO;AACLsB,oBAAYjC,MAAKS,YAAYM,eAAe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AACE,SAAQC,MAAM,IAAI;AACjB,WAAO;MACLC,WAAW,KAAKT,OAAOU;MACvBL,MAAM,KAAKH,QAAO;MAClBD,QAAQ,KAAKA;IACf;EACF;AACF;AA+CO,IAAMU,2BAA2B,CAACC,YAAiBA;",
6
- "names": ["omit", "pick", "inspect", "chalk", "nextPromiseId", "createMethodLogDecorator", "log", "arg0", "arg1", "meta", "target", "propertyKey", "descriptor", "method", "value", "methodName", "args", "combinedMeta", "F", "L", "S", "formattedArgs", "map", "arg", "inspect", "join", "startTime", "performance", "now", "result", "apply", "isThenable", "id", "logAsyncBegin", "then", "resolvedValue", "logAsyncResolved", "err", "logAsyncRejected", "logSyncCall", "logSyncError", "Object", "defineProperty", "createFunctionLogDecorator", "name", "fn", "opts", "decoratedFn", "transformedResult", "transformOutput", "obj", "info", "formatFunction", "chalk", "gray", "error", "promiseId", "formatPromise", "undefined", "greenCheck", "formatTimeElapsed", "COLOR_FUNCTION", "green", "toFixed", "bold", "rgb", "blue", "defaultsDeep", "getDebugName", "safariCheck", "getRelativeFilename", "filename", "match", "filePath", "CONFIG", "useTestProcessor", "printFileLinks", "APP_BROWSER_PROCESSOR", "config", "entry", "shouldLog", "filters", "LOG_BROWSER_PREFIX", "prefix", "LOG_BROWSER_CSS", "link", "meta", "F", "filepath", "replace", "L", "args", "S", "scope", "scopeName", "name", "getDebugName", "processPrefix", "hostSessionId", "push", "message", "context", "getContextFromEntry", "Object", "keys", "length", "error", "err", "levels", "LogLevel", "ERROR", "console", "bind", "WARN", "warn", "DEBUG", "log", "safariCheck", "join", "level", "C", "TEST_BROWSER_PROCESSOR", "path", "BROWSER_PROCESSOR", "inspect", "DEBUG_PROCESSOR", "config", "entry", "console", "log", "inspect", "appendFileSync", "mkdirSync", "openSync", "dirname", "jsonlogify", "EAGAIN_MAX_DURATION", "createFileProcessor", "pathOrFd", "levels", "filters", "fd", "config", "entry", "length", "includes", "level", "shouldLog", "mkdirSync", "dirname", "openSync", "record", "timestamp", "Date", "now", "meta", "file", "getRelativeFilename", "F", "line", "L", "context", "jsonlogify", "getContextFromEntry", "retryTS", "appendFileSync", "JSON", "stringify", "err", "code", "performance", "console", "log", "logFilePath", "getLogFilePath", "process", "env", "LOG_FILE", "HOME", "toISOString", "undefined", "FILE_PROCESSOR", "LogLevel", "ERROR", "WARN", "INFO", "TRACE", "processors", "LogProcessorType", "CONSOLE", "CONSOLE_PROCESSOR", "BROWSER", "BROWSER_PROCESSOR", "DEBUG", "DEBUG_PROCESSOR", "browser", "window", "navigator", "process", "env", "VITEST", "DEFAULT_PROCESSORS", "parseLogLevel", "level", "defValue", "LogLevel", "WARN", "levels", "toLowerCase", "parseFilter", "filter", "lines", "split", "map", "pattern", "createConfig", "options", "envOptions", "globalThis", "file", "LOG_CONFIG", "LOG_FILTER", "processor", "LOG_PROCESSOR", "undefined", "mergedOptions", "defaultsDeep", "loadOptions", "filters", "INFO", "captureFilters", "captureFilter", "prefix", "logCount", "createLog", "log", "params", "processLog", "LogLevel", "DEBUG", "Object", "assign", "_id", "_config", "createConfig", "defineProperty", "get", "level", "message", "context", "meta", "error", "processors", "forEach", "processor", "config", "options", "addProcessor", "filter", "p", "length", "push", "trace", "TRACE", "debug", "verbose", "VERBOSE", "info", "INFO", "warn", "WARN", "ERROR", "catch", "undefined", "method", "createMethodLogDecorator", "function", "createFunctionLogDecorator", "break", "repeat", "stack", "getFormattedStackTrace", "globalThis", "DX_LOG", "start", "Date", "now", "last", "label", "args", "err", "Error", "console", "group", "JSON", "stringify", "t", "Number", "toLocaleString", "dt", "groupEnd", "split", "slice", "join", "inspect", "kOwnershipScope", "Symbol", "kCurrentOwnershipScope", "kDebugInfoProperties", "OwnershipScope", "instance", "constr", "parent", "getInfo", "props", "prototype", "info", "prop", "inspect", "custom", "className", "name", "getCurrentOwnershipScope", "thisRef"]
3
+ "sources": ["../../../src/index.ts", "../../../src/decorators.ts", "../../../src/options.ts", "../../../src/platform/index.ts", "../../../src/processors/index.ts", "../../../src/processors/browser-processor.ts", "../../../src/processors/debug-processor.ts", "../../../src/processors/file-processor.ts", "../../../src/log.ts", "../../../src/dbg.ts", "../../../src/log-buffer.ts", "../../../src/experimental/ownership.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { omit, pick } from '@dxos/util';\n\nexport { omit, pick };\n\nexport * from './config';\nexport * from './context';\nexport * from './log';\nexport { parseFilter } from './options';\nexport * from './processors';\nexport * from './scope';\nexport type * from './meta';\nexport { dbg } from './dbg';\nexport * from './log-buffer';\n\nexport { getCurrentOwnershipScope } from './experimental/ownership';\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { inspect } from 'node:util';\n\nimport chalk from 'chalk';\n\nimport { type LogMethods } from './log';\nimport { type CallMetadata } from './meta';\n\nlet nextPromiseId = 0;\n\nexport const createMethodLogDecorator =\n (log: LogMethods) =>\n (arg0?: never, arg1?: never, meta?: CallMetadata): MethodDecorator =>\n (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const method = descriptor.value!;\n const methodName = propertyKey as string;\n descriptor.value = function (this: any, ...args: any) {\n const combinedMeta = {\n F: '',\n L: 0,\n ...(meta ?? {}),\n S: this as any,\n } as CallMetadata;\n\n const formattedArgs = args.map((arg: any) => inspect(arg, false, 1, true)).join(', ');\n\n try {\n const startTime = performance.now();\n const result = method.apply(this, args);\n\n if (isThenable(result)) {\n const id = nextPromiseId++;\n logAsyncBegin(log, methodName, formattedArgs, id, combinedMeta);\n result.then(\n (resolvedValue) => {\n logAsyncResolved(log, methodName, resolvedValue, id, startTime, combinedMeta);\n },\n (err) => {\n logAsyncRejected(log, methodName, err, id, startTime, combinedMeta);\n },\n );\n } else {\n logSyncCall(log, methodName, formattedArgs, result, combinedMeta);\n }\n\n return result;\n } catch (err: any) {\n logSyncError(log, methodName, formattedArgs, err, combinedMeta);\n throw err;\n }\n };\n Object.defineProperty(descriptor.value, 'name', { value: methodName + '$log' });\n };\n\nexport const createFunctionLogDecorator =\n (log: LogMethods) =>\n <F extends (...args: any[]) => any>(\n name: string,\n fn: F,\n opts: { transformOutput?: (result: ReturnType<F>) => Promise<any> | any } = {},\n ): F => {\n const decoratedFn = function (this: any, ...args: any) {\n const combinedMeta = {\n F: '',\n L: 0,\n } as CallMetadata;\n\n const formattedArgs = args.map((arg: any) => inspect(arg, false, 1, true)).join(', ');\n\n try {\n const startTime = performance.now();\n const result = fn.apply(this, args);\n\n let transformedResult = result;\n if (opts.transformOutput) {\n if (isThenable(result)) {\n transformedResult = result.then(opts.transformOutput as any);\n } else {\n transformedResult = opts.transformOutput(result);\n }\n }\n\n if (isThenable(transformedResult)) {\n const id = nextPromiseId++;\n logAsyncBegin(log, name, formattedArgs, id, combinedMeta);\n transformedResult.then(\n (resolvedValue) => {\n logAsyncResolved(log, name, resolvedValue, id, startTime, combinedMeta);\n },\n (err) => {\n logAsyncRejected(log, name, err, id, startTime, combinedMeta);\n },\n );\n } else {\n logSyncCall(log, name, formattedArgs, transformedResult, combinedMeta);\n }\n\n return result;\n } catch (err: any) {\n logSyncError(log, name, formattedArgs, err, combinedMeta);\n throw err;\n }\n };\n Object.defineProperty(decoratedFn, 'name', { value: name + '$log' });\n return decoratedFn as F;\n };\n\nconst isThenable = (obj: any): obj is Promise<unknown> => obj && typeof obj.then === 'function';\n\nconst logSyncCall = (\n log: LogMethods,\n methodName: string,\n formattedArgs: string,\n result: unknown,\n combinedMeta: CallMetadata,\n) => {\n log.info(\n `.${formatFunction(methodName)} (${formattedArgs}) ${chalk.gray('=>')} ${inspect(result, false, 1, true)}`,\n {},\n combinedMeta,\n );\n};\n\nconst logSyncError = (\n log: LogMethods,\n methodName: string,\n formattedArgs: string,\n err: Error,\n combinedMeta: CallMetadata,\n) => {\n log.error(`.${formatFunction(methodName)} (${formattedArgs}) 🔥 ${err}`, {}, combinedMeta);\n};\n\nconst logAsyncBegin = (\n log: LogMethods,\n methodName: string,\n formattedArgs: string,\n promiseId: number,\n combinedMeta: CallMetadata,\n) => {\n log.info(\n `.${formatFunction(methodName)} ↴ (${formattedArgs}) ${chalk.gray('=>')} ${formatPromise(promiseId)}`,\n {},\n combinedMeta,\n );\n};\n\nconst logAsyncResolved = (\n log: LogMethods,\n methodName: string,\n resolvedValue: unknown | undefined,\n promiseId: number,\n startTime: number,\n combinedMeta: CallMetadata,\n) => {\n if (resolvedValue !== undefined) {\n log.info(\n `.${formatFunction(methodName)} ↲ ${greenCheck} ${chalk.gray('resolve')} ${formatPromise(promiseId)} ${formatTimeElapsed(startTime)} ${chalk.gray('=>')} ${inspect(\n resolvedValue,\n false,\n 1,\n true,\n )}`,\n {},\n combinedMeta,\n );\n } else {\n log.info(\n `.${formatFunction(methodName)} ↲ ${greenCheck} ${chalk.gray('resolve')} ${formatPromise(promiseId)} ${formatTimeElapsed(startTime)}`,\n {},\n combinedMeta,\n );\n }\n};\n\nconst logAsyncRejected = (\n log: LogMethods,\n methodName: string,\n err: Error,\n promiseId: number,\n startTime: number,\n combinedMeta: CallMetadata,\n) => {\n log.info(\n `.${formatFunction(methodName)} ↲ 🔥 ${chalk.gray('reject')} ${formatPromise(promiseId)} ${formatTimeElapsed(startTime)} ${chalk.gray('=>')} ${err}`,\n {},\n combinedMeta,\n );\n};\n\nconst COLOR_FUNCTION = [220, 220, 170] as const;\n\n// https://github.com/dxos/dxos/issues/7286\nconst greenCheck = typeof chalk.green === 'function' ? chalk.green('✔') : '✔';\n\nconst formatTimeElapsed = (startTime: number) => chalk.gray(`${(performance.now() - startTime).toFixed(0)}ms`);\n\nconst formatFunction = (name: string) => chalk.bold(chalk.rgb(...COLOR_FUNCTION)(name));\n\nconst formatPromise = (id: number) => chalk.blue(`Promise#${id}`);\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport defaultsDeep from 'lodash.defaultsdeep';\n\nimport { type LogConfig, type LogFilter, LogLevel, type LogOptions, LogProcessorType, levels } from './config';\nimport { type LogProcessor } from './context';\nimport { loadOptions } from './platform';\nimport { BROWSER_PROCESSOR, CONSOLE_PROCESSOR, DEBUG_PROCESSOR } from './processors';\n\n/**\n * Processor variants.\n */\nexport const processors: Record<string, LogProcessor> = {\n [LogProcessorType.CONSOLE]: CONSOLE_PROCESSOR,\n [LogProcessorType.BROWSER]: BROWSER_PROCESSOR,\n [LogProcessorType.DEBUG]: DEBUG_PROCESSOR,\n};\n\nconst browser =\n (typeof window !== 'undefined' || typeof navigator !== 'undefined') &&\n !(typeof process !== 'undefined' && process?.env?.VITEST);\n\nexport const DEFAULT_PROCESSORS = [browser ? BROWSER_PROCESSOR : CONSOLE_PROCESSOR];\n\nconst parseLogLevel = (level: string, defValue = LogLevel.WARN) => levels[level.toLowerCase()] ?? defValue;\n\n/**\n * @internal\n */\nexport const parseFilter = (filter: string | string[] | LogLevel): LogFilter[] => {\n if (typeof filter === 'number') {\n return [{ level: filter }];\n }\n\n const lines = typeof filter === 'string' ? filter.split(/,\\s*/) : filter;\n return lines.map((filter) => {\n const [pattern, level] = filter.split(':');\n return level\n ? {\n level: parseLogLevel(level),\n pattern,\n }\n : {\n level: parseLogLevel(pattern),\n };\n });\n};\n\n/**\n * @internal\n */\nexport const createConfig = (options?: LogOptions): LogConfig => {\n // Node only.\n const envOptions: LogOptions | undefined =\n 'process' in globalThis\n ? {\n file: process!.env.LOG_CONFIG,\n filter: process!.env.LOG_FILTER,\n processor: process!.env.LOG_PROCESSOR,\n }\n : undefined;\n\n const mergedOptions: LogOptions = defaultsDeep({}, loadOptions(envOptions?.file), envOptions, options);\n return {\n options: mergedOptions,\n filters: parseFilter(mergedOptions.filter ?? LogLevel.INFO),\n captureFilters: parseFilter(mergedOptions.captureFilter ?? LogLevel.WARN),\n processors: mergedOptions.processor ? [processors[mergedOptions.processor]] : [...DEFAULT_PROCESSORS],\n prefix: mergedOptions.prefix,\n };\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nexport * from '#platform';\n", "//\n// Copyright 2022 DXOS.org\n//\n\nexport * from './browser-processor';\nexport * from './common';\nexport * from '#console-processor';\nexport * from './debug-processor';\nexport * from './file-processor';\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { getDebugName, safariCheck } from '@dxos/util';\n\nimport { LogLevel } from '../config';\nimport { type LogProcessor, getContextFromEntry, shouldLog } from '../context';\n\nconst 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\ntype Config = {\n useTestProcessor: boolean;\n printFileLinks: boolean;\n};\n\nconst CONFIG: Config = {\n useTestProcessor: false,\n printFileLinks: false,\n};\n\n/**\n * For running apps in the browser normally.\n */\nconst APP_BROWSER_PROCESSOR: LogProcessor = (config, entry) => {\n if (!shouldLog(entry, config.filters)) {\n return;\n }\n\n // Example local editor prefix: 'vscode://file/Users/burdon/Code/dxos/dxos/'.\n const LOG_BROWSER_PREFIX = config.prefix ?? 'https://vscode.dev/github.com/dxos/dxos/blob/main/';\n\n // TODO(burdon): CSS breaks formatting (e.g., [Object] rather than expandable property).\n // TODO(burdon): Consider custom formatters.\n // https://www.mattzeunert.com/2016/02/19/custom-chrome-devtools-object-formatters.html\n // NOTE: Cannot change color of link (from bright white).\n // const LOG_BROWSER_CSS = ['color:gray; font-size:10px; padding-bottom: 4px', 'color:#B97852; font-size:14px;'];\n const LOG_BROWSER_CSS: string[] = [];\n\n let link = '';\n if (entry.meta) {\n const filename = getRelativeFilename(entry.meta.F);\n const filepath = `${LOG_BROWSER_PREFIX.replace(/\\/$/, '')}/${filename}`;\n // TODO(burdon): Line numbers not working for app link, even with colons.\n // https://stackoverflow.com/a/54459820/2804332\n link = `${filepath}#L${entry.meta.L}`;\n }\n\n let args = [];\n\n if (entry.meta?.S) {\n const scope = entry.meta?.S;\n const scopeName = scope.name || getDebugName(scope);\n const processPrefix = entry.meta.S?.hostSessionId ? '[worker] ' : '';\n // TODO(dmaretskyi): Those can be made clickable with a custom formatter.\n args.push(`%c${processPrefix}${scopeName}`, 'color:#C026D3;font-weight:bold');\n }\n\n if (entry.message) {\n args.push(entry.message);\n }\n\n const context = getContextFromEntry(entry);\n if (context) {\n if (Object.keys(context).length === 1 && 'error' in context) {\n args.push(context.error);\n } else if (Object.keys(context).length === 1 && 'err' in context) {\n args.push(context.err);\n } else {\n args.push(context);\n }\n }\n\n // https://github.com/cloudflare/workers-sdk/issues/5591\n const levels: any = {\n [LogLevel.ERROR]: console.error.bind(console),\n [LogLevel.WARN]: console.warn.bind(console),\n [LogLevel.DEBUG]: console.log.bind(console),\n };\n\n // Safari prints source code location as this file, not the caller.\n if (CONFIG.printFileLinks || safariCheck()) {\n if (LOG_BROWSER_CSS?.length) {\n args = [`%c${link}\\n%c${args.join(' ')}`, ...LOG_BROWSER_CSS];\n } else {\n args = [link + '\\n', ...args];\n }\n }\n\n // https://github.com/cloudflare/workers-sdk/issues/5591\n const level = levels[entry.level] ?? console.log.bind(console);\n if (typeof entry.meta?.C === 'function') {\n entry.meta.C(level, args);\n } else {\n level(...args);\n }\n};\n\n/**\n * For running unit tests in the headless browser.\n */\nconst TEST_BROWSER_PROCESSOR: LogProcessor = (config, entry) => {\n if (!shouldLog(entry, config.filters)) {\n return;\n }\n\n let path = '';\n if (entry.meta) {\n path = `${getRelativeFilename(entry.meta.F)}:${entry.meta.L}`;\n }\n\n let args = [];\n\n const processPrefix = entry.meta?.S?.hostSessionId ? '[worker] ' : '';\n args.push(`${processPrefix}${entry.message}`);\n\n const context = getContextFromEntry(entry);\n if (context) {\n args.push(context);\n }\n\n const levels: any = {\n [LogLevel.ERROR]: console.error,\n [LogLevel.WARN]: console.warn,\n [LogLevel.DEBUG]: console.log,\n };\n\n if (CONFIG.printFileLinks) {\n args = [path, ...args];\n }\n\n const level = levels[entry.level] ?? console.log;\n if (typeof entry.meta?.C === 'function') {\n entry.meta.C(level, args);\n } else {\n level(...args);\n }\n};\n\nexport const BROWSER_PROCESSOR: LogProcessor = CONFIG.useTestProcessor ? TEST_BROWSER_PROCESSOR : APP_BROWSER_PROCESSOR;\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { inspect } from 'node:util';\n\nimport { type LogProcessor } from '../context';\n\nexport const DEBUG_PROCESSOR: LogProcessor = (config, entry) => {\n console.log(inspect(entry, false, null, true));\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { appendFileSync, mkdirSync, openSync } from 'node:fs';\nimport { dirname } from 'node:path';\n\nimport { jsonlogify } from '@dxos/util';\n\nimport { type LogFilter, LogLevel } from '../config';\nimport { type LogProcessor, getContextFromEntry, shouldLog } from '../context';\n\nimport { getRelativeFilename } from './common';\n\n// Amount of time to retry writing after encountering EAGAIN before giving up.\nconst EAGAIN_MAX_DURATION = 1000;\n\n/**\n * Create a file processor.\n * @param path - Path to log file to create or append to, or existing open file descriptor e.g. stdout.\n * @param levels - Log levels to process. Takes preference over Filters.\n * @param filters - Filters to apply.\n */\nexport const createFileProcessor = ({\n pathOrFd,\n levels,\n filters,\n}: {\n pathOrFd: string | number;\n levels: LogLevel[];\n filters?: LogFilter[];\n}): LogProcessor => {\n let fd: number | undefined;\n\n return (config, entry) => {\n if (levels.length > 0 && !levels.includes(entry.level)) {\n return;\n }\n if (!shouldLog(entry, filters)) {\n return;\n }\n\n if (typeof pathOrFd === 'number') {\n fd = pathOrFd;\n } else {\n try {\n mkdirSync(dirname(pathOrFd));\n } catch {}\n fd = openSync(pathOrFd, 'a');\n }\n\n const record = {\n ...entry,\n timestamp: Date.now(),\n ...(entry.meta ? { meta: { file: getRelativeFilename(entry.meta.F), line: entry.meta.L } } : {}),\n context: jsonlogify(getContextFromEntry(entry)),\n };\n let retryTS: number = 0;\n\n // Retry writing if EAGAIN is encountered.\n //\n // Node may set stdout and stderr to non-blocking. https://github.com/nodejs/node/issues/42826\n // This can cause EAGAIN errors when writing to them.\n // In order to not drop logs, make log methods asynchronous, or deal with buffering/delayed writes, spin until write succeeds.\n\n while (true) {\n try {\n return appendFileSync(fd, JSON.stringify(record) + '\\n');\n } catch (err: any) {\n if (err.code !== 'EAGAIN') {\n throw err;\n }\n if (retryTS === 0) {\n retryTS = performance.now();\n } else {\n if (performance.now() - retryTS > EAGAIN_MAX_DURATION) {\n console.log(`could not write after ${EAGAIN_MAX_DURATION}ms of EAGAIN failures, giving up`);\n throw err;\n }\n }\n }\n }\n };\n};\n\nlet logFilePath: string | undefined;\nconst getLogFilePath = () => {\n logFilePath ??=\n process.env.LOG_FILE ??\n (process.env.HOME ? `${process.env.HOME}/.dxlog/${new Date().toISOString()}.log` : undefined);\n\n return logFilePath!;\n};\n\nexport const FILE_PROCESSOR: LogProcessor = createFileProcessor({\n pathOrFd: getLogFilePath(),\n levels: [LogLevel.ERROR, LogLevel.WARN, LogLevel.INFO, LogLevel.TRACE],\n});\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { type LogConfig, LogLevel, type LogOptions } from './config';\nimport { type LogContext, type LogProcessor } from './context';\nimport { createFunctionLogDecorator, createMethodLogDecorator } from './decorators';\nimport { type CallMetadata } from './meta';\nimport { createConfig } from './options';\n\n/**\n * Accessible from browser console.\n * Example: `DX_LOG.config({ filter: 'ERROR' })`\n * NOTE: File level filtering isn't supported in storybooks.\n */\ndeclare global {\n const DX_LOG: Log;\n}\n\n/**\n * Logging function.\n */\ntype LogFunction = (message: string, context?: LogContext, meta?: CallMetadata) => void;\n\n/**\n * Logging methods.\n */\nexport interface LogMethods {\n config: (options?: LogOptions) => Log;\n addProcessor: (processor: LogProcessor, addDefault?: boolean) => () => void;\n\n trace: LogFunction;\n debug: LogFunction;\n verbose: LogFunction;\n info: LogFunction;\n warn: LogFunction;\n error: LogFunction;\n catch: (error: Error | any, context?: LogContext, meta?: CallMetadata) => void;\n\n method: (arg0?: never, arg1?: never, meta?: CallMetadata) => MethodDecorator;\n function: <F extends (...args: any[]) => any>(\n name: string,\n fn: F,\n opts?: {\n transformOutput?: (result: ReturnType<F>) => Promise<any> | any;\n },\n ) => F;\n\n break: () => void;\n stack: (message?: string, context?: never, meta?: CallMetadata) => void;\n}\n\n/**\n * Properties accessible on the logging function.\n * @internal\n */\nexport interface Log extends LogFunction, LogMethods {\n readonly runtimeConfig: LogConfig;\n}\n\n/**\n * @internal\n */\ninterface LogImp extends Log {\n _id: string;\n _config: LogConfig;\n}\n\nlet logCount = 0;\n\n/**\n * Create a logging function with properties.\n * @internal\n */\nexport const createLog = (): LogImp => {\n // Default function.\n const log: LogImp = ((...params) => processLog(LogLevel.DEBUG, ...params)) as LogImp;\n\n // Add private properties.\n Object.assign<LogImp, Partial<LogImp>>(log, {\n _id: `log-${++logCount}`,\n _config: createConfig(),\n });\n\n // TODO(burdon): Document.\n Object.defineProperty(log, 'runtimeConfig', {\n get: () => log._config,\n });\n\n /**\n * Process the current log call.\n */\n const processLog = (\n level: LogLevel,\n message: string | undefined,\n context: LogContext = {},\n meta?: CallMetadata,\n error?: Error,\n ) => {\n // TODO(burdon): Do the filter matching upstream (here) rather than in each processor?\n log._config.processors.forEach((processor) =>\n processor(log._config, {\n level,\n message,\n context,\n meta,\n error,\n }),\n );\n };\n\n /**\n * API.\n */\n Object.assign<Log, LogMethods>(log, {\n /**\n * Update config.\n * NOTE: Preserves any processors that were already added to this logger instance\n * unless an explicit processor option is provided.\n */\n config: ({ processor, ...options } = {}) => {\n const config = createConfig(options);\n // TODO(burdon): This could be buggy since the behavior is not reentrant.\n const processors = processor ? config.processors : log._config.processors;\n log._config = { ...config, processors };\n return log;\n },\n\n /**\n * Adds a processor to the logger.\n */\n addProcessor: (processor) => {\n if (log._config.processors.filter((p) => p === processor).length === 0) {\n log._config.processors.push(processor);\n }\n\n return () => {\n log._config.processors = log._config.processors.filter((p) => p !== processor);\n };\n },\n\n trace: (...params) => processLog(LogLevel.TRACE, ...params),\n debug: (...params) => processLog(LogLevel.DEBUG, ...params),\n verbose: (...params) => processLog(LogLevel.VERBOSE, ...params),\n info: (...params) => processLog(LogLevel.INFO, ...params),\n warn: (...params) => processLog(LogLevel.WARN, ...params),\n error: (...params) => processLog(LogLevel.ERROR, ...params),\n catch: (error, context, meta) => processLog(LogLevel.ERROR, undefined, context, meta, error),\n\n method: createMethodLogDecorator(log),\n function: createFunctionLogDecorator(log),\n\n break: () => log.info('-'.repeat(80)),\n stack: (message, context, meta) => {\n return processLog(LogLevel.INFO, `${message ?? 'Stack Dump'}\\n${getFormattedStackTrace()}`, context, meta);\n },\n });\n\n return log;\n};\n\n/**\n * Global logging function.\n */\nexport const log: Log = ((globalThis as any).DX_LOG ??= createLog());\n\nconst start = Date.now();\nlet last = start;\n\n/**\n * Log debug stack.\n */\nexport const debug = (label?: any, args?: any) => {\n const now = Date.now();\n const err = new Error();\n console.group(\n `DEBUG[${label}]`,\n JSON.stringify({ t: Number(now - start).toLocaleString(), dt: Number(now - last).toLocaleString(), ...args }),\n );\n console.warn(err.stack);\n console.groupEnd();\n last = Date.now();\n};\n\nconst getFormattedStackTrace = () => new Error().stack!.split('\\n').slice(3).join('\\n');\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { type CallMetadata } from './meta';\n/**\n * Debug-log value to console.\n * Log's the expression being evaluated.\n *\n * If only one argument is provided, it will also be returned.\n *\n * @example\n * ```ts\n * dbg(foo, bar);\n * // foo = 1\n * // bar = 2\n *\n * bar = dbg(foo * 2);\n * // foo * 2 = 2\n * ```\n *\n * NOTE: The second argument is injected by the log transform plugin.\n */\nexport const dbg: {\n <T>(value: T, _meta?: CallMetadata): T;\n} = <T>(arg: T, meta?: CallMetadata): T => {\n if (meta?.A) {\n console.log(`${meta.A[0]} =`, arg);\n } else {\n console.log(arg);\n }\n\n return arg;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { CircularBuffer, getDebugName } from '@dxos/util';\n\nimport { type LogConfig, LogLevel, shortLevelName } from './config';\nimport { type LogEntry, type LogProcessor } from './context';\n\nconst DEFAULT_BUFFER_SIZE = 2_000;\nconst MAX_CONTEXT_LENGTH = 500;\n\n/**\n * Compact log record with short property names for small serialized size.\n */\nexport type LogRecord = {\n /** ISO timestamp. */\n t: string;\n /** Level letter (D, V, I, W, E). */\n l: string;\n /** Message. */\n m: string;\n /** File path. */\n f?: string;\n /** Line number. */\n n?: number;\n /* Object from which the log was emitted. */\n o?: string;\n /** Error stack. */\n e?: string;\n /** Context JSON. */\n c?: string;\n};\n\n/**\n * Captures recent log entries in a circular buffer for debug log dump.\n */\nexport class LogBuffer {\n private readonly _buffer: CircularBuffer<LogRecord>;\n\n constructor(size = DEFAULT_BUFFER_SIZE) {\n this._buffer = new CircularBuffer<LogRecord>(size);\n }\n\n /** Log processor that can be registered with `log.runtimeConfig.processors`. */\n readonly logProcessor: LogProcessor = (_config: LogConfig, entry: LogEntry) => {\n if (entry.level <= LogLevel.TRACE) {\n return;\n }\n\n const record: LogRecord = {\n t: new Date().toISOString(),\n l: shortLevelName[entry.level] ?? '?',\n m: entry.message ?? '',\n };\n\n if (entry.meta) {\n record.f = getRelativeFilename(entry.meta.F);\n record.n = entry.meta.L;\n }\n\n if (entry.error) {\n record.e = entry.error.stack ?? entry.error.message;\n }\n\n if (entry.context != null) {\n try {\n const ctx = typeof entry.context === 'function' ? entry.context() : entry.context;\n if (ctx != null && !(ctx instanceof Error)) {\n let json = JSON.stringify(ctx);\n if (json.length > MAX_CONTEXT_LENGTH) {\n json = json.slice(0, MAX_CONTEXT_LENGTH);\n }\n record.c = json;\n }\n } catch {\n // Skip context that throws or is non-serializable.\n }\n }\n const scope = entry.meta?.S;\n if (typeof scope === 'object' && scope !== null && Object.getPrototypeOf(scope) !== Object.prototype) {\n record.o = getDebugName(scope);\n }\n\n this._buffer.push(record);\n };\n\n /** Number of entries currently in the buffer. */\n get size(): number {\n return this._buffer.elementCount;\n }\n\n /** Discard all buffered entries. */\n clear(): void {\n this._buffer.clear();\n }\n\n /** Serialize buffer contents as NDJSON (newline-delimited JSON). */\n serialize(): string {\n const lines: string[] = [];\n for (const record of this._buffer) {\n lines.push(JSON.stringify(record));\n }\n return lines.join('\\n');\n }\n}\n\nconst getRelativeFilename = (filename: string): string => {\n const match = filename.match(/.+\\/(packages\\/.+\\/.+)/);\n if (match) {\n return match[1];\n }\n return filename;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { inspect } from 'node:util';\n\nconst kOwnershipScope = Symbol('kOwnershipScope');\nconst kCurrentOwnershipScope = Symbol('kCurrentOwnershipScope');\nconst kDebugInfoProperties = Symbol('kDebugInfoProperties');\n\n/**\n *\n */\n// TODO(burdon): Document.\nexport class OwnershipScope {\n public instance: any;\n\n constructor(\n public constr: any,\n public parent?: OwnershipScope,\n ) {}\n\n getInfo() {\n if (!this.instance) {\n return {};\n }\n const props = this.constr.prototype[kDebugInfoProperties] ?? [];\n const info: any = {};\n for (const prop of props) {\n info[prop] = this.instance[prop];\n }\n return info;\n }\n\n [inspect.custom]() {\n return {\n className: this.constr.name,\n info: this.getInfo(),\n parent: this.parent,\n };\n }\n}\n\nfunction decorateMethodWeakReturnOwnership(prototype: any, key: string) {\n const original = prototype[key];\n prototype[key] = function (...args: any) {\n const res = original.apply(this, ...args);\n\n if (res && typeof res.then === 'function') {\n res.then((value: any) => {\n if (kOwnershipScope in value) {\n value[kOwnershipScope].parent ??= this[kOwnershipScope];\n }\n });\n } else {\n if (res && kOwnershipScope in res) {\n res[kOwnershipScope].parent ??= this[kOwnershipScope];\n }\n }\n\n return res;\n };\n}\n\nexport function ownershipClass<T extends { new (...args: any[]): {} }>(constr: T) {\n for (const key of Object.getOwnPropertyNames(constr.prototype)) {\n if (key !== 'constructor' && typeof constr.prototype[key] === 'function') {\n decorateMethodWeakReturnOwnership(constr.prototype, key);\n }\n }\n\n return class extends constr {\n constructor(...args: any[]) {\n const currentCausality = (globalThis as any)[kCurrentOwnershipScope];\n (globalThis as any)[kCurrentOwnershipScope] = new OwnershipScope(constr, currentCausality);\n super(...args);\n (this as any)[kOwnershipScope] = (globalThis as any)[kCurrentOwnershipScope];\n (this as any)[kOwnershipScope].instance = this;\n (globalThis as any)[kCurrentOwnershipScope] = currentCausality;\n }\n };\n}\n\nexport const debugInfo = (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {\n // console.log(target, propertyKey, descriptor);\n (target[kDebugInfoProperties] ??= []).push(propertyKey);\n};\n\nexport const getCurrentOwnershipScope = (thisRef: any) => thisRef;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,SAASA,MAAMC,YAAY;;;ACA3B,SAASC,eAAe;AAExB,OAAOC,WAAW;AAKlB,IAAIC,gBAAgB;AAEb,IAAMC,2BACX,CAACC,SACD,CAACC,MAAcC,MAAcC,SAC7B,CAACC,QAAaC,aAA8BC,eAAAA;AAC1C,QAAMC,SAASD,WAAWE;AAC1B,QAAMC,aAAaJ;AACnBC,aAAWE,QAAQ,YAAwBE,MAAS;AAClD,UAAMC,eAAe;MACnBC,GAAG;MACHC,GAAG;MACH,GAAIV,QAAQ,CAAC;MACbW,GAAG;IACL;AAEA,UAAMC,gBAAgBL,KAAKM,IAAI,CAACC,QAAaC,QAAQD,KAAK,OAAO,GAAG,IAAA,CAAA,EAAOE,KAAK,IAAA;AAEhF,QAAI;AACF,YAAMC,YAAYC,YAAYC,IAAG;AACjC,YAAMC,SAAShB,OAAOiB,MAAM,MAAMd,IAAAA;AAElC,UAAIe,WAAWF,MAAAA,GAAS;AACtB,cAAMG,KAAK5B;AACX6B,sBAAc3B,MAAKS,YAAYM,eAAeW,IAAIf,YAAAA;AAClDY,eAAOK,KACL,CAACC,kBAAAA;AACCC,2BAAiB9B,MAAKS,YAAYoB,eAAeH,IAAIN,WAAWT,YAAAA;QAClE,GACA,CAACoB,QAAAA;AACCC,2BAAiBhC,MAAKS,YAAYsB,KAAKL,IAAIN,WAAWT,YAAAA;QACxD,CAAA;MAEJ,OAAO;AACLsB,oBAAYjC,MAAKS,YAAYM,eAAeQ,QAAQZ,YAAAA;MACtD;AAEA,aA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B,QAAMC,QAAQD,SAASC,MAAM,wBAAA;AAC7B,MAAIA,OAAO;AACT,WAAOA,MAAM,CAAA;EACf;AACA,SAAOD;AACT;;;AC7GA,SAASE,WAAAA,gBAAe;AAIxB,IAAMC,uBAAuBC,uBAAO,sBAAA;AAM7B,IAAMC,iBAAN,MAAMA;;;EACJC;EAEP,YACSC,QACAC,QACP;SAFOD,SAAAA;SACAC,SAAAA;EACN;EAEHC,UAAU;AACR,QAAI,CAAC,KAAKH,UAAU;AAClB,aAAO,CAAC;IACV;AACA,UAAMI,QAAQ,KAAKH,OAAOI,UAAUR,oBAAAA,KAAyB,CAAA;AAC7D,UAAMS,OAAY,CAAC;AACnB,eAAWC,QAAQH,OAAO;AACxBE,WAAKC,IAAAA,IAAQ,KAAKP,SAASO,IAAAA;IAC7B;AACA,WAAOD;EACT;EAEA,CAACE,SAAQC,MAAM,IAAI;AACjB,WAAO;MACLC,WAAW,KAAKT,OAAOU;MACvBL,MAAM,KAAKH,QAAO;MAClBD,QAAQ,KAAKA;IACf;EACF;AACF;AA+CO,IAAMU,2BAA2B,CAACC,YAAiBA;",
6
+ "names": ["omit", "pick", "inspect", "chalk", "nextPromiseId", "createMethodLogDecorator", "log", "arg0", "arg1", "meta", "target", "propertyKey", "descriptor", "method", "value", "methodName", "args", "combinedMeta", "F", "L", "S", "formattedArgs", "map", "arg", "inspect", "join", "startTime", "performance", "now", "result", "apply", "isThenable", "id", "logAsyncBegin", "then", "resolvedValue", "logAsyncResolved", "err", "logAsyncRejected", "logSyncCall", "logSyncError", "Object", "defineProperty", "createFunctionLogDecorator", "name", "fn", "opts", "decoratedFn", "transformedResult", "transformOutput", "obj", "info", "formatFunction", "chalk", "gray", "error", "promiseId", "formatPromise", "undefined", "greenCheck", "formatTimeElapsed", "COLOR_FUNCTION", "green", "toFixed", "bold", "rgb", "blue", "defaultsDeep", "getDebugName", "safariCheck", "getRelativeFilename", "filename", "match", "filePath", "CONFIG", "useTestProcessor", "printFileLinks", "APP_BROWSER_PROCESSOR", "config", "entry", "shouldLog", "filters", "LOG_BROWSER_PREFIX", "prefix", "LOG_BROWSER_CSS", "link", "meta", "F", "filepath", "replace", "L", "args", "S", "scope", "scopeName", "name", "getDebugName", "processPrefix", "hostSessionId", "push", "message", "context", "getContextFromEntry", "Object", "keys", "length", "error", "err", "levels", "LogLevel", "ERROR", "console", "bind", "WARN", "warn", "DEBUG", "log", "safariCheck", "join", "level", "C", "TEST_BROWSER_PROCESSOR", "path", "BROWSER_PROCESSOR", "inspect", "DEBUG_PROCESSOR", "config", "entry", "console", "log", "inspect", "appendFileSync", "mkdirSync", "openSync", "dirname", "jsonlogify", "EAGAIN_MAX_DURATION", "createFileProcessor", "pathOrFd", "levels", "filters", "fd", "config", "entry", "length", "includes", "level", "shouldLog", "mkdirSync", "dirname", "openSync", "record", "timestamp", "Date", "now", "meta", "file", "getRelativeFilename", "F", "line", "L", "context", "jsonlogify", "getContextFromEntry", "retryTS", "appendFileSync", "JSON", "stringify", "err", "code", "performance", "console", "log", "logFilePath", "getLogFilePath", "process", "env", "LOG_FILE", "HOME", "toISOString", "undefined", "FILE_PROCESSOR", "LogLevel", "ERROR", "WARN", "INFO", "TRACE", "processors", "LogProcessorType", "CONSOLE", "CONSOLE_PROCESSOR", "BROWSER", "BROWSER_PROCESSOR", "DEBUG", "DEBUG_PROCESSOR", "browser", "window", "navigator", "process", "env", "VITEST", "DEFAULT_PROCESSORS", "parseLogLevel", "level", "defValue", "LogLevel", "WARN", "levels", "toLowerCase", "parseFilter", "filter", "lines", "split", "map", "pattern", "createConfig", "options", "envOptions", "globalThis", "file", "LOG_CONFIG", "LOG_FILTER", "processor", "LOG_PROCESSOR", "undefined", "mergedOptions", "defaultsDeep", "loadOptions", "filters", "INFO", "captureFilters", "captureFilter", "prefix", "logCount", "createLog", "log", "params", "processLog", "LogLevel", "DEBUG", "Object", "assign", "_id", "_config", "createConfig", "defineProperty", "get", "level", "message", "context", "meta", "error", "processors", "forEach", "processor", "config", "options", "addProcessor", "filter", "p", "length", "push", "trace", "TRACE", "debug", "verbose", "VERBOSE", "info", "INFO", "warn", "WARN", "ERROR", "catch", "undefined", "method", "createMethodLogDecorator", "function", "createFunctionLogDecorator", "break", "repeat", "stack", "getFormattedStackTrace", "globalThis", "DX_LOG", "start", "Date", "now", "last", "label", "args", "err", "Error", "console", "group", "JSON", "stringify", "t", "Number", "toLocaleString", "dt", "groupEnd", "split", "slice", "join", "dbg", "arg", "meta", "A", "console", "log", "CircularBuffer", "getDebugName", "DEFAULT_BUFFER_SIZE", "MAX_CONTEXT_LENGTH", "LogBuffer", "_buffer", "size", "CircularBuffer", "logProcessor", "_config", "entry", "level", "LogLevel", "TRACE", "record", "t", "Date", "toISOString", "l", "shortLevelName", "m", "message", "meta", "f", "getRelativeFilename", "F", "n", "L", "error", "e", "stack", "context", "ctx", "Error", "json", "JSON", "stringify", "length", "slice", "c", "scope", "S", "Object", "getPrototypeOf", "prototype", "o", "getDebugName", "push", "elementCount", "clear", "serialize", "lines", "join", "filename", "match", "inspect", "kDebugInfoProperties", "Symbol", "OwnershipScope", "instance", "constr", "parent", "getInfo", "props", "prototype", "info", "prop", "inspect", "custom", "className", "name", "getCurrentOwnershipScope", "thisRef"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"src/config.ts":{"bytes":4022,"imports":[],"format":"esm"},"src/scope.ts":{"bytes":4052,"imports":[],"format":"esm"},"src/context.ts":{"bytes":9183,"imports":[{"path":"src/scope.ts","kind":"import-statement","original":"./scope"}],"format":"esm"},"src/decorators.ts":{"bytes":19783,"imports":[{"path":"node:util","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true}],"format":"esm"},"src/platform/index.ts":{"bytes":454,"imports":[{"path":"#platform","kind":"import-statement","external":true}],"format":"esm"},"src/processors/browser-processor.ts":{"bytes":15856,"imports":[{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/config.ts","kind":"import-statement","original":"../config"},{"path":"src/context.ts","kind":"import-statement","original":"../context"}],"format":"esm"},"src/processors/common.ts":{"bytes":1609,"imports":[],"format":"esm"},"src/processors/debug-processor.ts":{"bytes":1057,"imports":[{"path":"node:util","kind":"import-statement","external":true}],"format":"esm"},"src/processors/file-processor.ts":{"bytes":10092,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/config.ts","kind":"import-statement","original":"../config"},{"path":"src/context.ts","kind":"import-statement","original":"../context"},{"path":"src/processors/common.ts","kind":"import-statement","original":"./common"}],"format":"esm"},"src/processors/index.ts":{"bytes":885,"imports":[{"path":"src/processors/browser-processor.ts","kind":"import-statement","original":"./browser-processor"},{"path":"src/processors/common.ts","kind":"import-statement","original":"./common"},{"path":"#console-processor","kind":"import-statement","external":true},{"path":"src/processors/debug-processor.ts","kind":"import-statement","original":"./debug-processor"},{"path":"src/processors/file-processor.ts","kind":"import-statement","original":"./file-processor"}],"format":"esm"},"src/options.ts":{"bytes":8101,"imports":[{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"src/config.ts","kind":"import-statement","original":"./config"},{"path":"src/platform/index.ts","kind":"import-statement","original":"./platform"},{"path":"src/processors/index.ts","kind":"import-statement","original":"./processors"}],"format":"esm"},"src/log.ts":{"bytes":14639,"imports":[{"path":"src/config.ts","kind":"import-statement","original":"./config"},{"path":"src/decorators.ts","kind":"import-statement","original":"./decorators"},{"path":"src/options.ts","kind":"import-statement","original":"./options"}],"format":"esm"},"src/experimental/ownership.ts":{"bytes":9249,"imports":[{"path":"node:util","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":1561,"imports":[{"path":"lodash.omit","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/config.ts","kind":"import-statement","original":"./config"},{"path":"src/context.ts","kind":"import-statement","original":"./context"},{"path":"src/log.ts","kind":"import-statement","original":"./log"},{"path":"src/options.ts","kind":"import-statement","original":"./options"},{"path":"src/processors/index.ts","kind":"import-statement","original":"./processors"},{"path":"src/scope.ts","kind":"import-statement","original":"./scope"},{"path":"src/experimental/ownership.ts","kind":"import-statement","original":"./experimental/ownership"}],"format":"esm"},"src/platform/browser/index.ts":{"bytes":2923,"imports":[],"format":"esm"},"src/platform/node/index.ts":{"bytes":2034,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"js-yaml","kind":"import-statement","external":true}],"format":"esm"},"src/processors/console-stub.ts":{"bytes":815,"imports":[],"format":"esm"},"src/processors/console-processor.ts":{"bytes":13229,"imports":[{"path":"node:util","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/config.ts","kind":"import-statement","original":"../config"},{"path":"src/context.ts","kind":"import-statement","original":"../context"},{"path":"src/processors/common.ts","kind":"import-statement","original":"./common"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":40324},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-QPYJZ4SO.mjs","kind":"import-statement"},{"path":"dist/lib/node-esm/chunk-2SZHAWBN.mjs","kind":"import-statement"},{"path":"lodash.omit","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"node:util","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true},{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"#platform","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"#console-processor","kind":"import-statement","external":true},{"path":"node:util","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"node:util","kind":"import-statement","external":true}],"exports":["BROWSER_PROCESSOR","DEBUG_PROCESSOR","FILE_PROCESSOR","LogLevel","LogProcessorType","createFileProcessor","createLog","debug","gatherLogInfoFromScope","getContextFromEntry","getCurrentOwnershipScope","getRelativeFilename","levels","log","logInfo","omit","parseFilter","pick","shortLevelName","shouldLog"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":897},"src/decorators.ts":{"bytesInOutput":4556},"src/options.ts":{"bytesInOutput":1672},"src/platform/index.ts":{"bytesInOutput":116},"src/processors/index.ts":{"bytesInOutput":409},"src/processors/browser-processor.ts":{"bytesInOutput":2975},"src/processors/debug-processor.ts":{"bytesInOutput":146},"src/processors/file-processor.ts":{"bytesInOutput":1812},"src/log.ts":{"bytesInOutput":2640},"src/experimental/ownership.ts":{"bytesInOutput":814}},"bytes":17100},"dist/lib/node-esm/platform/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1471},"dist/lib/node-esm/platform/browser/index.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-2SZHAWBN.mjs","kind":"import-statement"}],"exports":["loadOptions"],"entryPoint":"src/platform/browser/index.ts","inputs":{"src/platform/browser/index.ts":{"bytesInOutput":446}},"bytes":668},"dist/lib/node-esm/platform/node/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1057},"dist/lib/node-esm/platform/node/index.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-2SZHAWBN.mjs","kind":"import-statement"},{"path":"node:fs","kind":"import-statement","external":true},{"path":"js-yaml","kind":"import-statement","external":true}],"exports":["loadOptions"],"entryPoint":"src/platform/node/index.ts","inputs":{"src/platform/node/index.ts":{"bytesInOutput":315}},"bytes":534},"dist/lib/node-esm/processors/console-stub.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":375},"dist/lib/node-esm/processors/console-stub.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-2SZHAWBN.mjs","kind":"import-statement"}],"exports":["CONSOLE_PROCESSOR"],"entryPoint":"src/processors/console-stub.ts","inputs":{"src/processors/console-stub.ts":{"bytesInOutput":35}},"bytes":268},"dist/lib/node-esm/processors/console-processor.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":7039},"dist/lib/node-esm/processors/console-processor.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-QPYJZ4SO.mjs","kind":"import-statement"},{"path":"dist/lib/node-esm/chunk-2SZHAWBN.mjs","kind":"import-statement"},{"path":"node:util","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["CONSOLE_PROCESSOR","DEFAULT_FORMATTER","SHORT_FORMATTER","truncate"],"entryPoint":"src/processors/console-processor.ts","inputs":{"src/processors/console-processor.ts":{"bytesInOutput":2751}},"bytes":3175},"dist/lib/node-esm/chunk-QPYJZ4SO.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":9507},"dist/lib/node-esm/chunk-QPYJZ4SO.mjs":{"imports":[],"exports":["LogLevel","LogProcessorType","gatherLogInfoFromScope","getContextFromEntry","getRelativeFilename","levels","logInfo","shortLevelName","shouldLog"],"inputs":{"src/config.ts":{"bytesInOutput":809},"src/scope.ts":{"bytesInOutput":632},"src/context.ts":{"bytesInOutput":1579},"src/processors/common.ts":{"bytesInOutput":194}},"bytes":3601},"dist/lib/node-esm/chunk-2SZHAWBN.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/node-esm/chunk-2SZHAWBN.mjs":{"imports":[],"exports":["__export","__reExport"],"inputs":{},"bytes":1013}}}
1
+ {"inputs":{"src/config.ts":{"bytes":4022,"imports":[],"format":"esm"},"src/scope.ts":{"bytes":4052,"imports":[],"format":"esm"},"src/context.ts":{"bytes":9183,"imports":[{"path":"src/scope.ts","kind":"import-statement","original":"./scope"}],"format":"esm"},"src/decorators.ts":{"bytes":19783,"imports":[{"path":"node:util","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true}],"format":"esm"},"src/platform/index.ts":{"bytes":454,"imports":[{"path":"#platform","kind":"import-statement","external":true}],"format":"esm"},"src/processors/browser-processor.ts":{"bytes":15856,"imports":[{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/config.ts","kind":"import-statement","original":"../config"},{"path":"src/context.ts","kind":"import-statement","original":"../context"}],"format":"esm"},"src/processors/common.ts":{"bytes":1609,"imports":[],"format":"esm"},"src/processors/debug-processor.ts":{"bytes":1057,"imports":[{"path":"node:util","kind":"import-statement","external":true}],"format":"esm"},"src/processors/file-processor.ts":{"bytes":10092,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/config.ts","kind":"import-statement","original":"../config"},{"path":"src/context.ts","kind":"import-statement","original":"../context"},{"path":"src/processors/common.ts","kind":"import-statement","original":"./common"}],"format":"esm"},"src/processors/index.ts":{"bytes":885,"imports":[{"path":"src/processors/browser-processor.ts","kind":"import-statement","original":"./browser-processor"},{"path":"src/processors/common.ts","kind":"import-statement","original":"./common"},{"path":"#console-processor","kind":"import-statement","external":true},{"path":"src/processors/debug-processor.ts","kind":"import-statement","original":"./debug-processor"},{"path":"src/processors/file-processor.ts","kind":"import-statement","original":"./file-processor"}],"format":"esm"},"src/options.ts":{"bytes":8101,"imports":[{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"src/config.ts","kind":"import-statement","original":"./config"},{"path":"src/platform/index.ts","kind":"import-statement","original":"./platform"},{"path":"src/processors/index.ts","kind":"import-statement","original":"./processors"}],"format":"esm"},"src/log.ts":{"bytes":14824,"imports":[{"path":"src/config.ts","kind":"import-statement","original":"./config"},{"path":"src/decorators.ts","kind":"import-statement","original":"./decorators"},{"path":"src/options.ts","kind":"import-statement","original":"./options"}],"format":"esm"},"src/dbg.ts":{"bytes":2033,"imports":[],"format":"esm"},"src/log-buffer.ts":{"bytes":9754,"imports":[{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/config.ts","kind":"import-statement","original":"./config"}],"format":"esm"},"src/experimental/ownership.ts":{"bytes":9249,"imports":[{"path":"node:util","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":1686,"imports":[{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/config.ts","kind":"import-statement","original":"./config"},{"path":"src/context.ts","kind":"import-statement","original":"./context"},{"path":"src/log.ts","kind":"import-statement","original":"./log"},{"path":"src/options.ts","kind":"import-statement","original":"./options"},{"path":"src/processors/index.ts","kind":"import-statement","original":"./processors"},{"path":"src/scope.ts","kind":"import-statement","original":"./scope"},{"path":"src/dbg.ts","kind":"import-statement","original":"./dbg"},{"path":"src/log-buffer.ts","kind":"import-statement","original":"./log-buffer"},{"path":"src/experimental/ownership.ts","kind":"import-statement","original":"./experimental/ownership"}],"format":"esm"},"src/platform/browser/index.ts":{"bytes":2923,"imports":[],"format":"esm"},"src/platform/node/index.ts":{"bytes":2034,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"js-yaml","kind":"import-statement","external":true}],"format":"esm"},"src/processors/console-stub.ts":{"bytes":815,"imports":[],"format":"esm"},"src/processors/console-processor.ts":{"bytes":13229,"imports":[{"path":"node:util","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/config.ts","kind":"import-statement","original":"../config"},{"path":"src/context.ts","kind":"import-statement","original":"../context"},{"path":"src/processors/common.ts","kind":"import-statement","original":"./common"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":46342},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-62VKC2WQ.mjs","kind":"import-statement"},{"path":"dist/lib/node-esm/chunk-2SZHAWBN.mjs","kind":"import-statement"},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"node:util","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true},{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"#platform","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"#console-processor","kind":"import-statement","external":true},{"path":"node:util","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"node:util","kind":"import-statement","external":true}],"exports":["BROWSER_PROCESSOR","DEBUG_PROCESSOR","FILE_PROCESSOR","LogBuffer","LogLevel","LogProcessorType","createFileProcessor","createLog","dbg","debug","gatherLogInfoFromScope","getContextFromEntry","getCurrentOwnershipScope","getRelativeFilename","levels","log","logInfo","omit","parseFilter","pick","shortLevelName","shouldLog"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":919},"src/decorators.ts":{"bytesInOutput":4556},"src/options.ts":{"bytesInOutput":1672},"src/platform/index.ts":{"bytesInOutput":116},"src/processors/index.ts":{"bytesInOutput":409},"src/processors/browser-processor.ts":{"bytesInOutput":2975},"src/processors/debug-processor.ts":{"bytesInOutput":146},"src/processors/file-processor.ts":{"bytesInOutput":1812},"src/log.ts":{"bytesInOutput":2645},"src/dbg.ts":{"bytesInOutput":138},"src/log-buffer.ts":{"bytesInOutput":2027},"src/experimental/ownership.ts":{"bytesInOutput":718}},"bytes":19253},"dist/lib/node-esm/platform/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1471},"dist/lib/node-esm/platform/browser/index.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-2SZHAWBN.mjs","kind":"import-statement"}],"exports":["loadOptions"],"entryPoint":"src/platform/browser/index.ts","inputs":{"src/platform/browser/index.ts":{"bytesInOutput":446}},"bytes":668},"dist/lib/node-esm/platform/node/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1057},"dist/lib/node-esm/platform/node/index.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-2SZHAWBN.mjs","kind":"import-statement"},{"path":"node:fs","kind":"import-statement","external":true},{"path":"js-yaml","kind":"import-statement","external":true}],"exports":["loadOptions"],"entryPoint":"src/platform/node/index.ts","inputs":{"src/platform/node/index.ts":{"bytesInOutput":315}},"bytes":534},"dist/lib/node-esm/processors/console-stub.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":375},"dist/lib/node-esm/processors/console-stub.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-2SZHAWBN.mjs","kind":"import-statement"}],"exports":["CONSOLE_PROCESSOR"],"entryPoint":"src/processors/console-stub.ts","inputs":{"src/processors/console-stub.ts":{"bytesInOutput":35}},"bytes":268},"dist/lib/node-esm/processors/console-processor.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":7039},"dist/lib/node-esm/processors/console-processor.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-62VKC2WQ.mjs","kind":"import-statement"},{"path":"dist/lib/node-esm/chunk-2SZHAWBN.mjs","kind":"import-statement"},{"path":"node:util","kind":"import-statement","external":true},{"path":"chalk","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["CONSOLE_PROCESSOR","DEFAULT_FORMATTER","SHORT_FORMATTER","truncate"],"entryPoint":"src/processors/console-processor.ts","inputs":{"src/processors/console-processor.ts":{"bytesInOutput":2751}},"bytes":3175},"dist/lib/node-esm/chunk-62VKC2WQ.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":9508},"dist/lib/node-esm/chunk-62VKC2WQ.mjs":{"imports":[],"exports":["LogLevel","LogProcessorType","gatherLogInfoFromScope","getContextFromEntry","getRelativeFilename","levels","logInfo","shortLevelName","shouldLog"],"inputs":{"src/config.ts":{"bytesInOutput":809},"src/scope.ts":{"bytesInOutput":648},"src/context.ts":{"bytesInOutput":1579},"src/processors/common.ts":{"bytesInOutput":194}},"bytes":3617},"dist/lib/node-esm/chunk-2SZHAWBN.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/node-esm/chunk-2SZHAWBN.mjs":{"imports":[],"exports":["__export","__reExport"],"inputs":{},"bytes":1013}}}
@@ -5,7 +5,7 @@ import {
5
5
  getRelativeFilename,
6
6
  shortLevelName,
7
7
  shouldLog
8
- } from "../chunk-QPYJZ4SO.mjs";
8
+ } from "../chunk-62VKC2WQ.mjs";
9
9
  import "../chunk-2SZHAWBN.mjs";
10
10
 
11
11
  // src/processors/console-processor.ts
@@ -0,0 +1,23 @@
1
+ import { type CallMetadata } from './meta';
2
+ /**
3
+ * Debug-log value to console.
4
+ * Log's the expression being evaluated.
5
+ *
6
+ * If only one argument is provided, it will also be returned.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * dbg(foo, bar);
11
+ * // foo = 1
12
+ * // bar = 2
13
+ *
14
+ * bar = dbg(foo * 2);
15
+ * // foo * 2 = 2
16
+ * ```
17
+ *
18
+ * NOTE: The second argument is injected by the log transform plugin.
19
+ */
20
+ export declare const dbg: {
21
+ <T>(value: T, _meta?: CallMetadata): T;
22
+ };
23
+ //# sourceMappingURL=dbg.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dbg.d.ts","sourceRoot":"","sources":["../../../src/dbg.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC3C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,GAAG,EAAE;IAChB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC;CASxC,CAAC"}
@@ -1,5 +1,4 @@
1
- import omit from 'lodash.omit';
2
- import { pick } from '@dxos/util';
1
+ import { omit, pick } from '@dxos/util';
3
2
  export { omit, pick };
4
3
  export * from './config';
5
4
  export * from './context';
@@ -8,5 +7,7 @@ export { parseFilter } from './options';
8
7
  export * from './processors';
9
8
  export * from './scope';
10
9
  export type * from './meta';
10
+ export { dbg } from './dbg';
11
+ export * from './log-buffer';
11
12
  export { getCurrentOwnershipScope } from './experimental/ownership';
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,IAAI,MAAM,aAAa,CAAC;AAE/B,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAEtB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,mBAAmB,QAAQ,CAAC;AAE5B,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAEtB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,mBAAmB,QAAQ,CAAC;AAC5B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,cAAc,cAAc,CAAC;AAE7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { type LogProcessor } from './context';
2
+ /**
3
+ * Compact log record with short property names for small serialized size.
4
+ */
5
+ export type LogRecord = {
6
+ /** ISO timestamp. */
7
+ t: string;
8
+ /** Level letter (D, V, I, W, E). */
9
+ l: string;
10
+ /** Message. */
11
+ m: string;
12
+ /** File path. */
13
+ f?: string;
14
+ /** Line number. */
15
+ n?: number;
16
+ o?: string;
17
+ /** Error stack. */
18
+ e?: string;
19
+ /** Context JSON. */
20
+ c?: string;
21
+ };
22
+ /**
23
+ * Captures recent log entries in a circular buffer for debug log dump.
24
+ */
25
+ export declare class LogBuffer {
26
+ private readonly _buffer;
27
+ constructor(size?: number);
28
+ /** Log processor that can be registered with `log.runtimeConfig.processors`. */
29
+ readonly logProcessor: LogProcessor;
30
+ /** Number of entries currently in the buffer. */
31
+ get size(): number;
32
+ /** Discard all buffered entries. */
33
+ clear(): void;
34
+ /** Serialize buffer contents as NDJSON (newline-delimited JSON). */
35
+ serialize(): string;
36
+ }
37
+ //# sourceMappingURL=log-buffer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-buffer.d.ts","sourceRoot":"","sources":["../../../src/log-buffer.ts"],"names":[],"mappings":"AAOA,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAK7D;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,qBAAqB;IACrB,CAAC,EAAE,MAAM,CAAC;IACV,oCAAoC;IACpC,CAAC,EAAE,MAAM,CAAC;IACV,eAAe;IACf,CAAC,EAAE,MAAM,CAAC;IACV,iBAAiB;IACjB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,mBAAmB;IACnB,CAAC,CAAC,EAAE,MAAM,CAAC;IAEX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,mBAAmB;IACnB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,oBAAoB;IACpB,CAAC,CAAC,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA4B;gBAExC,IAAI,SAAsB;IAItC,gFAAgF;IAChF,QAAQ,CAAC,YAAY,EAAE,YAAY,CAwCjC;IAEF,iDAAiD;IACjD,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,oCAAoC;IACpC,KAAK,IAAI,IAAI;IAIb,oEAAoE;IACpE,SAAS,IAAI,MAAM;CAOpB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=log-buffer.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-buffer.test.d.ts","sourceRoot":"","sources":["../../../src/log-buffer.test.ts"],"names":[],"mappings":""}
@@ -3,6 +3,8 @@ import { type LogContext, type LogProcessor } from './context';
3
3
  import { type CallMetadata } from './meta';
4
4
  /**
5
5
  * Accessible from browser console.
6
+ * Example: `DX_LOG.config({ filter: 'ERROR' })`
7
+ * NOTE: File level filtering isn't supported in storybooks.
6
8
  */
7
9
  declare global {
8
10
  const DX_LOG: Log;
@@ -15,7 +17,7 @@ type LogFunction = (message: string, context?: LogContext, meta?: CallMetadata)
15
17
  * Logging methods.
16
18
  */
17
19
  export interface LogMethods {
18
- config: (options: LogOptions) => Log;
20
+ config: (options?: LogOptions) => Log;
19
21
  addProcessor: (processor: LogProcessor, addDefault?: boolean) => () => void;
20
22
  trace: LogFunction;
21
23
  debug: LogFunction;
@@ -1 +1 @@
1
- {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../src/log.ts"],"names":[],"mappings":"AAIA,OAAO,EAA4B,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAE/D,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,QAAQ,CAAC;AAG3C;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IACb,MAAM,MAAM,EAAE,GAAG,CAAC;CACnB;AAED;;GAEG;AACH,KAAK,WAAW,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;AAExF;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,GAAG,CAAC;IACrC,YAAY,EAAE,CAAC,SAAS,EAAE,YAAY,EAAE,UAAU,CAAC,EAAE,OAAO,KAAK,MA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