@dxos/log 0.1.56-main.f3d4052 → 0.1.56-next.a63ce79

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.
@@ -31,17 +31,15 @@ var LogProcessorType;
31
31
  // packages/common/log/src/scope.ts
32
32
  var logInfoProperties = Symbol("logInfoProperties");
33
33
  var logInfo = (target, propertyKey, descriptor) => {
34
- var _a2;
35
- ((_a2 = target[logInfoProperties]) != null ? _a2 : target[logInfoProperties] = []).push(propertyKey);
34
+ (target[logInfoProperties] ??= []).push(propertyKey);
36
35
  };
37
36
  var gatherLogInfoFromScope = (scope) => {
38
- var _a2;
39
37
  if (!scope) {
40
38
  return {};
41
39
  }
42
40
  const res = {};
43
41
  const prototype = Object.getPrototypeOf(scope);
44
- const infoProps = (_a2 = prototype[logInfoProperties]) != null ? _a2 : [];
42
+ const infoProps = prototype[logInfoProperties] ?? [];
45
43
  for (const prop of infoProps) {
46
44
  try {
47
45
  res[prop] = typeof scope[prop] === "function" ? scope[prop]() : scope[prop];
@@ -60,10 +58,7 @@ var shouldLog = (entry, filters) => {
60
58
  if (filters === void 0) {
61
59
  return true;
62
60
  } else {
63
- return filters.some((filter) => {
64
- var _a2, _b;
65
- return matchFilter(filter, entry.level, (_b = (_a2 = entry.meta) == null ? void 0 : _a2.F) != null ? _b : "");
66
- });
61
+ return filters.some((filter) => matchFilter(filter, entry.level, entry.meta?.F ?? ""));
67
62
  }
68
63
  };
69
64
  var getContextFromEntry = (entry) => {
@@ -71,18 +66,18 @@ var getContextFromEntry = (entry) => {
71
66
  if (entry.meta) {
72
67
  const scopeInfo = gatherLogInfoFromScope(entry.meta.S);
73
68
  if (Object.keys(scopeInfo).length > 0) {
74
- context = Object.assign(context != null ? context : {}, scopeInfo);
69
+ context = Object.assign(context ?? {}, scopeInfo);
75
70
  }
76
71
  }
77
72
  if (entry.context) {
78
73
  if (entry.context instanceof Error) {
79
74
  const c = entry.context.context;
80
- context = Object.assign(context != null ? context : {}, {
75
+ context = Object.assign(context ?? {}, {
81
76
  error: entry.context.stack,
82
77
  ...c
83
78
  });
84
79
  } else if (typeof entry.context === "object") {
85
- context = Object.assign(context != null ? context : {}, entry.context);
80
+ context = Object.assign(context ?? {}, entry.context);
86
81
  }
87
82
  }
88
83
  return context && Object.keys(context).length > 0 ? context : void 0;
@@ -127,11 +122,10 @@ var CONFIG = typeof mochaExecutor !== "undefined" ? {
127
122
  printFileLinks: false
128
123
  };
129
124
  var APP_BROWSER_PROCESSOR = (config, entry) => {
130
- var _a2, _b, _c;
131
125
  if (!shouldLog(entry, config.filters)) {
132
126
  return;
133
127
  }
134
- const LOG_BROWSER_PREFIX = (_a2 = config.prefix) != null ? _a2 : "https://vscode.dev/github.com/dxos/dxos/blob/main/";
128
+ const LOG_BROWSER_PREFIX = config.prefix ?? "https://vscode.dev/github.com/dxos/dxos/blob/main/";
135
129
  const LOG_BROWSER_CSS = [];
136
130
  let link = "";
137
131
  if (entry.meta) {
@@ -151,7 +145,7 @@ var APP_BROWSER_PROCESSOR = (config, entry) => {
151
145
  [LogLevel.DEBUG]: console.log
152
146
  };
153
147
  if (CONFIG.printFileLinks) {
154
- if (LOG_BROWSER_CSS == null ? void 0 : LOG_BROWSER_CSS.length) {
148
+ if (LOG_BROWSER_CSS?.length) {
155
149
  args = [
156
150
  `%c${link}
157
151
  %c${args.join(" ")}`,
@@ -164,15 +158,14 @@ var APP_BROWSER_PROCESSOR = (config, entry) => {
164
158
  ];
165
159
  }
166
160
  }
167
- const level = (_b = levels2[entry.level]) != null ? _b : console.log;
168
- if (typeof ((_c = entry.meta) == null ? void 0 : _c.C) === "function") {
161
+ const level = levels2[entry.level] ?? console.log;
162
+ if (typeof entry.meta?.C === "function") {
169
163
  entry.meta.C(level, args);
170
164
  } else {
171
165
  level(...args);
172
166
  }
173
167
  };
174
168
  var TEST_BROWSER_PROCESSOR = (config, entry) => {
175
- var _a2, _b;
176
169
  if (!shouldLog(entry, config.filters)) {
177
170
  return;
178
171
  }
@@ -197,8 +190,8 @@ var TEST_BROWSER_PROCESSOR = (config, entry) => {
197
190
  ...args
198
191
  ];
199
192
  }
200
- const level = (_a2 = levels2[entry.level]) != null ? _a2 : console.log;
201
- if (typeof ((_b = entry.meta) == null ? void 0 : _b.C) === "function") {
193
+ const level = levels2[entry.level] ?? console.log;
194
+ if (typeof entry.meta?.C === "function") {
202
195
  entry.meta.C(level, args);
203
196
  } else {
204
197
  level(...args);
@@ -213,14 +206,13 @@ import { jsonify } from "@dxos/util";
213
206
  var createFileProcessor = ({ path, levels: levels2 }) => {
214
207
  let fd;
215
208
  return (config, entry) => {
216
- var _a2, _b;
217
209
  if (!levels2.includes(entry.level)) {
218
210
  return;
219
211
  }
220
212
  if (!fd) {
221
213
  try {
222
214
  mkdirSync(dirname(path));
223
- } catch (e) {
215
+ } catch {
224
216
  }
225
217
  fd = openSync(path, "w");
226
218
  }
@@ -228,8 +220,8 @@ var createFileProcessor = ({ path, levels: levels2 }) => {
228
220
  ...entry,
229
221
  timestamp: Date.now(),
230
222
  meta: {
231
- file: (_a2 = entry.meta) == null ? void 0 : _a2.F,
232
- line: (_b = entry.meta) == null ? void 0 : _b.L
223
+ file: entry.meta?.F,
224
+ line: entry.meta?.L
233
225
  },
234
226
  context: jsonify(getContextFromEntry(entry))
235
227
  };
@@ -238,8 +230,7 @@ var createFileProcessor = ({ path, levels: levels2 }) => {
238
230
  };
239
231
  var logFilePath;
240
232
  var getLogFilePath = () => {
241
- var _a2;
242
- logFilePath != null ? logFilePath : logFilePath = (_a2 = process.env.LOG_FILE) != null ? _a2 : process.env.HOME ? `${process.env.HOME}/.dxlog/${new Date().toISOString()}.log` : void 0;
233
+ logFilePath ??= process.env.LOG_FILE ?? (process.env.HOME ? `${process.env.HOME}/.dxlog/${(/* @__PURE__ */ new Date()).toISOString()}.log` : void 0);
243
234
  return logFilePath;
244
235
  };
245
236
  var FILE_PROCESSOR = createFileProcessor({
@@ -270,10 +261,7 @@ var parseFilter = (filter) => {
270
261
  }
271
262
  ];
272
263
  }
273
- const parseLogLevel = (level, defValue = LogLevel.WARN) => {
274
- var _a2;
275
- return (_a2 = levels[level.toLowerCase()]) != null ? _a2 : defValue;
276
- };
264
+ const parseLogLevel = (level, defValue = LogLevel.WARN) => levels[level.toLowerCase()] ?? defValue;
277
265
  const lines = typeof filter === "string" ? filter.split(/,\s*/) : filter;
278
266
  return lines.map((filter2) => {
279
267
  const [pattern, level] = filter2.split(":");
@@ -286,17 +274,16 @@ var parseFilter = (filter) => {
286
274
  });
287
275
  };
288
276
  var getConfig = (_options) => {
289
- var _a2, _b, _c, _d;
290
277
  let options = defaultsDeep({}, _options, "process" in globalThis && {
291
278
  // TODO(burdon): Node only.
292
- file: (_a2 = process.env) == null ? void 0 : _a2.LOG_CONFIG,
293
- filter: (_b = process.env) == null ? void 0 : _b.LOG_FILTER,
294
- processor: (_c = process.env) == null ? void 0 : _c.LOG_PROCESSOR
279
+ file: process.env?.LOG_CONFIG,
280
+ filter: process.env?.LOG_FILTER,
281
+ processor: process.env?.LOG_PROCESSOR
295
282
  });
296
283
  options = defaultsDeep({}, loadOptions(options.file), options);
297
284
  return {
298
285
  options,
299
- filters: parseFilter((_d = options.filter) != null ? _d : LogLevel.INFO),
286
+ filters: parseFilter(options.filter ?? LogLevel.INFO),
300
287
  processors: options.processor ? [
301
288
  processors[options.processor]
302
289
  ] : DEFAULT_PROCESSORS,
@@ -340,32 +327,7 @@ var createLog = () => {
340
327
  };
341
328
  return log2;
342
329
  };
343
- var _a;
344
- var log = (_a = globalThis.dx_log) != null ? _a : globalThis.dx_log = createLog();
345
-
346
- // packages/common/log/src/invariant.ts
347
- var invariant = (condition, message, meta) => {
348
- if (condition) {
349
- return;
350
- }
351
- let errorMessage = "invariant violation";
352
- if (message) {
353
- errorMessage += `: ${message}`;
354
- }
355
- if (meta == null ? void 0 : meta.A) {
356
- errorMessage += ` [${meta.A[0]}]`;
357
- }
358
- if (meta == null ? void 0 : meta.F) {
359
- errorMessage += ` at ${meta.F}:${meta.L}`;
360
- }
361
- throw new InvariantViolation(errorMessage);
362
- };
363
- var InvariantViolation = class extends Error {
364
- constructor(message) {
365
- super(message);
366
- Object.setPrototypeOf(this, new.target.prototype);
367
- }
368
- };
330
+ var log = globalThis.dx_log ??= createLog();
369
331
 
370
332
  // packages/common/log/src/experimental/ownership.ts
371
333
  import { inspect as inspect2 } from "@dxos/node-std/util";
@@ -378,11 +340,10 @@ var OwnershipScope = class {
378
340
  this.parent = parent;
379
341
  }
380
342
  getInfo() {
381
- var _a2;
382
343
  if (!this.instance) {
383
344
  return {};
384
345
  }
385
- const props = (_a2 = this.constr.prototype[kDebugInfoProperties]) != null ? _a2 : [];
346
+ const props = this.constr.prototype[kDebugInfoProperties] ?? [];
386
347
  const info = {};
387
348
  for (const prop of props) {
388
349
  info[prop] = this.instance[prop];
@@ -403,14 +364,12 @@ export {
403
364
  CONSOLE_PROCESSOR,
404
365
  DEBUG_PROCESSOR,
405
366
  FILE_PROCESSOR,
406
- InvariantViolation,
407
367
  LogLevel,
408
368
  LogProcessorType,
409
369
  createFileProcessor,
410
370
  gatherLogInfoFromScope,
411
371
  getContextFromEntry,
412
372
  getCurrentOwnershipScope,
413
- invariant,
414
373
  levels,
415
374
  log,
416
375
  logInfo,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/config.ts", "../../../src/scope.ts", "../../../src/context.ts", "../../../src/options.ts", "../../../src/platform/browser/index.ts", "../../../src/processors/console-stub.ts", "../../../src/processors/debug-processor.ts", "../../../src/processors/browser-processor.ts", "../../../src/processors/file-processor.ts", "../../../src/log.ts", "../../../src/invariant.ts", "../../../src/experimental/ownership.ts"],
4
- "sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { LogProcessor } from './context';\n\n/**\n * Standard levels.\n */\n// NOTE: Keep aligned with LogLevel in @dxos/protocols.\nexport enum LogLevel {\n TRACE = 5,\n DEBUG = 10,\n INFO = 11,\n WARN = 12,\n ERROR = 13,\n}\n\nexport const levels: { [index: string]: LogLevel } = {\n trace: LogLevel.TRACE,\n debug: LogLevel.DEBUG,\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.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 depth?: number; // Context object depth.\n processor?: string | LogProcessorType;\n formatter?: {\n column: number;\n };\n prefix?: string;\n};\n\n/**\n * Runtime config.\n */\nexport interface LogConfig {\n options: LogOptions;\n filters?: LogFilter[];\n processors: LogProcessor[];\n prefix?: string;\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 = 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 { LogConfig, LogFilter, LogLevel } from './config';\nimport { CallMetadata } from './meta';\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 * Record for current log line.\n */\nexport interface LogEntry {\n level: LogLevel;\n message: string;\n context?: LogContext;\n meta?: CallMetadata;\n error?: Error;\n}\n\n/**\n * Processes (e.g., prints, forwards) log entries.\n */\nexport type LogProcessor = (config: LogConfig, entry: LogEntry) => void;\n\nconst matchFilter = (filter: LogFilter, level: LogLevel, path: string) => {\n return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));\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 true;\n } else {\n return filters.some((filter) => matchFilter(filter, entry.level, entry.meta?.F ?? ''));\n }\n};\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 if (entry.context) {\n if (entry.context instanceof Error) {\n // Additional context from Error.\n const c = (entry.context as any).context;\n // If ERROR then show stacktrace.\n context = Object.assign(context ?? {}, { error: entry.context.stack, ...c });\n } else if (typeof entry.context === 'object') {\n context = Object.assign(context ?? {}, entry.context);\n }\n }\n\n return context && Object.keys(context).length > 0 ? context : undefined;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport defaultsDeep from 'lodash.defaultsdeep';\n\nimport { LogConfig, LogFilter, LogLevel, LogOptions, LogProcessorType, levels } from './config';\nimport { LogProcessor } from './context';\nimport { loadOptions } from './platform';\nimport { CONSOLE_PROCESSOR, DEBUG_PROCESSOR, BROWSER_PROCESSOR } from './processors';\n\n/**\n * Processor variants.\n */\nexport const processors: { [index: string]: LogProcessor } = {\n [LogProcessorType.CONSOLE]: CONSOLE_PROCESSOR,\n [LogProcessorType.BROWSER]: BROWSER_PROCESSOR,\n [LogProcessorType.DEBUG]: DEBUG_PROCESSOR,\n};\n\nconst IS_BROWSER = typeof window !== 'undefined' || typeof navigator !== 'undefined';\n\nexport const DEFAULT_PROCESSORS = [IS_BROWSER ? BROWSER_PROCESSOR : CONSOLE_PROCESSOR];\n\nexport const parseFilter = (filter: string | string[] | LogLevel): LogFilter[] => {\n if (typeof filter === 'number') {\n return [{ level: filter }];\n }\n\n const parseLogLevel = (level: string, defValue = LogLevel.WARN) => levels[level.toLowerCase()] ?? defValue;\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 ? { level: parseLogLevel(level), pattern } : { level: parseLogLevel(pattern) };\n });\n};\n\nexport const getConfig = (_options?: LogOptions): LogConfig => {\n let options: LogOptions = defaultsDeep(\n {},\n _options,\n 'process' in globalThis && {\n // TODO(burdon): Node only.\n file: process!.env?.LOG_CONFIG,\n filter: process!.env?.LOG_FILTER,\n processor: process!.env?.LOG_PROCESSOR,\n },\n );\n\n // TODO(burdon): Verbose option.\n // console.log(JSON.stringify(options, undefined, 2));\n options = defaultsDeep({}, loadOptions(options.file), options);\n return {\n options,\n filters: parseFilter(options.filter ?? LogLevel.INFO),\n processors: options.processor ? [processors[options.processor]] : DEFAULT_PROCESSORS,\n prefix: options.prefix,\n };\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { LogOptions } from '../../config';\n\n// NOTE: Implementation for the browser. See `package.json`.\nexport const loadOptions = (filepath?: string): LogOptions | undefined => {\n try {\n return JSON.parse(localStorage.getItem('dxlog')!);\n } catch (err) {\n return undefined;\n }\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(wittjosiah): Consider mapping console processor directly to browser processor in the browser.\nexport const CONSOLE_PROCESSOR = () => {};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { inspect } from 'node:util';\n\nimport { LogProcessor } from '../context';\n\nexport const DEBUG_PROCESSOR: LogProcessor = (config, entry) => {\n console.log(inspect(entry, false, null, true));\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { LogLevel } from '../config';\nimport { getContextFromEntry, LogProcessor, 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 typeof mochaExecutor !== 'undefined'\n ? {\n useTestProcessor: true,\n printFileLinks: true,\n }\n : {\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 args.push(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 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 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\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 args.push(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 2023 DXOS.org\n//\n\nimport { appendFileSync, mkdirSync, openSync } from 'node:fs';\nimport { dirname } from 'node:path';\n\nimport { jsonify } from '@dxos/util';\n\nimport { LogLevel } from '../config';\nimport { LogProcessor, getContextFromEntry } from '../context';\n\nexport const createFileProcessor = ({ path, levels }: { path: string; levels: LogLevel[] }): LogProcessor => {\n let fd: number | undefined;\n\n return (config, entry) => {\n if (!levels.includes(entry.level)) {\n return;\n }\n if (!fd) {\n try {\n mkdirSync(dirname(path));\n } catch {}\n fd = openSync(path, 'w');\n }\n\n const record = {\n ...entry,\n timestamp: Date.now(),\n meta: {\n file: entry.meta?.F,\n line: entry.meta?.L,\n },\n context: jsonify(getContextFromEntry(entry)),\n };\n appendFileSync(fd, JSON.stringify(record) + '\\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 path: getLogFilePath(),\n levels: [LogLevel.ERROR, LogLevel.WARN, LogLevel.INFO, LogLevel.TRACE],\n});\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { LogConfig, LogLevel, LogOptions } from './config';\nimport { LogContext, LogProcessor } from './context';\nimport { CallMetadata } from './meta';\nimport { getConfig, DEFAULT_PROCESSORS } from './options';\n\n/**\n * Logging function.\n */\ntype LogFunction = (message: string, context?: LogContext, meta?: CallMetadata) => void;\n\n/**\n * Logging methods.\n */\ninterface LogMethods {\n trace: LogFunction;\n debug: LogFunction;\n info: LogFunction;\n warn: LogFunction;\n error: LogFunction;\n catch: (error: Error | any, context?: LogContext, meta?: CallMetadata) => void;\n break: () => void;\n}\n\n/**\n * Properties accessible on the logging function.\n */\ninterface Log extends LogMethods, LogFunction {\n config: (options: LogOptions) => void;\n addProcessor: (processor: LogProcessor) => void;\n runtimeConfig: LogConfig;\n}\n\ninterface LogImp extends Log {\n _config: LogConfig;\n}\n\nconst createLog = (): LogImp => {\n const log: LogImp = ((...params) => processLog(LogLevel.DEBUG, ...params)) as LogImp;\n\n log._config = getConfig();\n Object.defineProperty(log, 'runtimeConfig', { get: () => log._config });\n\n log.addProcessor = (processor: LogProcessor) => {\n if (DEFAULT_PROCESSORS.filter((p) => p === processor).length === 0) {\n DEFAULT_PROCESSORS.push(processor);\n }\n if (log._config.processors.filter((p) => p === processor).length === 0) {\n log._config.processors.push(processor);\n }\n };\n\n // Set config.\n log.config = (options: LogOptions) => {\n log._config = getConfig(options);\n };\n\n // TODO(burdon): API to set context and separate error object.\n // E.g., log.warn('failed', { key: 123 }, err);\n\n log.trace = (...params) => processLog(LogLevel.TRACE, ...params);\n log.debug = (...params) => processLog(LogLevel.DEBUG, ...params);\n log.info = (...params) => processLog(LogLevel.INFO, ...params);\n log.warn = (...params) => processLog(LogLevel.WARN, ...params);\n log.error = (...params) => processLog(LogLevel.ERROR, ...params);\n\n // Catch only shows error message, not stacktrace.\n log.catch = (error: Error | any, context, meta) => processLog(LogLevel.ERROR, error.stack, context, meta);\n\n // Show break.\n log.break = () => log.info('——————————————————————————————————————————————————');\n\n /**\n * Process the current log call.\n */\n const processLog = (\n level: LogLevel,\n message: string,\n context: LogContext = {},\n meta?: CallMetadata,\n error?: Error,\n ) => {\n log._config.processors.forEach((processor) => processor(log._config, { level, message, context, meta, error }));\n };\n\n return log;\n};\n\n/**\n * Global logging function.\n */\nexport const log: Log = ((globalThis as any).dx_log ??= createLog());\n\n/**\n * Accessible from browser console.\n */\ndeclare global {\n // eslint-disable-next-line camelcase\n const dx_log: Log;\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { CallMetadata } from './meta';\n\nexport type InvariantFn = (condition: unknown, message?: string, meta?: CallMetadata) => asserts condition;\n\n/**\n * Asserts that the condition is true.\n *\n * @param message Optional message.\n */\nexport const invariant: InvariantFn = (\n condition: unknown,\n message?: string,\n meta?: CallMetadata,\n): asserts condition => {\n if (condition) {\n return;\n }\n\n let errorMessage = 'invariant violation';\n\n if (message) {\n errorMessage += `: ${message}`;\n }\n\n if (meta?.A) {\n errorMessage += ` [${meta.A[0]}]`;\n }\n\n if (meta?.F) {\n errorMessage += ` at ${meta.F}:${meta.L}`;\n }\n\n throw new InvariantViolation(errorMessage);\n};\n\nexport class InvariantViolation extends Error {\n constructor(message: string) {\n super(message);\n // NOTE: Restores prototype chain (https://stackoverflow.com/a/48342359).\n Object.setPrototypeOf(this, new.target.prototype);\n }\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(public constr: any, public parent?: OwnershipScope) {}\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": ";IAUO;UAAKA,WAAQ;AAARA,EAAAA,UAAAA,UACVC,OAAAA,IAAQ,CAAA,IAARA;AADUD,EAAAA,UAAAA,UAEVE,OAAAA,IAAQ,EAAA,IAARA;AAFUF,EAAAA,UAAAA,UAGVG,MAAAA,IAAO,EAAA,IAAPA;AAHUH,EAAAA,UAAAA,UAIVI,MAAAA,IAAO,EAAA,IAAPA;AAJUJ,EAAAA,UAAAA,UAKVK,OAAAA,IAAQ,EAAA,IAARA;GALUL,aAAAA,WAAAA,CAAAA,EAAAA;AAQL,IAAMM,SAAwC;EACnDC,OAAOP,SAASC;EAChBO,OAAOR,SAASE;EAChBO,MAAMT,SAASG;EACfO,MAAMV,SAASI;EACfO,OAAOX,SAASK;AAClB;AAEO,IAAMO,iBAAiB;EAC5B,CAACZ,SAASC,KAAK,GAAG;EAClB,CAACD,SAASE,KAAK,GAAG;EAClB,CAACF,SAASG,IAAI,GAAG;EACjB,CAACH,SAASI,IAAI,GAAG;EACjB,CAACJ,SAASK,KAAK,GAAG;AACpB;IAEO;UAAKQ,mBAAgB;AAAhBA,EAAAA,kBACVC,SAAAA,IAAU;AADAD,EAAAA,kBAEVE,SAAAA,IAAU;AAFAF,EAAAA,kBAGVX,OAAAA,IAAQ;GAHEW,qBAAAA,mBAAAA,CAAAA,EAAAA;;;AC9BZ,IAAMG,oBAAoBC,OAAO,mBAAA;AAc1B,IAAMC,UAAU,CAACC,QAAaC,aAAqBC,eAAAA;AAlB1D,MAAAC;AAoBGH,IAAAA,MAAAA,qCAAAA,MAAAA,4BAA8B,CAAA,GAAII,KAAKH,WAAAA;AAC1C;AAMO,IAAMI,yBAAyB,CAACC,UAAAA;AA3BvC,MAAAH;AA4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AAmBC,QAAoBC,QAAyB;kBAA7CD;kBAAoBC;EAA0B;EAEjEC,UAAU;AAnBZ,QAAAC;AAoBI,QAAI,CAAC,KAAKC,UAAU;AAClB,aAAO,CAAC;IACV;AACA,UAAMC,SAAQF,MAAA,KAAKH,OAAOM,UAAUT,oBAAAA,MAAtB,OAAAM,MAA+C,CAAA;AAC7D,UAAMI,OAAY,CAAC;AACnB,eAAWC,QAAQH,OAAO;AACxBE,WAAKC,IAAAA,IAAQ,KAAKJ,SAASI,IAAAA;IAC7B;AACA,WAAOD;EACT;EAEA,CAACE,SAAQC,MAAM,IAAI;AACjB,WAAO;MACLC,WAAW,KAAKX,OAAOY;MACvBL,MAAM,KAAKL,QAAO;MAClBD,QAAQ,KAAKA;IACf;EACF;AACF;AA+CO,IAAMY,2BAA2B,CAACC,YAAiBA;",
6
- "names": ["LogLevel", "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "levels", "trace", "debug", "info", "warn", "error", "shortLevelName", "LogProcessorType", "CONSOLE", "BROWSER", "logInfoProperties", "Symbol", "logInfo", "target", "propertyKey", "descriptor", "_a", "push", "gatherLogInfoFromScope", "scope", "res", "prototype", "Object", "getPrototypeOf", "infoProps", "prop", "err", "message", "matchFilter", "filter", "level", "path", "pattern", "includes", "shouldLog", "entry", "filters", "undefined", "some", "_a", "meta", "F", "getContextFromEntry", "context", "scopeInfo", "gatherLogInfoFromScope", "S", "Object", "keys", "length", "assign", "Error", "c", "error", "stack", "defaultsDeep", "loadOptions", "filepath", "JSON", "parse", "localStorage", "getItem", "err", "undefined", "CONSOLE_PROCESSOR", "inspect", "DEBUG_PROCESSOR", "config", "entry", "console", "log", "inspect", "getRelativeFilename", "filename", "match", "filePath", "CONFIG", "mochaExecutor", "useTestProcessor", "printFileLinks", "APP_BROWSER_PROCESSOR", "config", "entry", "_a", "shouldLog", "filters", "LOG_BROWSER_PREFIX", "prefix", "LOG_BROWSER_CSS", "link", "meta", "F", "filepath", "replace", "L", "args", "push", "message", "context", "getContextFromEntry", "levels", "LogLevel", "ERROR", "console", "error", "WARN", "warn", "DEBUG", "log", "length", "join", "level", "C", "TEST_BROWSER_PROCESSOR", "path", "BROWSER_PROCESSOR", "appendFileSync", "mkdirSync", "openSync", "dirname", "jsonify", "createFileProcessor", "path", "levels", "fd", "config", "entry", "_a", "includes", "level", "mkdirSync", "dirname", "openSync", "record", "timestamp", "Date", "now", "meta", "file", "F", "line", "L", "context", "jsonify", "getContextFromEntry", "appendFileSync", "JSON", "stringify", "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", "IS_BROWSER", "window", "navigator", "DEFAULT_PROCESSORS", "parseFilter", "filter", "level", "parseLogLevel", "defValue", "LogLevel", "WARN", "_a", "levels", "toLowerCase", "lines", "split", "map", "pattern", "getConfig", "_options", "options", "defaultsDeep", "globalThis", "file", "process", "env", "LOG_CONFIG", "LOG_FILTER", "processor", "LOG_PROCESSOR", "loadOptions", "filters", "INFO", "prefix", "createLog", "log", "params", "processLog", "LogLevel", "DEBUG", "_config", "getConfig", "Object", "defineProperty", "get", "addProcessor", "processor", "DEFAULT_PROCESSORS", "filter", "p", "length", "push", "processors", "config", "options", "trace", "TRACE", "debug", "info", "INFO", "warn", "WARN", "error", "ERROR", "catch", "context", "meta", "stack", "break", "level", "message", "forEach", "globalThis", "dx_log", "invariant", "condition", "message", "meta", "errorMessage", "A", "F", "L", "InvariantViolation", "Error", "constructor", "Object", "setPrototypeOf", "prototype", "inspect", "kOwnershipScope", "Symbol", "kCurrentOwnershipScope", "kDebugInfoProperties", "OwnershipScope", "constructor", "constr", "parent", "getInfo", "_a", "instance", "props", "prototype", "info", "prop", "inspect", "custom", "className", "name", "getCurrentOwnershipScope", "thisRef"]
3
+ "sources": ["../../../src/config.ts", "../../../src/scope.ts", "../../../src/context.ts", "../../../src/options.ts", "../../../src/platform/browser/index.ts", "../../../src/processors/console-stub.ts", "../../../src/processors/debug-processor.ts", "../../../src/processors/browser-processor.ts", "../../../src/processors/file-processor.ts", "../../../src/log.ts", "../../../src/experimental/ownership.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { LogProcessor } from './context';\n\n/**\n * Standard levels.\n */\n// NOTE: Keep aligned with LogLevel in @dxos/protocols.\nexport enum LogLevel {\n TRACE = 5,\n DEBUG = 10,\n INFO = 11,\n WARN = 12,\n ERROR = 13,\n}\n\nexport const levels: { [index: string]: LogLevel } = {\n trace: LogLevel.TRACE,\n debug: LogLevel.DEBUG,\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.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 depth?: number; // Context object depth.\n processor?: string | LogProcessorType;\n formatter?: {\n column: number;\n };\n prefix?: string;\n};\n\n/**\n * Runtime config.\n */\nexport interface LogConfig {\n options: LogOptions;\n filters?: LogFilter[];\n processors: LogProcessor[];\n prefix?: string;\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 = 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 { LogConfig, LogFilter, LogLevel } from './config';\nimport { CallMetadata } from './meta';\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 * Record for current log line.\n */\nexport interface LogEntry {\n level: LogLevel;\n message: string;\n context?: LogContext;\n meta?: CallMetadata;\n error?: Error;\n}\n\n/**\n * Processes (e.g., prints, forwards) log entries.\n */\nexport type LogProcessor = (config: LogConfig, entry: LogEntry) => void;\n\nconst matchFilter = (filter: LogFilter, level: LogLevel, path: string) => {\n return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));\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 true;\n } else {\n return filters.some((filter) => matchFilter(filter, entry.level, entry.meta?.F ?? ''));\n }\n};\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 if (entry.context) {\n if (entry.context instanceof Error) {\n // Additional context from Error.\n const c = (entry.context as any).context;\n // If ERROR then show stacktrace.\n context = Object.assign(context ?? {}, { error: entry.context.stack, ...c });\n } else if (typeof entry.context === 'object') {\n context = Object.assign(context ?? {}, entry.context);\n }\n }\n\n return context && Object.keys(context).length > 0 ? context : undefined;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport defaultsDeep from 'lodash.defaultsdeep';\n\nimport { LogConfig, LogFilter, LogLevel, LogOptions, LogProcessorType, levels } from './config';\nimport { LogProcessor } from './context';\nimport { loadOptions } from './platform';\nimport { CONSOLE_PROCESSOR, DEBUG_PROCESSOR, BROWSER_PROCESSOR } from './processors';\n\n/**\n * Processor variants.\n */\nexport const processors: { [index: string]: LogProcessor } = {\n [LogProcessorType.CONSOLE]: CONSOLE_PROCESSOR,\n [LogProcessorType.BROWSER]: BROWSER_PROCESSOR,\n [LogProcessorType.DEBUG]: DEBUG_PROCESSOR,\n};\n\nconst IS_BROWSER = typeof window !== 'undefined' || typeof navigator !== 'undefined';\n\nexport const DEFAULT_PROCESSORS = [IS_BROWSER ? BROWSER_PROCESSOR : CONSOLE_PROCESSOR];\n\nexport const parseFilter = (filter: string | string[] | LogLevel): LogFilter[] => {\n if (typeof filter === 'number') {\n return [{ level: filter }];\n }\n\n const parseLogLevel = (level: string, defValue = LogLevel.WARN) => levels[level.toLowerCase()] ?? defValue;\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 ? { level: parseLogLevel(level), pattern } : { level: parseLogLevel(pattern) };\n });\n};\n\nexport const getConfig = (_options?: LogOptions): LogConfig => {\n let options: LogOptions = defaultsDeep(\n {},\n _options,\n 'process' in globalThis && {\n // TODO(burdon): Node only.\n file: process!.env?.LOG_CONFIG,\n filter: process!.env?.LOG_FILTER,\n processor: process!.env?.LOG_PROCESSOR,\n },\n );\n\n // TODO(burdon): Verbose option.\n // console.log(JSON.stringify(options, undefined, 2));\n options = defaultsDeep({}, loadOptions(options.file), options);\n return {\n options,\n filters: parseFilter(options.filter ?? LogLevel.INFO),\n processors: options.processor ? [processors[options.processor]] : DEFAULT_PROCESSORS,\n prefix: options.prefix,\n };\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { LogOptions } from '../../config';\n\n// NOTE: Implementation for the browser. See `package.json`.\nexport const loadOptions = (filepath?: string): LogOptions | undefined => {\n try {\n return JSON.parse(localStorage.getItem('dxlog')!);\n } catch (err) {\n return undefined;\n }\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(wittjosiah): Consider mapping console processor directly to browser processor in the browser.\nexport const CONSOLE_PROCESSOR = () => {};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { inspect } from 'node:util';\n\nimport { LogProcessor } from '../context';\n\nexport const DEBUG_PROCESSOR: LogProcessor = (config, entry) => {\n console.log(inspect(entry, false, null, true));\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { LogLevel } from '../config';\nimport { getContextFromEntry, LogProcessor, 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 typeof mochaExecutor !== 'undefined'\n ? {\n useTestProcessor: true,\n printFileLinks: true,\n }\n : {\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 args.push(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 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 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\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 args.push(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 2023 DXOS.org\n//\n\nimport { appendFileSync, mkdirSync, openSync } from 'node:fs';\nimport { dirname } from 'node:path';\n\nimport { jsonify } from '@dxos/util';\n\nimport { LogLevel } from '../config';\nimport { LogProcessor, getContextFromEntry } from '../context';\n\nexport const createFileProcessor = ({ path, levels }: { path: string; levels: LogLevel[] }): LogProcessor => {\n let fd: number | undefined;\n\n return (config, entry) => {\n if (!levels.includes(entry.level)) {\n return;\n }\n if (!fd) {\n try {\n mkdirSync(dirname(path));\n } catch {}\n fd = openSync(path, 'w');\n }\n\n const record = {\n ...entry,\n timestamp: Date.now(),\n meta: {\n file: entry.meta?.F,\n line: entry.meta?.L,\n },\n context: jsonify(getContextFromEntry(entry)),\n };\n appendFileSync(fd, JSON.stringify(record) + '\\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 path: getLogFilePath(),\n levels: [LogLevel.ERROR, LogLevel.WARN, LogLevel.INFO, LogLevel.TRACE],\n});\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { LogConfig, LogLevel, LogOptions } from './config';\nimport { LogContext, LogProcessor } from './context';\nimport { CallMetadata } from './meta';\nimport { getConfig, DEFAULT_PROCESSORS } from './options';\n\n/**\n * Logging function.\n */\ntype LogFunction = (message: string, context?: LogContext, meta?: CallMetadata) => void;\n\n/**\n * Logging methods.\n */\ninterface LogMethods {\n trace: LogFunction;\n debug: LogFunction;\n info: LogFunction;\n warn: LogFunction;\n error: LogFunction;\n catch: (error: Error | any, context?: LogContext, meta?: CallMetadata) => void;\n break: () => void;\n}\n\n/**\n * Properties accessible on the logging function.\n */\ninterface Log extends LogMethods, LogFunction {\n config: (options: LogOptions) => void;\n addProcessor: (processor: LogProcessor) => void;\n runtimeConfig: LogConfig;\n}\n\ninterface LogImp extends Log {\n _config: LogConfig;\n}\n\nconst createLog = (): LogImp => {\n const log: LogImp = ((...params) => processLog(LogLevel.DEBUG, ...params)) as LogImp;\n\n log._config = getConfig();\n Object.defineProperty(log, 'runtimeConfig', { get: () => log._config });\n\n log.addProcessor = (processor: LogProcessor) => {\n if (DEFAULT_PROCESSORS.filter((p) => p === processor).length === 0) {\n DEFAULT_PROCESSORS.push(processor);\n }\n if (log._config.processors.filter((p) => p === processor).length === 0) {\n log._config.processors.push(processor);\n }\n };\n\n // Set config.\n log.config = (options: LogOptions) => {\n log._config = getConfig(options);\n };\n\n // TODO(burdon): API to set context and separate error object.\n // E.g., log.warn('failed', { key: 123 }, err);\n\n log.trace = (...params) => processLog(LogLevel.TRACE, ...params);\n log.debug = (...params) => processLog(LogLevel.DEBUG, ...params);\n log.info = (...params) => processLog(LogLevel.INFO, ...params);\n log.warn = (...params) => processLog(LogLevel.WARN, ...params);\n log.error = (...params) => processLog(LogLevel.ERROR, ...params);\n\n // Catch only shows error message, not stacktrace.\n log.catch = (error: Error | any, context, meta) => processLog(LogLevel.ERROR, error.stack, context, meta);\n\n // Show break.\n log.break = () => log.info('——————————————————————————————————————————————————');\n\n /**\n * Process the current log call.\n */\n const processLog = (\n level: LogLevel,\n message: string,\n context: LogContext = {},\n meta?: CallMetadata,\n error?: Error,\n ) => {\n log._config.processors.forEach((processor) => processor(log._config, { level, message, context, meta, error }));\n };\n\n return log;\n};\n\n/**\n * Global logging function.\n */\nexport const log: Log = ((globalThis as any).dx_log ??= createLog());\n\n/**\n * Accessible from browser console.\n */\ndeclare global {\n // eslint-disable-next-line camelcase\n const dx_log: Log;\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(public constr: any, public parent?: OwnershipScope) {}\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;\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BC,OAAO,iBAAA;AAC/B,IAAMC,yBAAyBD,OAAO,wBAAA;AACtC,IAAME,uBAAuBF,OAAO,sBAAA;AAM7B,IAAMG,iBAAN,MAAMA;EAGXC,YAAmBC,QAAoBC,QAAyB;kBAA7CD;kBAAoBC;EAA0B;EAEjEC,UAAU;AACR,QAAI,CAAC,KAAKC,UAAU;AAClB,aAAO,CAAC;IACV;AACA,UAAMC,QAAQ,KAAKJ,OAAOK,UAAUR,oBAAAA,KAAyB,CAAA;AAC7D,UAAMS,OAAY,CAAC;AACnB,eAAWC,QAAQH,OAAO;AACxBE,WAAKC,IAAAA,IAAQ,KAAKJ,SAASI,IAAAA;IAC7B;AACA,WAAOD;EACT;EAEA,CAACE,SAAQC,MAAM,IAAI;AACjB,WAAO;MACLC,WAAW,KAAKV,OAAOW;MACvBL,MAAM,KAAKJ,QAAO;MAClBD,QAAQ,KAAKA;IACf;EACF;AACF;AA+CO,IAAMW,2BAA2B,CAACC,YAAiBA;",
6
+ "names": ["LogLevel", "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "levels", "trace", "debug", "info", "warn", "error", "shortLevelName", "LogProcessorType", "CONSOLE", "BROWSER", "logInfoProperties", "Symbol", "logInfo", "target", "propertyKey", "descriptor", "push", "gatherLogInfoFromScope", "scope", "res", "prototype", "Object", "getPrototypeOf", "infoProps", "prop", "err", "message", "matchFilter", "filter", "level", "path", "pattern", "includes", "shouldLog", "entry", "filters", "undefined", "some", "meta", "F", "getContextFromEntry", "context", "scopeInfo", "gatherLogInfoFromScope", "S", "Object", "keys", "length", "assign", "Error", "c", "error", "stack", "defaultsDeep", "loadOptions", "filepath", "JSON", "parse", "localStorage", "getItem", "err", "undefined", "CONSOLE_PROCESSOR", "inspect", "DEBUG_PROCESSOR", "config", "entry", "console", "log", "inspect", "getRelativeFilename", "filename", "match", "filePath", "CONFIG", "mochaExecutor", "useTestProcessor", "printFileLinks", "APP_BROWSER_PROCESSOR", "config", "entry", "shouldLog", "filters", "LOG_BROWSER_PREFIX", "prefix", "LOG_BROWSER_CSS", "link", "meta", "F", "filepath", "replace", "L", "args", "push", "message", "context", "getContextFromEntry", "levels", "LogLevel", "ERROR", "console", "error", "WARN", "warn", "DEBUG", "log", "length", "join", "level", "C", "TEST_BROWSER_PROCESSOR", "path", "BROWSER_PROCESSOR", "appendFileSync", "mkdirSync", "openSync", "dirname", "jsonify", "createFileProcessor", "path", "levels", "fd", "config", "entry", "includes", "level", "mkdirSync", "dirname", "openSync", "record", "timestamp", "Date", "now", "meta", "file", "F", "line", "L", "context", "jsonify", "getContextFromEntry", "appendFileSync", "JSON", "stringify", "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", "IS_BROWSER", "window", "navigator", "DEFAULT_PROCESSORS", "parseFilter", "filter", "level", "parseLogLevel", "defValue", "LogLevel", "WARN", "levels", "toLowerCase", "lines", "split", "map", "pattern", "getConfig", "_options", "options", "defaultsDeep", "globalThis", "file", "process", "env", "LOG_CONFIG", "LOG_FILTER", "processor", "LOG_PROCESSOR", "loadOptions", "filters", "INFO", "prefix", "createLog", "log", "params", "processLog", "LogLevel", "DEBUG", "_config", "getConfig", "Object", "defineProperty", "get", "addProcessor", "processor", "DEFAULT_PROCESSORS", "filter", "p", "length", "push", "processors", "config", "options", "trace", "TRACE", "debug", "info", "INFO", "warn", "WARN", "error", "ERROR", "catch", "context", "meta", "stack", "break", "level", "message", "forEach", "globalThis", "dx_log", "inspect", "kOwnershipScope", "Symbol", "kCurrentOwnershipScope", "kDebugInfoProperties", "OwnershipScope", "constructor", "constr", "parent", "getInfo", "instance", "props", "prototype", "info", "prop", "inspect", "custom", "className", "name", "getCurrentOwnershipScope", "thisRef"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/common/log/src/config.ts":{"bytes":3974,"imports":[]},"packages/common/log/src/scope.ts":{"bytes":3852,"imports":[]},"packages/common/log/src/context.ts":{"bytes":5914,"imports":[{"path":"packages/common/log/src/scope.ts","kind":"import-statement","original":"./scope"}]},"packages/common/log/src/platform/browser/index.ts":{"bytes":1317,"imports":[]},"packages/common/log/src/platform/index.ts":{"bytes":460,"imports":[{"path":"packages/common/log/src/platform/browser/index.ts","kind":"import-statement","original":"./node"}]},"packages/common/log/src/processors/console-stub.ts":{"bytes":828,"imports":[]},"packages/common/log/src/processors/debug-processor.ts":{"bytes":1066,"imports":[{"path":"@dxos/node-std/util","kind":"import-statement","external":true}]},"packages/common/log/src/processors/browser-processor.ts":{"bytes":12682,"imports":[{"path":"packages/common/log/src/config.ts","kind":"import-statement","original":"../config"},{"path":"packages/common/log/src/context.ts","kind":"import-statement","original":"../context"}]},"packages/common/log/src/processors/file-processor.ts":{"bytes":5318,"imports":[{"path":"@dxos/node-std/fs","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/common/log/src/config.ts","kind":"import-statement","original":"../config"},{"path":"packages/common/log/src/context.ts","kind":"import-statement","original":"../context"}]},"packages/common/log/src/processors/index.ts":{"bytes":817,"imports":[{"path":"packages/common/log/src/processors/console-stub.ts","kind":"import-statement","original":"./console-processor"},{"path":"packages/common/log/src/processors/debug-processor.ts","kind":"import-statement","original":"./debug-processor"},{"path":"packages/common/log/src/processors/browser-processor.ts","kind":"import-statement","original":"./browser-processor"},{"path":"packages/common/log/src/processors/file-processor.ts","kind":"import-statement","original":"./file-processor"}]},"packages/common/log/src/options.ts":{"bytes":7349,"imports":[{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"packages/common/log/src/config.ts","kind":"import-statement","original":"./config"},{"path":"packages/common/log/src/platform/index.ts","kind":"import-statement","original":"./platform"},{"path":"packages/common/log/src/processors/index.ts","kind":"import-statement","original":"./processors"}]},"packages/common/log/src/log.ts":{"bytes":8730,"imports":[{"path":"packages/common/log/src/config.ts","kind":"import-statement","original":"./config"},{"path":"packages/common/log/src/options.ts","kind":"import-statement","original":"./options"}]},"packages/common/log/src/invariant.ts":{"bytes":3304,"imports":[]},"packages/common/log/src/meta.ts":{"bytes":1625,"imports":[]},"packages/common/log/src/experimental/ownership.ts":{"bytes":9246,"imports":[{"path":"@dxos/node-std/util","kind":"import-statement","external":true}]},"packages/common/log/src/index.ts":{"bytes":1353,"imports":[{"path":"packages/common/log/src/config.ts","kind":"import-statement","original":"./config"},{"path":"packages/common/log/src/context.ts","kind":"import-statement","original":"./context"},{"path":"packages/common/log/src/log.ts","kind":"import-statement","original":"./log"},{"path":"packages/common/log/src/options.ts","kind":"import-statement","original":"./options"},{"path":"packages/common/log/src/processors/index.ts","kind":"import-statement","original":"./processors"},{"path":"packages/common/log/src/scope.ts","kind":"import-statement","original":"./scope"},{"path":"packages/common/log/src/invariant.ts","kind":"import-statement","original":"./invariant"},{"path":"packages/common/log/src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"packages/common/log/src/experimental/ownership.ts","kind":"import-statement","original":"./experimental/ownership"}]}},"outputs":{"packages/common/log/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":31453},"packages/common/log/dist/lib/browser/index.mjs":{"imports":[{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"@dxos/node-std/util","kind":"import-statement","external":true},{"path":"@dxos/node-std/fs","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/node-std/util","kind":"import-statement","external":true}],"exports":["BROWSER_PROCESSOR","CONSOLE_PROCESSOR","DEBUG_PROCESSOR","FILE_PROCESSOR","InvariantViolation","LogLevel","LogProcessorType","createFileProcessor","gatherLogInfoFromScope","getContextFromEntry","getCurrentOwnershipScope","invariant","levels","log","logInfo","parseFilter","shortLevelName","shouldLog"],"entryPoint":"packages/common/log/src/index.ts","inputs":{"packages/common/log/src/config.ts":{"bytesInOutput":821},"packages/common/log/src/index.ts":{"bytesInOutput":0},"packages/common/log/src/scope.ts":{"bytesInOutput":662},"packages/common/log/src/context.ts":{"bytesInOutput":1122},"packages/common/log/src/options.ts":{"bytesInOutput":1624},"packages/common/log/src/platform/browser/index.ts":{"bytesInOutput":140},"packages/common/log/src/platform/index.ts":{"bytesInOutput":0},"packages/common/log/src/processors/console-stub.ts":{"bytesInOutput":35},"packages/common/log/src/processors/index.ts":{"bytesInOutput":0},"packages/common/log/src/processors/debug-processor.ts":{"bytesInOutput":143},"packages/common/log/src/processors/browser-processor.ts":{"bytesInOutput":2507},"packages/common/log/src/processors/file-processor.ts":{"bytesInOutput":1223},"packages/common/log/src/log.ts":{"bytesInOutput":1690},"packages/common/log/src/invariant.ts":{"bytesInOutput":561},"packages/common/log/src/experimental/ownership.ts":{"bytesInOutput":826}},"bytes":12325}}}
1
+ {"inputs":{"packages/common/log/src/config.ts":{"bytes":3974,"imports":[],"format":"esm"},"packages/common/log/src/scope.ts":{"bytes":3852,"imports":[],"format":"esm"},"packages/common/log/src/context.ts":{"bytes":5914,"imports":[{"path":"packages/common/log/src/scope.ts","kind":"import-statement","original":"./scope"}],"format":"esm"},"packages/common/log/src/platform/browser/index.ts":{"bytes":1317,"imports":[],"format":"esm"},"packages/common/log/src/platform/index.ts":{"bytes":460,"imports":[{"path":"packages/common/log/src/platform/browser/index.ts","kind":"import-statement","original":"./node"}],"format":"esm"},"packages/common/log/src/processors/console-stub.ts":{"bytes":828,"imports":[],"format":"esm"},"packages/common/log/src/processors/debug-processor.ts":{"bytes":1066,"imports":[{"path":"@dxos/node-std/util","kind":"import-statement","external":true}],"format":"esm"},"packages/common/log/src/processors/browser-processor.ts":{"bytes":12682,"imports":[{"path":"packages/common/log/src/config.ts","kind":"import-statement","original":"../config"},{"path":"packages/common/log/src/context.ts","kind":"import-statement","original":"../context"}],"format":"esm"},"packages/common/log/src/processors/file-processor.ts":{"bytes":5318,"imports":[{"path":"@dxos/node-std/fs","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/common/log/src/config.ts","kind":"import-statement","original":"../config"},{"path":"packages/common/log/src/context.ts","kind":"import-statement","original":"../context"}],"format":"esm"},"packages/common/log/src/processors/index.ts":{"bytes":817,"imports":[{"path":"packages/common/log/src/processors/console-stub.ts","kind":"import-statement","original":"./console-processor"},{"path":"packages/common/log/src/processors/debug-processor.ts","kind":"import-statement","original":"./debug-processor"},{"path":"packages/common/log/src/processors/browser-processor.ts","kind":"import-statement","original":"./browser-processor"},{"path":"packages/common/log/src/processors/file-processor.ts","kind":"import-statement","original":"./file-processor"}],"format":"esm"},"packages/common/log/src/options.ts":{"bytes":7349,"imports":[{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"packages/common/log/src/config.ts","kind":"import-statement","original":"./config"},{"path":"packages/common/log/src/platform/index.ts","kind":"import-statement","original":"./platform"},{"path":"packages/common/log/src/processors/index.ts","kind":"import-statement","original":"./processors"}],"format":"esm"},"packages/common/log/src/log.ts":{"bytes":8730,"imports":[{"path":"packages/common/log/src/config.ts","kind":"import-statement","original":"./config"},{"path":"packages/common/log/src/options.ts","kind":"import-statement","original":"./options"}],"format":"esm"},"packages/common/log/src/meta.ts":{"bytes":1625,"imports":[],"format":"esm"},"packages/common/log/src/experimental/ownership.ts":{"bytes":9246,"imports":[{"path":"@dxos/node-std/util","kind":"import-statement","external":true}],"format":"esm"},"packages/common/log/src/index.ts":{"bytes":1264,"imports":[{"path":"packages/common/log/src/config.ts","kind":"import-statement","original":"./config"},{"path":"packages/common/log/src/context.ts","kind":"import-statement","original":"./context"},{"path":"packages/common/log/src/log.ts","kind":"import-statement","original":"./log"},{"path":"packages/common/log/src/options.ts","kind":"import-statement","original":"./options"},{"path":"packages/common/log/src/processors/index.ts","kind":"import-statement","original":"./processors"},{"path":"packages/common/log/src/scope.ts","kind":"import-statement","original":"./scope"},{"path":"packages/common/log/src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"packages/common/log/src/experimental/ownership.ts","kind":"import-statement","original":"./experimental/ownership"}],"format":"esm"}},"outputs":{"packages/common/log/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":29403},"packages/common/log/dist/lib/browser/index.mjs":{"imports":[{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"@dxos/node-std/util","kind":"import-statement","external":true},{"path":"@dxos/node-std/fs","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/node-std/util","kind":"import-statement","external":true}],"exports":["BROWSER_PROCESSOR","CONSOLE_PROCESSOR","DEBUG_PROCESSOR","FILE_PROCESSOR","LogLevel","LogProcessorType","createFileProcessor","gatherLogInfoFromScope","getContextFromEntry","getCurrentOwnershipScope","levels","log","logInfo","parseFilter","shortLevelName","shouldLog"],"entryPoint":"packages/common/log/src/index.ts","inputs":{"packages/common/log/src/config.ts":{"bytesInOutput":821},"packages/common/log/src/index.ts":{"bytesInOutput":0},"packages/common/log/src/scope.ts":{"bytesInOutput":571},"packages/common/log/src/context.ts":{"bytesInOutput":981},"packages/common/log/src/options.ts":{"bytesInOutput":1444},"packages/common/log/src/platform/browser/index.ts":{"bytesInOutput":140},"packages/common/log/src/platform/index.ts":{"bytesInOutput":0},"packages/common/log/src/processors/console-stub.ts":{"bytesInOutput":35},"packages/common/log/src/processors/index.ts":{"bytesInOutput":0},"packages/common/log/src/processors/debug-processor.ts":{"bytesInOutput":143},"packages/common/log/src/processors/browser-processor.ts":{"bytesInOutput":2318},"packages/common/log/src/processors/file-processor.ts":{"bytesInOutput":1098},"packages/common/log/src/log.ts":{"bytesInOutput":1644},"packages/common/log/src/experimental/ownership.ts":{"bytesInOutput":792}},"bytes":10882}}}
@@ -35,7 +35,6 @@ __export(src_exports, {
35
35
  DEBUG_PROCESSOR: () => DEBUG_PROCESSOR,
36
36
  DEFAULT_FORMATTER: () => DEFAULT_FORMATTER,
37
37
  FILE_PROCESSOR: () => FILE_PROCESSOR,
38
- InvariantViolation: () => InvariantViolation,
39
38
  LogLevel: () => LogLevel,
40
39
  LogProcessorType: () => LogProcessorType,
41
40
  SHORT_FORMATTER: () => SHORT_FORMATTER,
@@ -43,7 +42,6 @@ __export(src_exports, {
43
42
  gatherLogInfoFromScope: () => gatherLogInfoFromScope,
44
43
  getContextFromEntry: () => getContextFromEntry,
45
44
  getCurrentOwnershipScope: () => getCurrentOwnershipScope,
46
- invariant: () => invariant,
47
45
  levels: () => levels,
48
46
  log: () => log,
49
47
  logInfo: () => logInfo,
@@ -87,17 +85,15 @@ var LogProcessorType;
87
85
  // packages/common/log/src/scope.ts
88
86
  var logInfoProperties = Symbol("logInfoProperties");
89
87
  var logInfo = (target, propertyKey, descriptor) => {
90
- var _a2;
91
- ((_a2 = target[logInfoProperties]) != null ? _a2 : target[logInfoProperties] = []).push(propertyKey);
88
+ (target[logInfoProperties] ??= []).push(propertyKey);
92
89
  };
93
90
  var gatherLogInfoFromScope = (scope) => {
94
- var _a2;
95
91
  if (!scope) {
96
92
  return {};
97
93
  }
98
94
  const res = {};
99
95
  const prototype = Object.getPrototypeOf(scope);
100
- const infoProps = (_a2 = prototype[logInfoProperties]) != null ? _a2 : [];
96
+ const infoProps = prototype[logInfoProperties] ?? [];
101
97
  for (const prop of infoProps) {
102
98
  try {
103
99
  res[prop] = typeof scope[prop] === "function" ? scope[prop]() : scope[prop];
@@ -116,10 +112,7 @@ var shouldLog = (entry, filters) => {
116
112
  if (filters === void 0) {
117
113
  return true;
118
114
  } else {
119
- return filters.some((filter) => {
120
- var _a2, _b;
121
- return matchFilter(filter, entry.level, (_b = (_a2 = entry.meta) == null ? void 0 : _a2.F) != null ? _b : "");
122
- });
115
+ return filters.some((filter) => matchFilter(filter, entry.level, entry.meta?.F ?? ""));
123
116
  }
124
117
  };
125
118
  var getContextFromEntry = (entry) => {
@@ -127,18 +120,18 @@ var getContextFromEntry = (entry) => {
127
120
  if (entry.meta) {
128
121
  const scopeInfo = gatherLogInfoFromScope(entry.meta.S);
129
122
  if (Object.keys(scopeInfo).length > 0) {
130
- context = Object.assign(context != null ? context : {}, scopeInfo);
123
+ context = Object.assign(context ?? {}, scopeInfo);
131
124
  }
132
125
  }
133
126
  if (entry.context) {
134
127
  if (entry.context instanceof Error) {
135
128
  const c = entry.context.context;
136
- context = Object.assign(context != null ? context : {}, {
129
+ context = Object.assign(context ?? {}, {
137
130
  error: entry.context.stack,
138
131
  ...c
139
132
  });
140
133
  } else if (typeof entry.context === "object") {
141
- context = Object.assign(context != null ? context : {}, entry.context);
134
+ context = Object.assign(context ?? {}, entry.context);
142
135
  }
143
136
  }
144
137
  return context && Object.keys(context).length > 0 ? context : void 0;
@@ -170,6 +163,7 @@ var loadOptions = (filepath) => {
170
163
  var import_chalk = __toESM(require("chalk"));
171
164
  var import_lodash = __toESM(require("lodash.pickby"));
172
165
  var import_node_util = require("node:util");
166
+ var import_util = require("@dxos/util");
173
167
  var LEVEL_COLORS = {
174
168
  [LogLevel.TRACE]: "gray",
175
169
  [LogLevel.DEBUG]: "gray",
@@ -178,7 +172,7 @@ var LEVEL_COLORS = {
178
172
  [LogLevel.ERROR]: "red"
179
173
  };
180
174
  var truncate = (text, length = 0, right = false) => {
181
- const str = text && length ? right ? text.slice(-length) : text.substring(0, length) : text != null ? text : "";
175
+ const str = text && length ? right ? text.slice(-length) : text.substring(0, length) : text ?? "";
182
176
  return right ? str.padStart(length, " ") : str.padEnd(length, " ");
183
177
  };
184
178
  var getRelativeFilename = (filename) => {
@@ -189,16 +183,22 @@ var getRelativeFilename = (filename) => {
189
183
  }
190
184
  return filename;
191
185
  };
192
- var DEFAULT_FORMATTER = (config, { path: path2, line, level, message, context, error }) => {
193
- var _a2, _b;
194
- const column = (_b = (_a2 = config.options) == null ? void 0 : _a2.formatter) == null ? void 0 : _b.column;
186
+ var DEFAULT_FORMATTER = (config, { path: path2, line, level, message, context, error, scope }) => {
187
+ const column = config.options?.formatter?.column;
195
188
  const filepath = path2 !== void 0 && line !== void 0 ? import_chalk.default.grey(`${path2}:${line}`) : void 0;
189
+ let instance;
190
+ if (scope) {
191
+ const prototype = Object.getPrototypeOf(scope);
192
+ const id = (0, import_util.getPrototypeSpecificInstanceId)(scope);
193
+ instance = import_chalk.default.magentaBright(`${prototype.constructor.name}#${id}`);
194
+ }
196
195
  return [
197
196
  // NOTE: File path must come fist for console hyperlinks.
198
197
  // Must not truncate for terminal output.
199
198
  filepath,
200
199
  column && filepath ? "".padStart(column - filepath.length) : void 0,
201
200
  import_chalk.default[LEVEL_COLORS[level]](column ? shortLevelName[level] : LogLevel[level]),
201
+ instance,
202
202
  message,
203
203
  context,
204
204
  error
@@ -223,6 +223,7 @@ var CONSOLE_PROCESSOR = (config, entry) => {
223
223
  if (meta) {
224
224
  parts.path = getRelativeFilename(meta.F);
225
225
  parts.line = meta.L;
226
+ parts.scope = meta.S;
226
227
  }
227
228
  const context = getContextFromEntry(entry);
228
229
  if (context) {
@@ -260,11 +261,10 @@ var CONFIG = typeof mochaExecutor !== "undefined" ? {
260
261
  printFileLinks: false
261
262
  };
262
263
  var APP_BROWSER_PROCESSOR = (config, entry) => {
263
- var _a2, _b, _c;
264
264
  if (!shouldLog(entry, config.filters)) {
265
265
  return;
266
266
  }
267
- const LOG_BROWSER_PREFIX = (_a2 = config.prefix) != null ? _a2 : "https://vscode.dev/github.com/dxos/dxos/blob/main/";
267
+ const LOG_BROWSER_PREFIX = config.prefix ?? "https://vscode.dev/github.com/dxos/dxos/blob/main/";
268
268
  const LOG_BROWSER_CSS = [];
269
269
  let link = "";
270
270
  if (entry.meta) {
@@ -284,7 +284,7 @@ var APP_BROWSER_PROCESSOR = (config, entry) => {
284
284
  [LogLevel.DEBUG]: console.log
285
285
  };
286
286
  if (CONFIG.printFileLinks) {
287
- if (LOG_BROWSER_CSS == null ? void 0 : LOG_BROWSER_CSS.length) {
287
+ if (LOG_BROWSER_CSS?.length) {
288
288
  args = [
289
289
  `%c${link}
290
290
  %c${args.join(" ")}`,
@@ -297,15 +297,14 @@ var APP_BROWSER_PROCESSOR = (config, entry) => {
297
297
  ];
298
298
  }
299
299
  }
300
- const level = (_b = levels2[entry.level]) != null ? _b : console.log;
301
- if (typeof ((_c = entry.meta) == null ? void 0 : _c.C) === "function") {
300
+ const level = levels2[entry.level] ?? console.log;
301
+ if (typeof entry.meta?.C === "function") {
302
302
  entry.meta.C(level, args);
303
303
  } else {
304
304
  level(...args);
305
305
  }
306
306
  };
307
307
  var TEST_BROWSER_PROCESSOR = (config, entry) => {
308
- var _a2, _b;
309
308
  if (!shouldLog(entry, config.filters)) {
310
309
  return;
311
310
  }
@@ -330,8 +329,8 @@ var TEST_BROWSER_PROCESSOR = (config, entry) => {
330
329
  ...args
331
330
  ];
332
331
  }
333
- const level = (_a2 = levels2[entry.level]) != null ? _a2 : console.log;
334
- if (typeof ((_b = entry.meta) == null ? void 0 : _b.C) === "function") {
332
+ const level = levels2[entry.level] ?? console.log;
333
+ if (typeof entry.meta?.C === "function") {
335
334
  entry.meta.C(level, args);
336
335
  } else {
337
336
  level(...args);
@@ -342,18 +341,17 @@ var BROWSER_PROCESSOR = CONFIG.useTestProcessor ? TEST_BROWSER_PROCESSOR : APP_B
342
341
  // packages/common/log/src/processors/file-processor.ts
343
342
  var import_node_fs2 = require("node:fs");
344
343
  var import_node_path2 = require("node:path");
345
- var import_util = require("@dxos/util");
344
+ var import_util2 = require("@dxos/util");
346
345
  var createFileProcessor = ({ path: path2, levels: levels2 }) => {
347
346
  let fd;
348
347
  return (config, entry) => {
349
- var _a2, _b;
350
348
  if (!levels2.includes(entry.level)) {
351
349
  return;
352
350
  }
353
351
  if (!fd) {
354
352
  try {
355
353
  (0, import_node_fs2.mkdirSync)((0, import_node_path2.dirname)(path2));
356
- } catch (e) {
354
+ } catch {
357
355
  }
358
356
  fd = (0, import_node_fs2.openSync)(path2, "w");
359
357
  }
@@ -361,18 +359,17 @@ var createFileProcessor = ({ path: path2, levels: levels2 }) => {
361
359
  ...entry,
362
360
  timestamp: Date.now(),
363
361
  meta: {
364
- file: (_a2 = entry.meta) == null ? void 0 : _a2.F,
365
- line: (_b = entry.meta) == null ? void 0 : _b.L
362
+ file: entry.meta?.F,
363
+ line: entry.meta?.L
366
364
  },
367
- context: (0, import_util.jsonify)(getContextFromEntry(entry))
365
+ context: (0, import_util2.jsonify)(getContextFromEntry(entry))
368
366
  };
369
367
  (0, import_node_fs2.appendFileSync)(fd, JSON.stringify(record) + "\n");
370
368
  };
371
369
  };
372
370
  var logFilePath;
373
371
  var getLogFilePath = () => {
374
- var _a2;
375
- logFilePath != null ? logFilePath : logFilePath = (_a2 = process.env.LOG_FILE) != null ? _a2 : process.env.HOME ? `${process.env.HOME}/.dxlog/${new Date().toISOString()}.log` : void 0;
372
+ logFilePath ??= process.env.LOG_FILE ?? (process.env.HOME ? `${process.env.HOME}/.dxlog/${(/* @__PURE__ */ new Date()).toISOString()}.log` : void 0);
376
373
  return logFilePath;
377
374
  };
378
375
  var FILE_PROCESSOR = createFileProcessor({
@@ -403,10 +400,7 @@ var parseFilter = (filter) => {
403
400
  }
404
401
  ];
405
402
  }
406
- const parseLogLevel = (level, defValue = LogLevel.WARN) => {
407
- var _a2;
408
- return (_a2 = levels[level.toLowerCase()]) != null ? _a2 : defValue;
409
- };
403
+ const parseLogLevel = (level, defValue = LogLevel.WARN) => levels[level.toLowerCase()] ?? defValue;
410
404
  const lines = typeof filter === "string" ? filter.split(/,\s*/) : filter;
411
405
  return lines.map((filter2) => {
412
406
  const [pattern, level] = filter2.split(":");
@@ -419,17 +413,16 @@ var parseFilter = (filter) => {
419
413
  });
420
414
  };
421
415
  var getConfig = (_options) => {
422
- var _a2, _b, _c, _d;
423
416
  let options = (0, import_lodash2.default)({}, _options, "process" in globalThis && {
424
417
  // TODO(burdon): Node only.
425
- file: (_a2 = process.env) == null ? void 0 : _a2.LOG_CONFIG,
426
- filter: (_b = process.env) == null ? void 0 : _b.LOG_FILTER,
427
- processor: (_c = process.env) == null ? void 0 : _c.LOG_PROCESSOR
418
+ file: process.env?.LOG_CONFIG,
419
+ filter: process.env?.LOG_FILTER,
420
+ processor: process.env?.LOG_PROCESSOR
428
421
  });
429
422
  options = (0, import_lodash2.default)({}, loadOptions(options.file), options);
430
423
  return {
431
424
  options,
432
- filters: parseFilter((_d = options.filter) != null ? _d : LogLevel.INFO),
425
+ filters: parseFilter(options.filter ?? LogLevel.INFO),
433
426
  processors: options.processor ? [
434
427
  processors[options.processor]
435
428
  ] : DEFAULT_PROCESSORS,
@@ -473,32 +466,7 @@ var createLog = () => {
473
466
  };
474
467
  return log2;
475
468
  };
476
- var _a;
477
- var log = (_a = globalThis.dx_log) != null ? _a : globalThis.dx_log = createLog();
478
-
479
- // packages/common/log/src/invariant.ts
480
- var invariant = (condition, message, meta) => {
481
- if (condition) {
482
- return;
483
- }
484
- let errorMessage = "invariant violation";
485
- if (message) {
486
- errorMessage += `: ${message}`;
487
- }
488
- if (meta == null ? void 0 : meta.A) {
489
- errorMessage += ` [${meta.A[0]}]`;
490
- }
491
- if (meta == null ? void 0 : meta.F) {
492
- errorMessage += ` at ${meta.F}:${meta.L}`;
493
- }
494
- throw new InvariantViolation(errorMessage);
495
- };
496
- var InvariantViolation = class extends Error {
497
- constructor(message) {
498
- super(message);
499
- Object.setPrototypeOf(this, new.target.prototype);
500
- }
501
- };
469
+ var log = globalThis.dx_log ??= createLog();
502
470
 
503
471
  // packages/common/log/src/experimental/ownership.ts
504
472
  var import_node_util3 = require("node:util");
@@ -511,11 +479,10 @@ var OwnershipScope = class {
511
479
  this.parent = parent;
512
480
  }
513
481
  getInfo() {
514
- var _a2;
515
482
  if (!this.instance) {
516
483
  return {};
517
484
  }
518
- const props = (_a2 = this.constr.prototype[kDebugInfoProperties]) != null ? _a2 : [];
485
+ const props = this.constr.prototype[kDebugInfoProperties] ?? [];
519
486
  const info = {};
520
487
  for (const prop of props) {
521
488
  info[prop] = this.instance[prop];
@@ -538,7 +505,6 @@ var getCurrentOwnershipScope = (thisRef) => thisRef;
538
505
  DEBUG_PROCESSOR,
539
506
  DEFAULT_FORMATTER,
540
507
  FILE_PROCESSOR,
541
- InvariantViolation,
542
508
  LogLevel,
543
509
  LogProcessorType,
544
510
  SHORT_FORMATTER,
@@ -546,7 +512,6 @@ var getCurrentOwnershipScope = (thisRef) => thisRef;
546
512
  gatherLogInfoFromScope,
547
513
  getContextFromEntry,
548
514
  getCurrentOwnershipScope,
549
- invariant,
550
515
  levels,
551
516
  log,
552
517
  logInfo,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/index.ts", "../../../src/config.ts", "../../../src/scope.ts", "../../../src/context.ts", "../../../src/options.ts", "../../../src/platform/node/index.ts", "../../../src/processors/console-processor.ts", "../../../src/processors/debug-processor.ts", "../../../src/processors/browser-processor.ts", "../../../src/processors/file-processor.ts", "../../../src/log.ts", "../../../src/invariant.ts", "../../../src/experimental/ownership.ts"],
4
- "sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nexport * from './config';\nexport * from './context';\nexport * from './log';\nexport { parseFilter } from './options';\nexport * from './processors';\nexport * from './scope';\nexport * from './invariant';\nexport * from './meta';\n\nexport { getCurrentOwnershipScope } from './experimental/ownership';\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { LogProcessor } from './context';\n\n/**\n * Standard levels.\n */\n// NOTE: Keep aligned with LogLevel in @dxos/protocols.\nexport enum LogLevel {\n TRACE = 5,\n DEBUG = 10,\n INFO = 11,\n WARN = 12,\n ERROR = 13,\n}\n\nexport const levels: { [index: string]: LogLevel } = {\n trace: LogLevel.TRACE,\n debug: LogLevel.DEBUG,\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.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 depth?: number; // Context object depth.\n processor?: string | LogProcessorType;\n formatter?: {\n column: number;\n };\n prefix?: string;\n};\n\n/**\n * Runtime config.\n */\nexport interface LogConfig {\n options: LogOptions;\n filters?: LogFilter[];\n processors: LogProcessor[];\n prefix?: string;\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 = 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 { LogConfig, LogFilter, LogLevel } from './config';\nimport { CallMetadata } from './meta';\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 * Record for current log line.\n */\nexport interface LogEntry {\n level: LogLevel;\n message: string;\n context?: LogContext;\n meta?: CallMetadata;\n error?: Error;\n}\n\n/**\n * Processes (e.g., prints, forwards) log entries.\n */\nexport type LogProcessor = (config: LogConfig, entry: LogEntry) => void;\n\nconst matchFilter = (filter: LogFilter, level: LogLevel, path: string) => {\n return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));\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 true;\n } else {\n return filters.some((filter) => matchFilter(filter, entry.level, entry.meta?.F ?? ''));\n }\n};\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 if (entry.context) {\n if (entry.context instanceof Error) {\n // Additional context from Error.\n const c = (entry.context as any).context;\n // If ERROR then show stacktrace.\n context = Object.assign(context ?? {}, { error: entry.context.stack, ...c });\n } else if (typeof entry.context === 'object') {\n context = Object.assign(context ?? {}, entry.context);\n }\n }\n\n return context && Object.keys(context).length > 0 ? context : undefined;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport defaultsDeep from 'lodash.defaultsdeep';\n\nimport { LogConfig, LogFilter, LogLevel, LogOptions, LogProcessorType, levels } from './config';\nimport { LogProcessor } from './context';\nimport { loadOptions } from './platform';\nimport { CONSOLE_PROCESSOR, DEBUG_PROCESSOR, BROWSER_PROCESSOR } from './processors';\n\n/**\n * Processor variants.\n */\nexport const processors: { [index: string]: LogProcessor } = {\n [LogProcessorType.CONSOLE]: CONSOLE_PROCESSOR,\n [LogProcessorType.BROWSER]: BROWSER_PROCESSOR,\n [LogProcessorType.DEBUG]: DEBUG_PROCESSOR,\n};\n\nconst IS_BROWSER = typeof window !== 'undefined' || typeof navigator !== 'undefined';\n\nexport const DEFAULT_PROCESSORS = [IS_BROWSER ? BROWSER_PROCESSOR : CONSOLE_PROCESSOR];\n\nexport const parseFilter = (filter: string | string[] | LogLevel): LogFilter[] => {\n if (typeof filter === 'number') {\n return [{ level: filter }];\n }\n\n const parseLogLevel = (level: string, defValue = LogLevel.WARN) => levels[level.toLowerCase()] ?? defValue;\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 ? { level: parseLogLevel(level), pattern } : { level: parseLogLevel(pattern) };\n });\n};\n\nexport const getConfig = (_options?: LogOptions): LogConfig => {\n let options: LogOptions = defaultsDeep(\n {},\n _options,\n 'process' in globalThis && {\n // TODO(burdon): Node only.\n file: process!.env?.LOG_CONFIG,\n filter: process!.env?.LOG_FILTER,\n processor: process!.env?.LOG_PROCESSOR,\n },\n );\n\n // TODO(burdon): Verbose option.\n // console.log(JSON.stringify(options, undefined, 2));\n options = defaultsDeep({}, loadOptions(options.file), options);\n return {\n options,\n filters: parseFilter(options.filter ?? LogLevel.INFO),\n processors: options.processor ? [processors[options.processor]] : DEFAULT_PROCESSORS,\n prefix: options.prefix,\n };\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport yaml from 'js-yaml';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { LogOptions } from '../../config';\n\n/**\n * Node config loader.\n */\nexport const loadOptions = (filepath?: string): LogOptions | undefined => {\n if (filepath) {\n const fullpath = path.join(process.cwd(), filepath);\n console.log(`Log file: ${fullpath}`);\n try {\n const text = fs.readFileSync(fullpath, 'utf-8');\n if (text) {\n return yaml.load(text) as LogOptions;\n }\n } catch (err) {\n console.warn(`Invalid log file: ${fullpath}`);\n }\n }\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport chalk from 'chalk';\nimport pickBy from 'lodash.pickby';\nimport { inspect } from 'node:util';\n\nimport { LogConfig, LogLevel, shortLevelName } from '../config';\nimport { getContextFromEntry, LogProcessor, shouldLog } from '../context';\n\nconst LEVEL_COLORS: Record<LogLevel, typeof chalk.ForegroundColor> = {\n [LogLevel.TRACE]: 'gray',\n [LogLevel.DEBUG]: 'gray',\n [LogLevel.INFO]: 'white',\n [LogLevel.WARN]: 'yellow',\n [LogLevel.ERROR]: 'red',\n};\n\nexport const truncate = (text?: string, length = 0, right = false) => {\n const str = text && length ? (right ? text.slice(-length) : text.substring(0, length)) : text ?? '';\n return right ? str.padStart(length, ' ') : str.padEnd(length, ' ');\n};\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\n// TODO(burdon): Optional timestamp.\n// TODO(burdon): Optional package name.\n// TODO(burdon): Show exceptions on one line.\nexport type FormatParts = {\n path?: string;\n line?: number;\n level: LogLevel;\n message: string;\n context?: any;\n error?: Error;\n};\n\nexport type Formatter = (config: LogConfig, parts: FormatParts) => (string | undefined)[];\n\nexport const DEFAULT_FORMATTER: Formatter = (config, { path, line, level, message, context, error }) => {\n const column = config.options?.formatter?.column;\n\n const filepath = path !== undefined && line !== undefined ? chalk.grey(`${path}:${line}`) : undefined;\n\n return [\n // NOTE: File path must come fist for console hyperlinks.\n // Must not truncate for terminal output.\n filepath,\n column && filepath ? ''.padStart(column - filepath.length) : undefined,\n chalk[LEVEL_COLORS[level]](column ? shortLevelName[level] : LogLevel[level]),\n message,\n context,\n error,\n ];\n};\n\nexport const SHORT_FORMATTER: Formatter = (config, { path, level, message }) => [\n chalk.grey(truncate(path, 16, true)), // NOTE: Breaks terminal linking.\n chalk[LEVEL_COLORS[level]](shortLevelName[level]),\n message,\n];\n\n// TODO(burdon): Config option.\nconst formatter = DEFAULT_FORMATTER;\n\nexport const CONSOLE_PROCESSOR: LogProcessor = (config, entry) => {\n const { level, message, meta, error } = entry;\n if (!shouldLog(entry, config.filters)) {\n return;\n }\n\n const parts: FormatParts = { level, message, error };\n\n if (meta) {\n parts.path = getRelativeFilename(meta.F);\n parts.line = meta.L;\n }\n\n const context = getContextFromEntry(entry);\n if (context) {\n // Remove undefined fields.\n // https://nodejs.org/api/util.html#utilinspectobject-options\n parts.context = inspect(\n pickBy(context, (value?: unknown) => value !== undefined),\n { depth: config.options.depth, colors: true, maxArrayLength: 8, sorted: false },\n );\n }\n\n const line = formatter(config, parts).filter(Boolean).join(' ');\n console.log(line);\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { inspect } from 'node:util';\n\nimport { LogProcessor } from '../context';\n\nexport const DEBUG_PROCESSOR: LogProcessor = (config, entry) => {\n console.log(inspect(entry, false, null, true));\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { LogLevel } from '../config';\nimport { getContextFromEntry, LogProcessor, 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 typeof mochaExecutor !== 'undefined'\n ? {\n useTestProcessor: true,\n printFileLinks: true,\n }\n : {\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 args.push(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 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 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\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 args.push(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 2023 DXOS.org\n//\n\nimport { appendFileSync, mkdirSync, openSync } from 'node:fs';\nimport { dirname } from 'node:path';\n\nimport { jsonify } from '@dxos/util';\n\nimport { LogLevel } from '../config';\nimport { LogProcessor, getContextFromEntry } from '../context';\n\nexport const createFileProcessor = ({ path, levels }: { path: string; levels: LogLevel[] }): LogProcessor => {\n let fd: number | undefined;\n\n return (config, entry) => {\n if (!levels.includes(entry.level)) {\n return;\n }\n if (!fd) {\n try {\n mkdirSync(dirname(path));\n } catch {}\n fd = openSync(path, 'w');\n }\n\n const record = {\n ...entry,\n timestamp: Date.now(),\n meta: {\n file: entry.meta?.F,\n line: entry.meta?.L,\n },\n context: jsonify(getContextFromEntry(entry)),\n };\n appendFileSync(fd, JSON.stringify(record) + '\\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 path: getLogFilePath(),\n levels: [LogLevel.ERROR, LogLevel.WARN, LogLevel.INFO, LogLevel.TRACE],\n});\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { LogConfig, LogLevel, LogOptions } from './config';\nimport { LogContext, LogProcessor } from './context';\nimport { CallMetadata } from './meta';\nimport { getConfig, DEFAULT_PROCESSORS } from './options';\n\n/**\n * Logging function.\n */\ntype LogFunction = (message: string, context?: LogContext, meta?: CallMetadata) => void;\n\n/**\n * Logging methods.\n */\ninterface LogMethods {\n trace: LogFunction;\n debug: LogFunction;\n info: LogFunction;\n warn: LogFunction;\n error: LogFunction;\n catch: (error: Error | any, context?: LogContext, meta?: CallMetadata) => void;\n break: () => void;\n}\n\n/**\n * Properties accessible on the logging function.\n */\ninterface Log extends LogMethods, LogFunction {\n config: (options: LogOptions) => void;\n addProcessor: (processor: LogProcessor) => void;\n runtimeConfig: LogConfig;\n}\n\ninterface LogImp extends Log {\n _config: LogConfig;\n}\n\nconst createLog = (): LogImp => {\n const log: LogImp = ((...params) => processLog(LogLevel.DEBUG, ...params)) as LogImp;\n\n log._config = getConfig();\n Object.defineProperty(log, 'runtimeConfig', { get: () => log._config });\n\n log.addProcessor = (processor: LogProcessor) => {\n if (DEFAULT_PROCESSORS.filter((p) => p === processor).length === 0) {\n DEFAULT_PROCESSORS.push(processor);\n }\n if (log._config.processors.filter((p) => p === processor).length === 0) {\n log._config.processors.push(processor);\n }\n };\n\n // Set config.\n log.config = (options: LogOptions) => {\n log._config = getConfig(options);\n };\n\n // TODO(burdon): API to set context and separate error object.\n // E.g., log.warn('failed', { key: 123 }, err);\n\n log.trace = (...params) => processLog(LogLevel.TRACE, ...params);\n log.debug = (...params) => processLog(LogLevel.DEBUG, ...params);\n log.info = (...params) => processLog(LogLevel.INFO, ...params);\n log.warn = (...params) => processLog(LogLevel.WARN, ...params);\n log.error = (...params) => processLog(LogLevel.ERROR, ...params);\n\n // Catch only shows error message, not stacktrace.\n log.catch = (error: Error | any, context, meta) => processLog(LogLevel.ERROR, error.stack, context, meta);\n\n // Show break.\n log.break = () => log.info('——————————————————————————————————————————————————');\n\n /**\n * Process the current log call.\n */\n const processLog = (\n level: LogLevel,\n message: string,\n context: LogContext = {},\n meta?: CallMetadata,\n error?: Error,\n ) => {\n log._config.processors.forEach((processor) => processor(log._config, { level, message, context, meta, error }));\n };\n\n return log;\n};\n\n/**\n * Global logging function.\n */\nexport const log: Log = ((globalThis as any).dx_log ??= createLog());\n\n/**\n * Accessible from browser console.\n */\ndeclare global {\n // eslint-disable-next-line camelcase\n const dx_log: Log;\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { CallMetadata } from './meta';\n\nexport type InvariantFn = (condition: unknown, message?: string, meta?: CallMetadata) => asserts condition;\n\n/**\n * Asserts that the condition is true.\n *\n * @param message Optional message.\n */\nexport const invariant: InvariantFn = (\n condition: unknown,\n message?: string,\n meta?: CallMetadata,\n): asserts condition => {\n if (condition) {\n return;\n }\n\n let errorMessage = 'invariant violation';\n\n if (message) {\n errorMessage += `: ${message}`;\n }\n\n if (meta?.A) {\n errorMessage += ` [${meta.A[0]}]`;\n }\n\n if (meta?.F) {\n errorMessage += ` at ${meta.F}:${meta.L}`;\n }\n\n throw new InvariantViolation(errorMessage);\n};\n\nexport class InvariantViolation extends Error {\n constructor(message: string) {\n super(message);\n // NOTE: Restores prototype chain (https://stackoverflow.com/a/48342359).\n Object.setPrototypeOf(this, new.target.prototype);\n }\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(public constr: any, public parent?: OwnershipScope) {}\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;;;;;;;;;;;;;;;;;;;;;;;;;;;ICUO;UAAKA,WAAQ;AAARA,EAAAA,UAAAA,UACVC,OAAAA,IAAQ,CAAA,IAARA;AADUD,EAAAA,UAAAA,UAEVE,OAAAA,IAAQ,EAAA,IAARA;AAFUF,EAAAA,UAAAA,UAGVG,MAAAA,IAAO,EAAA,IAAPA;AAHUH,EAAAA,UAAAA,UAIVI,MAAAA,IAAO,EAAA,IAAPA;AAJUJ,EAAAA,UAAAA,UAKVK,OAAAA,IAAQ,EAAA,IAARA;GALUL,aAAAA,WAAAA,CAAAA,EAAAA;AAQL,IAAMM,SAAwC;EACnDC,OAAOP,SAASC;EAChBO,OAAOR,SAASE;EAChBO,MAAMT,SAASG;EACfO,MAAMV,SAASI;EACfO,OAAOX,SAASK;AAClB;AAEO,IAAMO,iBAAiB;EAC5B,CAACZ,SAASC,KAAK,GAAG;EAClB,CAACD,SAASE,KAAK,GAAG;EAClB,CAACF,SAASG,IAAI,GAAG;EACjB,CAACH,SAASI,IA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AAM,IAAIC,mBAAmBJ,YAAAA;AAC/B;AAEO,IAAMI,qBAAN,cAAiCC,MAAAA;EACtCC,YAAYR,SAAiB;AAC3B,UAAMA,OAAAA;AAENS,WAAOC,eAAe,MAAM,WAAWC,SAAS;EAClD;AACF;;;ACzCA,IAAAC,oBAAwB;AAExB,IAAMC,kBAAkBC,OAAO,iBAAA;AAC/B,IAAMC,yBAAyBD,OAAO,wBAAA;AACtC,IAAME,uBAAuBF,OAAO,sBAAA;AAM7B,IAAMG,iBAAN,MAAMA;EAGXC,YAAmBC,QAAoBC,QAAyB;kBAA7CD;kBAAoBC;EAA0B;EAEjEC,UAAU;AAnBZ,QAAAC;AAoBI,QAAI,CAAC,KAAKC,UAAU;AAClB,aAAO,CAAC;IACV;AACA,UAAMC,SAAQF,MAAA,KAAKH,OAAOM,UAAUT,oBAAAA,MAAtB,OAAAM,MAA+C,CAAA;AAC7D,UAAMI,OAAY,CAAC;AACnB,eAAWC,QAAQH,OAAO;AACxBE,WAAKC,IAAAA,IAAQ,KAAKJ,SAASI,IAAAA;IAC7B;AACA,WAAOD;EACT;EAEA,CAACE,0BAAQC,MAAM,IAAI;AACjB,WAAO;MACLC,WAAW,KAAKX,OAAOY;MACvBL,MAAM,KAAKL,QAAO;MAClBD,QAAQ,KAAKA;IACf;EACF;AACF;AA+CO,IAAMY,2BAA2B,CAACC,YAAiBA;",
6
- "names": ["LogLevel", "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "levels", "trace", "debug", "info", "warn", "error", "shortLevelName", "LogProcessorType", "CONSOLE", "BROWSER", "logInfoProperties", "Symbol", "logInfo", "target", "propertyKey", "descriptor", "_a", "push", "gatherLogInfoFromScope", "scope", "res", "prototype", "Object", "getPrototypeOf", "infoProps", "prop", "err", "message", "matchFilter", "filter", "level", "path", "pattern", "includes", "shouldLog", "entry", "filters", "undefined", "some", "_a", "meta", "F", "getContextFromEntry", "context", "scopeInfo", "gatherLogInfoFromScope", "S", "Object", "keys", "length", "assign", "Error", "c", "error", "stack", "import_lodash", "loadOptions", "filepath", "fullpath", "path", "join", "process", "cwd", "console", "log", "text", "fs", "readFileSync", "yaml", "load", "err", "warn", "LEVEL_COLORS", "LogLevel", "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "truncate", "text", "length", "right", "str", "slice", "substring", "padStart", "padEnd", "getRelativeFilename", "filename", "match", "filePath", "DEFAULT_FORMATTER", "config", "path", "line", "level", "message", "context", "error", "_a", "column", "options", "formatter", "filepath", "undefined", "chalk", "grey", "shortLevelName", "SHORT_FORMATTER", "CONSOLE_PROCESSOR", "entry", "meta", "shouldLog", "filters", "parts", "F", "L", "getContextFromEntry", "inspect", "pickBy", "value", "depth", "colors", "maxArrayLength", "sorted", "filter", "Boolean", "join", "console", "log", "import_node_util", "DEBUG_PROCESSOR", "config", "entry", "console", "log", "inspect", "getRelativeFilename", "filename", "match", "filePath", "CONFIG", "mochaExecutor", "useTestProcessor", "printFileLinks", "APP_BROWSER_PROCESSOR", "config", "entry", "_a", "shouldLog", "filters", "LOG_BROWSER_PREFIX", "prefix", "LOG_BROWSER_CSS", "link", "meta", "F", "filepath", "replace", "L", "args", "push", "message", "context", "getContextFromEntry", "levels", "LogLevel", "ERROR", "console", "error", "WARN", "warn", "DEBUG", "log", "length", "join", "level", "C", "TEST_BROWSER_PROCESSOR", "path", "BROWSER_PROCESSOR", "import_node_fs", "import_node_path", "createFileProcessor", "path", "levels", "fd", "config", "entry", "_a", "includes", "level", "mkdirSync", "dirname", "openSync", "record", "timestamp", "Date", "now", "meta", "file", "F", "line", "L", "context", "jsonify", "getContextFromEntry", "appendFileSync", "JSON", "stringify", "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", "IS_BROWSER", "window", "navigator", "DEFAULT_PROCESSORS", "parseFilter", "filter", "level", "parseLogLevel", "defValue", "LogLevel", "WARN", "_a", "levels", "toLowerCase", "lines", "split", "map", "pattern", "getConfig", "_options", "options", "defaultsDeep", "globalThis", "file", "process", "env", "LOG_CONFIG", "LOG_FILTER", "processor", "LOG_PROCESSOR", "loadOptions", "filters", "INFO", "prefix", "createLog", "log", "params", "processLog", "LogLevel", "DEBUG", "_config", "getConfig", "Object", "defineProperty", "get", "addProcessor", "processor", "DEFAULT_PROCESSORS", "filter", "p", "length", "push", "processors", "config", "options", "trace", "TRACE", "debug", "info", "INFO", "warn", "WARN", "error", "ERROR", "catch", "context", "meta", "stack", "break", "level", "message", "forEach", "globalThis", "dx_log", "invariant", "condition", "message", "meta", "errorMessage", "A", "F", "L", "InvariantViolation", "Error", "constructor", "Object", "setPrototypeOf", "prototype", "import_node_util", "kOwnershipScope", "Symbol", "kCurrentOwnershipScope", "kDebugInfoProperties", "OwnershipScope", "constructor", "constr", "parent", "getInfo", "_a", "instance", "props", "prototype", "info", "prop", "inspect", "custom", "className", "name", "getCurrentOwnershipScope", "thisRef"]
3
+ "sources": ["../../../src/index.ts", "../../../src/config.ts", "../../../src/scope.ts", "../../../src/context.ts", "../../../src/options.ts", "../../../src/platform/node/index.ts", "../../../src/processors/console-processor.ts", "../../../src/processors/debug-processor.ts", "../../../src/processors/browser-processor.ts", "../../../src/processors/file-processor.ts", "../../../src/log.ts", "../../../src/experimental/ownership.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nexport * from './config';\nexport * from './context';\nexport * from './log';\nexport { parseFilter } from './options';\nexport * from './processors';\nexport * from './scope';\nexport * from './meta';\n\nexport { getCurrentOwnershipScope } from './experimental/ownership';\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { LogProcessor } from './context';\n\n/**\n * Standard levels.\n */\n// NOTE: Keep aligned with LogLevel in @dxos/protocols.\nexport enum LogLevel {\n TRACE = 5,\n DEBUG = 10,\n INFO = 11,\n WARN = 12,\n ERROR = 13,\n}\n\nexport const levels: { [index: string]: LogLevel } = {\n trace: LogLevel.TRACE,\n debug: LogLevel.DEBUG,\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.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 depth?: number; // Context object depth.\n processor?: string | LogProcessorType;\n formatter?: {\n column: number;\n };\n prefix?: string;\n};\n\n/**\n * Runtime config.\n */\nexport interface LogConfig {\n options: LogOptions;\n filters?: LogFilter[];\n processors: LogProcessor[];\n prefix?: string;\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 = 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 { LogConfig, LogFilter, LogLevel } from './config';\nimport { CallMetadata } from './meta';\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 * Record for current log line.\n */\nexport interface LogEntry {\n level: LogLevel;\n message: string;\n context?: LogContext;\n meta?: CallMetadata;\n error?: Error;\n}\n\n/**\n * Processes (e.g., prints, forwards) log entries.\n */\nexport type LogProcessor = (config: LogConfig, entry: LogEntry) => void;\n\nconst matchFilter = (filter: LogFilter, level: LogLevel, path: string) => {\n return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));\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 true;\n } else {\n return filters.some((filter) => matchFilter(filter, entry.level, entry.meta?.F ?? ''));\n }\n};\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 if (entry.context) {\n if (entry.context instanceof Error) {\n // Additional context from Error.\n const c = (entry.context as any).context;\n // If ERROR then show stacktrace.\n context = Object.assign(context ?? {}, { error: entry.context.stack, ...c });\n } else if (typeof entry.context === 'object') {\n context = Object.assign(context ?? {}, entry.context);\n }\n }\n\n return context && Object.keys(context).length > 0 ? context : undefined;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport defaultsDeep from 'lodash.defaultsdeep';\n\nimport { LogConfig, LogFilter, LogLevel, LogOptions, LogProcessorType, levels } from './config';\nimport { LogProcessor } from './context';\nimport { loadOptions } from './platform';\nimport { CONSOLE_PROCESSOR, DEBUG_PROCESSOR, BROWSER_PROCESSOR } from './processors';\n\n/**\n * Processor variants.\n */\nexport const processors: { [index: string]: LogProcessor } = {\n [LogProcessorType.CONSOLE]: CONSOLE_PROCESSOR,\n [LogProcessorType.BROWSER]: BROWSER_PROCESSOR,\n [LogProcessorType.DEBUG]: DEBUG_PROCESSOR,\n};\n\nconst IS_BROWSER = typeof window !== 'undefined' || typeof navigator !== 'undefined';\n\nexport const DEFAULT_PROCESSORS = [IS_BROWSER ? BROWSER_PROCESSOR : CONSOLE_PROCESSOR];\n\nexport const parseFilter = (filter: string | string[] | LogLevel): LogFilter[] => {\n if (typeof filter === 'number') {\n return [{ level: filter }];\n }\n\n const parseLogLevel = (level: string, defValue = LogLevel.WARN) => levels[level.toLowerCase()] ?? defValue;\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 ? { level: parseLogLevel(level), pattern } : { level: parseLogLevel(pattern) };\n });\n};\n\nexport const getConfig = (_options?: LogOptions): LogConfig => {\n let options: LogOptions = defaultsDeep(\n {},\n _options,\n 'process' in globalThis && {\n // TODO(burdon): Node only.\n file: process!.env?.LOG_CONFIG,\n filter: process!.env?.LOG_FILTER,\n processor: process!.env?.LOG_PROCESSOR,\n },\n );\n\n // TODO(burdon): Verbose option.\n // console.log(JSON.stringify(options, undefined, 2));\n options = defaultsDeep({}, loadOptions(options.file), options);\n return {\n options,\n filters: parseFilter(options.filter ?? LogLevel.INFO),\n processors: options.processor ? [processors[options.processor]] : DEFAULT_PROCESSORS,\n prefix: options.prefix,\n };\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport yaml from 'js-yaml';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { LogOptions } from '../../config';\n\n/**\n * Node config loader.\n */\nexport const loadOptions = (filepath?: string): LogOptions | undefined => {\n if (filepath) {\n const fullpath = path.join(process.cwd(), filepath);\n console.log(`Log file: ${fullpath}`);\n try {\n const text = fs.readFileSync(fullpath, 'utf-8');\n if (text) {\n return yaml.load(text) as LogOptions;\n }\n } catch (err) {\n console.warn(`Invalid log file: ${fullpath}`);\n }\n }\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport chalk from 'chalk';\nimport pickBy from 'lodash.pickby';\nimport { inspect } from 'node:util';\n\nimport { getPrototypeSpecificInstanceId } from '@dxos/util';\n\nimport { LogConfig, LogLevel, shortLevelName } from '../config';\nimport { getContextFromEntry, LogProcessor, shouldLog } from '../context';\n\nconst LEVEL_COLORS: Record<LogLevel, typeof chalk.ForegroundColor> = {\n [LogLevel.TRACE]: 'gray',\n [LogLevel.DEBUG]: 'gray',\n [LogLevel.INFO]: 'white',\n [LogLevel.WARN]: 'yellow',\n [LogLevel.ERROR]: 'red',\n};\n\nexport const truncate = (text?: string, length = 0, right = false) => {\n const str = text && length ? (right ? text.slice(-length) : text.substring(0, length)) : text ?? '';\n return right ? str.padStart(length, ' ') : str.padEnd(length, ' ');\n};\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\n// TODO(burdon): Optional timestamp.\n// TODO(burdon): Optional package name.\n// TODO(burdon): Show exceptions on one line.\nexport type FormatParts = {\n path?: string;\n line?: number;\n level: LogLevel;\n message: string;\n context?: any;\n error?: Error;\n scope?: any;\n};\n\nexport type Formatter = (config: LogConfig, parts: FormatParts) => (string | undefined)[];\n\nexport const DEFAULT_FORMATTER: Formatter = (config, { path, line, level, message, context, error, scope }) => {\n const column = config.options?.formatter?.column;\n\n const filepath = path !== undefined && line !== undefined ? chalk.grey(`${path}:${line}`) : undefined;\n\n let instance;\n if (scope) {\n const prototype = Object.getPrototypeOf(scope);\n const id = getPrototypeSpecificInstanceId(scope);\n instance = chalk.magentaBright(`${prototype.constructor.name}#${id}`);\n }\n\n return [\n // NOTE: File path must come fist for console hyperlinks.\n // Must not truncate for terminal output.\n filepath,\n column && filepath ? ''.padStart(column - filepath.length) : undefined,\n chalk[LEVEL_COLORS[level]](column ? shortLevelName[level] : LogLevel[level]),\n instance,\n message,\n context,\n error,\n ];\n};\n\nexport const SHORT_FORMATTER: Formatter = (config, { path, level, message }) => [\n chalk.grey(truncate(path, 16, true)), // NOTE: Breaks terminal linking.\n chalk[LEVEL_COLORS[level]](shortLevelName[level]),\n message,\n];\n\n// TODO(burdon): Config option.\nconst formatter = DEFAULT_FORMATTER;\n\nexport const CONSOLE_PROCESSOR: LogProcessor = (config, entry) => {\n const { level, message, meta, error } = entry;\n if (!shouldLog(entry, config.filters)) {\n return;\n }\n\n const parts: FormatParts = { level, message, error };\n\n if (meta) {\n parts.path = getRelativeFilename(meta.F);\n parts.line = meta.L;\n parts.scope = meta.S;\n }\n\n const context = getContextFromEntry(entry);\n if (context) {\n // Remove undefined fields.\n // https://nodejs.org/api/util.html#utilinspectobject-options\n parts.context = inspect(\n pickBy(context, (value?: unknown) => value !== undefined),\n { depth: config.options.depth, colors: true, maxArrayLength: 8, sorted: false },\n );\n }\n\n const line = formatter(config, parts).filter(Boolean).join(' ');\n console.log(line);\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { inspect } from 'node:util';\n\nimport { LogProcessor } from '../context';\n\nexport const DEBUG_PROCESSOR: LogProcessor = (config, entry) => {\n console.log(inspect(entry, false, null, true));\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { LogLevel } from '../config';\nimport { getContextFromEntry, LogProcessor, 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 typeof mochaExecutor !== 'undefined'\n ? {\n useTestProcessor: true,\n printFileLinks: true,\n }\n : {\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 args.push(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 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 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\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 args.push(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 2023 DXOS.org\n//\n\nimport { appendFileSync, mkdirSync, openSync } from 'node:fs';\nimport { dirname } from 'node:path';\n\nimport { jsonify } from '@dxos/util';\n\nimport { LogLevel } from '../config';\nimport { LogProcessor, getContextFromEntry } from '../context';\n\nexport const createFileProcessor = ({ path, levels }: { path: string; levels: LogLevel[] }): LogProcessor => {\n let fd: number | undefined;\n\n return (config, entry) => {\n if (!levels.includes(entry.level)) {\n return;\n }\n if (!fd) {\n try {\n mkdirSync(dirname(path));\n } catch {}\n fd = openSync(path, 'w');\n }\n\n const record = {\n ...entry,\n timestamp: Date.now(),\n meta: {\n file: entry.meta?.F,\n line: entry.meta?.L,\n },\n context: jsonify(getContextFromEntry(entry)),\n };\n appendFileSync(fd, JSON.stringify(record) + '\\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 path: getLogFilePath(),\n levels: [LogLevel.ERROR, LogLevel.WARN, LogLevel.INFO, LogLevel.TRACE],\n});\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { LogConfig, LogLevel, LogOptions } from './config';\nimport { LogContext, LogProcessor } from './context';\nimport { CallMetadata } from './meta';\nimport { getConfig, DEFAULT_PROCESSORS } from './options';\n\n/**\n * Logging function.\n */\ntype LogFunction = (message: string, context?: LogContext, meta?: CallMetadata) => void;\n\n/**\n * Logging methods.\n */\ninterface LogMethods {\n trace: LogFunction;\n debug: LogFunction;\n info: LogFunction;\n warn: LogFunction;\n error: LogFunction;\n catch: (error: Error | any, context?: LogContext, meta?: CallMetadata) => void;\n break: () => void;\n}\n\n/**\n * Properties accessible on the logging function.\n */\ninterface Log extends LogMethods, LogFunction {\n config: (options: LogOptions) => void;\n addProcessor: (processor: LogProcessor) => void;\n runtimeConfig: LogConfig;\n}\n\ninterface LogImp extends Log {\n _config: LogConfig;\n}\n\nconst createLog = (): LogImp => {\n const log: LogImp = ((...params) => processLog(LogLevel.DEBUG, ...params)) as LogImp;\n\n log._config = getConfig();\n Object.defineProperty(log, 'runtimeConfig', { get: () => log._config });\n\n log.addProcessor = (processor: LogProcessor) => {\n if (DEFAULT_PROCESSORS.filter((p) => p === processor).length === 0) {\n DEFAULT_PROCESSORS.push(processor);\n }\n if (log._config.processors.filter((p) => p === processor).length === 0) {\n log._config.processors.push(processor);\n }\n };\n\n // Set config.\n log.config = (options: LogOptions) => {\n log._config = getConfig(options);\n };\n\n // TODO(burdon): API to set context and separate error object.\n // E.g., log.warn('failed', { key: 123 }, err);\n\n log.trace = (...params) => processLog(LogLevel.TRACE, ...params);\n log.debug = (...params) => processLog(LogLevel.DEBUG, ...params);\n log.info = (...params) => processLog(LogLevel.INFO, ...params);\n log.warn = (...params) => processLog(LogLevel.WARN, ...params);\n log.error = (...params) => processLog(LogLevel.ERROR, ...params);\n\n // Catch only shows error message, not stacktrace.\n log.catch = (error: Error | any, context, meta) => processLog(LogLevel.ERROR, error.stack, context, meta);\n\n // Show break.\n log.break = () => log.info('——————————————————————————————————————————————————');\n\n /**\n * Process the current log call.\n */\n const processLog = (\n level: LogLevel,\n message: string,\n context: LogContext = {},\n meta?: CallMetadata,\n error?: Error,\n ) => {\n log._config.processors.forEach((processor) => processor(log._config, { level, message, context, meta, error }));\n };\n\n return log;\n};\n\n/**\n * Global logging function.\n */\nexport const log: Log = ((globalThis as any).dx_log ??= createLog());\n\n/**\n * Accessible from browser console.\n */\ndeclare global {\n // eslint-disable-next-line camelcase\n const dx_log: Log;\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(public constr: any, public parent?: OwnershipScope) {}\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;;;;;;;;;;;;;;;;;;;;;;;;;ICUO;UAAKA,WAAQ;AAARA,EAAAA,UAAAA,UACVC,OAAAA,IAAQ,CAAA,IAARA;AADUD,EAAAA,UAAAA,UAEVE,OAAAA,IAAQ,EAAA,IAARA;AAFUF,EAAAA,UAAAA,UAGVG,MAAAA,IAAO,EAAA,IAAPA;AAHUH,EAAAA,UAAAA,UAIVI,MAAAA,IAAO,EAAA,IAAPA;AAJUJ,EAAAA,UAAAA,UAKVK,OAAAA,IAAQ,EAAA,IAARA;GALUL,aAAAA,WAAAA,CAAAA,EAAAA;AAQL,IAAMM,SAAwC;EACnDC,OAAOP,SAASC;EAChBO,OAAOR,SAASE;EAChBO,MAAMT,SAASG;EACfO,MAAMV,SAASI;EACfO,OAAOX,SAASK;AAClB;AAEO,IAAMO,iBAAiB;EAC5B,CAACZ,SAASC,KAAK,GAAG;EAClB,CAACD,SAASE,KAAK,GAAG;EAClB,CAACF,SAASG,IAAI,GAAG;EACjB,CAACH,SAASI,IAAI,GAAG;EACjB,CAACJ,SAASK,KAAK,GAAG;AACpB;IAEO;UAAKQ,mBAAgB;AAAhBA,EAAAA,kBACVC,SAAAA,IAAU;AADAD,EAAAA,kBAEVE,SAAAA,IAAU;AAFAF,EAAAA,kB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FO", "WARN", "ERROR", "levels", "trace", "debug", "info", "warn", "error", "shortLevelName", "LogProcessorType", "CONSOLE", "BROWSER", "logInfoProperties", "Symbol", "logInfo", "target", "propertyKey", "descriptor", "push", "gatherLogInfoFromScope", "scope", "res", "prototype", "Object", "getPrototypeOf", "infoProps", "prop", "err", "message", "matchFilter", "filter", "level", "path", "pattern", "includes", "shouldLog", "entry", "filters", "undefined", "some", "meta", "F", "getContextFromEntry", "context", "scopeInfo", "gatherLogInfoFromScope", "S", "Object", "keys", "length", "assign", "Error", "c", "error", "stack", "import_lodash", "loadOptions", "filepath", "fullpath", "path", "join", "process", "cwd", "console", "log", "text", "fs", "readFileSync", "yaml", "load", "err", "warn", "LEVEL_COLORS", "LogLevel", "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "truncate", "text", "length", "right", "str", "slice", "substring", "padStart", "padEnd", "getRelativeFilename", "filename", "match", "filePath", "DEFAULT_FORMATTER", "config", "path", "line", "level", "message", "context", "error", "scope", "column", "options", "formatter", "filepath", "undefined", "chalk", "grey", "instance", "prototype", "Object", "getPrototypeOf", "id", "getPrototypeSpecificInstanceId", "magentaBright", "constructor", "name", "shortLevelName", "SHORT_FORMATTER", "CONSOLE_PROCESSOR", "entry", "meta", "shouldLog", "filters", "parts", "F", "L", "S", "getContextFromEntry", "inspect", "pickBy", "value", "depth", "colors", "maxArrayLength", "sorted", "filter", "Boolean", "join", "console", "log", "import_node_util", "DEBUG_PROCESSOR", "config", "entry", "console", "log", "inspect", "getRelativeFilename", "filename", "match", "filePath", "CONFIG", "mochaExecutor", "useTestProcessor", "printFileLinks", "APP_BROWSER_PROCESSOR", "config", "entry", "shouldLog", "filters", "LOG_BROWSER_PREFIX", "prefix", "LOG_BROWSER_CSS", "link", "meta", "F", "filepath", "replace", "L", "args", "push", "message", "context", "getContextFromEntry", "levels", "LogLevel", "ERROR", "console", "error", "WARN", "warn", "DEBUG", "log", "length", "join", "level", "C", "TEST_BROWSER_PROCESSOR", "path", "BROWSER_PROCESSOR", "import_node_fs", "import_node_path", "import_util", "createFileProcessor", "path", "levels", "fd", "config", "entry", "includes", "level", "mkdirSync", "dirname", "openSync", "record", "timestamp", "Date", "now", "meta", "file", "F", "line", "L", "context", "jsonify", "getContextFromEntry", "appendFileSync", "JSON", "stringify", "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", "IS_BROWSER", "window", "navigator", "DEFAULT_PROCESSORS", "parseFilter", "filter", "level", "parseLogLevel", "defValue", "LogLevel", "WARN", "levels", "toLowerCase", "lines", "split", "map", "pattern", "getConfig", "_options", "options", "defaultsDeep", "globalThis", "file", "process", "env", "LOG_CONFIG", "LOG_FILTER", "processor", "LOG_PROCESSOR", "loadOptions", "filters", "INFO", "prefix", "createLog", "log", "params", "processLog", "LogLevel", "DEBUG", "_config", "getConfig", "Object", "defineProperty", "get", "addProcessor", "processor", "DEFAULT_PROCESSORS", "filter", "p", "length", "push", "processors", "config", "options", "trace", "TRACE", "debug", "info", "INFO", "warn", "WARN", "error", "ERROR", "catch", "context", "meta", "stack", "break", "level", "message", "forEach", "globalThis", "dx_log", "import_node_util", "kOwnershipScope", "Symbol", "kCurrentOwnershipScope", "kDebugInfoProperties", "OwnershipScope", "constructor", "constr", "parent", "getInfo", "instance", "props", "prototype", "info", "prop", "inspect", "custom", "className", "name", "getCurrentOwnershipScope", "thisRef"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/common/log/src/config.ts":{"bytes":3974,"imports":[]},"packages/common/log/src/scope.ts":{"bytes":3852,"imports":[]},"packages/common/log/src/context.ts":{"bytes":5914,"imports":[{"path":"packages/common/log/src/scope.ts","kind":"import-statement","original":"./scope"}]},"packages/common/log/src/platform/node/index.ts":{"bytes":2459,"imports":[{"path":"js-yaml","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}]},"packages/common/log/src/platform/index.ts":{"bytes":460,"imports":[{"path":"packages/common/log/src/platform/node/index.ts","kind":"import-statement","original":"./node"}]},"packages/common/log/src/processors/console-processor.ts":{"bytes":10985,"imports":[{"path":"chalk","kind":"import-statement","external":true},{"path":"lodash.pickby","kind":"import-statement","external":true},{"path":"node:util","kind":"import-statement","external":true},{"path":"packages/common/log/src/config.ts","kind":"import-statement","original":"../config"},{"path":"packages/common/log/src/context.ts","kind":"import-statement","original":"../context"}]},"packages/common/log/src/processors/debug-processor.ts":{"bytes":1066,"imports":[{"path":"node:util","kind":"import-statement","external":true}]},"packages/common/log/src/processors/browser-processor.ts":{"bytes":12682,"imports":[{"path":"packages/common/log/src/config.ts","kind":"import-statement","original":"../config"},{"path":"packages/common/log/src/context.ts","kind":"import-statement","original":"../context"}]},"packages/common/log/src/processors/file-processor.ts":{"bytes":5318,"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":"packages/common/log/src/config.ts","kind":"import-statement","original":"../config"},{"path":"packages/common/log/src/context.ts","kind":"import-statement","original":"../context"}]},"packages/common/log/src/processors/index.ts":{"bytes":817,"imports":[{"path":"packages/common/log/src/processors/console-processor.ts","kind":"import-statement","original":"./console-processor"},{"path":"packages/common/log/src/processors/debug-processor.ts","kind":"import-statement","original":"./debug-processor"},{"path":"packages/common/log/src/processors/browser-processor.ts","kind":"import-statement","original":"./browser-processor"},{"path":"packages/common/log/src/processors/file-processor.ts","kind":"import-statement","original":"./file-processor"}]},"packages/common/log/src/options.ts":{"bytes":7349,"imports":[{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"packages/common/log/src/config.ts","kind":"import-statement","original":"./config"},{"path":"packages/common/log/src/platform/index.ts","kind":"import-statement","original":"./platform"},{"path":"packages/common/log/src/processors/index.ts","kind":"import-statement","original":"./processors"}]},"packages/common/log/src/log.ts":{"bytes":8730,"imports":[{"path":"packages/common/log/src/config.ts","kind":"import-statement","original":"./config"},{"path":"packages/common/log/src/options.ts","kind":"import-statement","original":"./options"}]},"packages/common/log/src/invariant.ts":{"bytes":3304,"imports":[]},"packages/common/log/src/meta.ts":{"bytes":1625,"imports":[]},"packages/common/log/src/experimental/ownership.ts":{"bytes":9246,"imports":[{"path":"node:util","kind":"import-statement","external":true}]},"packages/common/log/src/index.ts":{"bytes":1353,"imports":[{"path":"packages/common/log/src/config.ts","kind":"import-statement","original":"./config"},{"path":"packages/common/log/src/context.ts","kind":"import-statement","original":"./context"},{"path":"packages/common/log/src/log.ts","kind":"import-statement","original":"./log"},{"path":"packages/common/log/src/options.ts","kind":"import-statement","original":"./options"},{"path":"packages/common/log/src/processors/index.ts","kind":"import-statement","original":"./processors"},{"path":"packages/common/log/src/scope.ts","kind":"import-statement","original":"./scope"},{"path":"packages/common/log/src/invariant.ts","kind":"import-statement","original":"./invariant"},{"path":"packages/common/log/src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"packages/common/log/src/experimental/ownership.ts","kind":"import-statement","original":"./experimental/ownership"}]}},"outputs":{"packages/common/log/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":37937},"packages/common/log/dist/lib/node/index.cjs":{"imports":[{"path":"lodash.defaultsdeep","kind":"require-call","external":true},{"path":"js-yaml","kind":"require-call","external":true},{"path":"node:fs","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"chalk","kind":"require-call","external":true},{"path":"lodash.pickby","kind":"require-call","external":true},{"path":"node:util","kind":"require-call","external":true},{"path":"node:util","kind":"require-call","external":true},{"path":"node:fs","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"@dxos/util","kind":"require-call","external":true},{"path":"node:util","kind":"require-call","external":true}],"exports":[],"entryPoint":"packages/common/log/src/index.ts","inputs":{"packages/common/log/src/index.ts":{"bytesInOutput":921},"packages/common/log/src/config.ts":{"bytesInOutput":821},"packages/common/log/src/scope.ts":{"bytesInOutput":662},"packages/common/log/src/context.ts":{"bytesInOutput":1124},"packages/common/log/src/options.ts":{"bytesInOutput":1668},"packages/common/log/src/platform/node/index.ts":{"bytesInOutput":572},"packages/common/log/src/platform/index.ts":{"bytesInOutput":0},"packages/common/log/src/processors/console-processor.ts":{"bytesInOutput":2347},"packages/common/log/src/processors/index.ts":{"bytesInOutput":0},"packages/common/log/src/processors/debug-processor.ts":{"bytesInOutput":165},"packages/common/log/src/processors/browser-processor.ts":{"bytesInOutput":2513},"packages/common/log/src/processors/file-processor.ts":{"bytesInOutput":1306},"packages/common/log/src/log.ts":{"bytesInOutput":1690},"packages/common/log/src/invariant.ts":{"bytesInOutput":561},"packages/common/log/src/experimental/ownership.ts":{"bytesInOutput":830}},"bytes":17718}}}
1
+ {"inputs":{"packages/common/log/src/config.ts":{"bytes":3974,"imports":[],"format":"esm"},"packages/common/log/src/scope.ts":{"bytes":3852,"imports":[],"format":"esm"},"packages/common/log/src/context.ts":{"bytes":5914,"imports":[{"path":"packages/common/log/src/scope.ts","kind":"import-statement","original":"./scope"}],"format":"esm"},"packages/common/log/src/platform/node/index.ts":{"bytes":2459,"imports":[{"path":"js-yaml","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"packages/common/log/src/platform/index.ts":{"bytes":460,"imports":[{"path":"packages/common/log/src/platform/node/index.ts","kind":"import-statement","original":"./node"}],"format":"esm"},"packages/common/log/src/processors/console-processor.ts":{"bytes":12371,"imports":[{"path":"chalk","kind":"import-statement","external":true},{"path":"lodash.pickby","kind":"import-statement","external":true},{"path":"node:util","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/common/log/src/config.ts","kind":"import-statement","original":"../config"},{"path":"packages/common/log/src/context.ts","kind":"import-statement","original":"../context"}],"format":"esm"},"packages/common/log/src/processors/debug-processor.ts":{"bytes":1066,"imports":[{"path":"node:util","kind":"import-statement","external":true}],"format":"esm"},"packages/common/log/src/processors/browser-processor.ts":{"bytes":12682,"imports":[{"path":"packages/common/log/src/config.ts","kind":"import-statement","original":"../config"},{"path":"packages/common/log/src/context.ts","kind":"import-statement","original":"../context"}],"format":"esm"},"packages/common/log/src/processors/file-processor.ts":{"bytes":5318,"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":"packages/common/log/src/config.ts","kind":"import-statement","original":"../config"},{"path":"packages/common/log/src/context.ts","kind":"import-statement","original":"../context"}],"format":"esm"},"packages/common/log/src/processors/index.ts":{"bytes":817,"imports":[{"path":"packages/common/log/src/processors/console-processor.ts","kind":"import-statement","original":"./console-processor"},{"path":"packages/common/log/src/processors/debug-processor.ts","kind":"import-statement","original":"./debug-processor"},{"path":"packages/common/log/src/processors/browser-processor.ts","kind":"import-statement","original":"./browser-processor"},{"path":"packages/common/log/src/processors/file-processor.ts","kind":"import-statement","original":"./file-processor"}],"format":"esm"},"packages/common/log/src/options.ts":{"bytes":7349,"imports":[{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"packages/common/log/src/config.ts","kind":"import-statement","original":"./config"},{"path":"packages/common/log/src/platform/index.ts","kind":"import-statement","original":"./platform"},{"path":"packages/common/log/src/processors/index.ts","kind":"import-statement","original":"./processors"}],"format":"esm"},"packages/common/log/src/log.ts":{"bytes":8730,"imports":[{"path":"packages/common/log/src/config.ts","kind":"import-statement","original":"./config"},{"path":"packages/common/log/src/options.ts","kind":"import-statement","original":"./options"}],"format":"esm"},"packages/common/log/src/meta.ts":{"bytes":1625,"imports":[],"format":"esm"},"packages/common/log/src/experimental/ownership.ts":{"bytes":9246,"imports":[{"path":"node:util","kind":"import-statement","external":true}],"format":"esm"},"packages/common/log/src/index.ts":{"bytes":1264,"imports":[{"path":"packages/common/log/src/config.ts","kind":"import-statement","original":"./config"},{"path":"packages/common/log/src/context.ts","kind":"import-statement","original":"./context"},{"path":"packages/common/log/src/log.ts","kind":"import-statement","original":"./log"},{"path":"packages/common/log/src/options.ts","kind":"import-statement","original":"./options"},{"path":"packages/common/log/src/processors/index.ts","kind":"import-statement","original":"./processors"},{"path":"packages/common/log/src/scope.ts","kind":"import-statement","original":"./scope"},{"path":"packages/common/log/src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"packages/common/log/src/experimental/ownership.ts","kind":"import-statement","original":"./experimental/ownership"}],"format":"esm"}},"outputs":{"packages/common/log/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":36572},"packages/common/log/dist/lib/node/index.cjs":{"imports":[{"path":"lodash.defaultsdeep","kind":"require-call","external":true},{"path":"js-yaml","kind":"require-call","external":true},{"path":"node:fs","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"chalk","kind":"require-call","external":true},{"path":"lodash.pickby","kind":"require-call","external":true},{"path":"node:util","kind":"require-call","external":true},{"path":"@dxos/util","kind":"require-call","external":true},{"path":"node:util","kind":"require-call","external":true},{"path":"node:fs","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"@dxos/util","kind":"require-call","external":true},{"path":"node:util","kind":"require-call","external":true}],"exports":[],"entryPoint":"packages/common/log/src/index.ts","inputs":{"packages/common/log/src/index.ts":{"bytesInOutput":843},"packages/common/log/src/config.ts":{"bytesInOutput":821},"packages/common/log/src/scope.ts":{"bytesInOutput":571},"packages/common/log/src/context.ts":{"bytesInOutput":983},"packages/common/log/src/options.ts":{"bytesInOutput":1488},"packages/common/log/src/platform/node/index.ts":{"bytesInOutput":572},"packages/common/log/src/platform/index.ts":{"bytesInOutput":0},"packages/common/log/src/processors/console-processor.ts":{"bytesInOutput":2596},"packages/common/log/src/processors/index.ts":{"bytesInOutput":0},"packages/common/log/src/processors/debug-processor.ts":{"bytesInOutput":165},"packages/common/log/src/processors/browser-processor.ts":{"bytesInOutput":2324},"packages/common/log/src/processors/file-processor.ts":{"bytesInOutput":1183},"packages/common/log/src/log.ts":{"bytesInOutput":1644},"packages/common/log/src/experimental/ownership.ts":{"bytesInOutput":796}},"bytes":16448}}}
@@ -4,7 +4,6 @@ export * from './log';
4
4
  export { parseFilter } from './options';
5
5
  export * from './processors';
6
6
  export * from './scope';
7
- export * from './invariant';
8
7
  export * from './meta';
9
8
  export { getCurrentOwnershipScope } from './experimental/ownership';
10
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,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,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AAEvB,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,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,cAAc,QAAQ,CAAC;AAEvB,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -8,6 +8,7 @@ export type FormatParts = {
8
8
  message: string;
9
9
  context?: any;
10
10
  error?: Error;
11
+ scope?: any;
11
12
  };
12
13
  export type Formatter = (config: LogConfig, parts: FormatParts) => (string | undefined)[];
13
14
  export declare const DEFAULT_FORMATTER: Formatter;
@@ -1 +1 @@
1
- {"version":3,"file":"console-processor.d.ts","sourceRoot":"","sources":["../../../../src/processors/console-processor.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAkB,MAAM,WAAW,CAAC;AAChE,OAAO,EAAuB,YAAY,EAAa,MAAM,YAAY,CAAC;AAU1E,eAAO,MAAM,QAAQ,UAAW,MAAM,6CAGrC,CAAC;AAiBF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,QAAQ,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;AAE1F,eAAO,MAAM,iBAAiB,EAAE,SAe/B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,SAI7B,CAAC;AAKF,eAAO,MAAM,iBAAiB,EAAE,YAyB/B,CAAC"}
1
+ {"version":3,"file":"console-processor.d.ts","sourceRoot":"","sources":["../../../../src/processors/console-processor.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAkB,MAAM,WAAW,CAAC;AAChE,OAAO,EAAuB,YAAY,EAAa,MAAM,YAAY,CAAC;AAU1E,eAAO,MAAM,QAAQ,UAAW,MAAM,6CAGrC,CAAC;AAiBF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,QAAQ,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,KAAK,CAAC,EAAE,GAAG,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;AAE1F,eAAO,MAAM,iBAAiB,EAAE,SAuB/B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,SAI7B,CAAC;AAKF,eAAO,MAAM,iBAAiB,EAAE,YA0B/B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/log",
3
- "version": "0.1.56-main.f3d4052",
3
+ "version": "0.1.56-next.a63ce79",
4
4
  "description": "Logger",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -22,8 +22,8 @@
22
22
  "js-yaml": "^4.1.0",
23
23
  "lodash.defaultsdeep": "^4.6.1",
24
24
  "lodash.pickby": "^4.6.0",
25
- "@dxos/node-std": "0.1.56-main.f3d4052",
26
- "@dxos/util": "0.1.56-main.f3d4052"
25
+ "@dxos/node-std": "0.1.56-next.a63ce79",
26
+ "@dxos/util": "0.1.56-next.a63ce79"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@swc-node/sourcemap-support": "^0.2.0",
package/src/index.ts CHANGED
@@ -8,7 +8,6 @@ export * from './log';
8
8
  export { parseFilter } from './options';
9
9
  export * from './processors';
10
10
  export * from './scope';
11
- export * from './invariant';
12
11
  export * from './meta';
13
12
 
14
13
  export { getCurrentOwnershipScope } from './experimental/ownership';
@@ -6,6 +6,8 @@ import chalk from 'chalk';
6
6
  import pickBy from 'lodash.pickby';
7
7
  import { inspect } from 'node:util';
8
8
 
9
+ import { getPrototypeSpecificInstanceId } from '@dxos/util';
10
+
9
11
  import { LogConfig, LogLevel, shortLevelName } from '../config';
10
12
  import { getContextFromEntry, LogProcessor, shouldLog } from '../context';
11
13
 
@@ -44,21 +46,30 @@ export type FormatParts = {
44
46
  message: string;
45
47
  context?: any;
46
48
  error?: Error;
49
+ scope?: any;
47
50
  };
48
51
 
49
52
  export type Formatter = (config: LogConfig, parts: FormatParts) => (string | undefined)[];
50
53
 
51
- export const DEFAULT_FORMATTER: Formatter = (config, { path, line, level, message, context, error }) => {
54
+ export const DEFAULT_FORMATTER: Formatter = (config, { path, line, level, message, context, error, scope }) => {
52
55
  const column = config.options?.formatter?.column;
53
56
 
54
57
  const filepath = path !== undefined && line !== undefined ? chalk.grey(`${path}:${line}`) : undefined;
55
58
 
59
+ let instance;
60
+ if (scope) {
61
+ const prototype = Object.getPrototypeOf(scope);
62
+ const id = getPrototypeSpecificInstanceId(scope);
63
+ instance = chalk.magentaBright(`${prototype.constructor.name}#${id}`);
64
+ }
65
+
56
66
  return [
57
67
  // NOTE: File path must come fist for console hyperlinks.
58
68
  // Must not truncate for terminal output.
59
69
  filepath,
60
70
  column && filepath ? ''.padStart(column - filepath.length) : undefined,
61
71
  chalk[LEVEL_COLORS[level]](column ? shortLevelName[level] : LogLevel[level]),
72
+ instance,
62
73
  message,
63
74
  context,
64
75
  error,
@@ -85,6 +96,7 @@ export const CONSOLE_PROCESSOR: LogProcessor = (config, entry) => {
85
96
  if (meta) {
86
97
  parts.path = getRelativeFilename(meta.F);
87
98
  parts.line = meta.L;
99
+ parts.scope = meta.S;
88
100
  }
89
101
 
90
102
  const context = getContextFromEntry(entry);
@@ -1,12 +0,0 @@
1
- import { CallMetadata } from './meta';
2
- export type InvariantFn = (condition: unknown, message?: string, meta?: CallMetadata) => asserts condition;
3
- /**
4
- * Asserts that the condition is true.
5
- *
6
- * @param message Optional message.
7
- */
8
- export declare const invariant: InvariantFn;
9
- export declare class InvariantViolation extends Error {
10
- constructor(message: string);
11
- }
12
- //# sourceMappingURL=invariant.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"invariant.d.ts","sourceRoot":"","sources":["../../../src/invariant.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,MAAM,WAAW,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,SAAS,CAAC;AAE3G;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,WAwBvB,CAAC;AAEF,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAK5B"}
package/src/invariant.ts DELETED
@@ -1,46 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { CallMetadata } from './meta';
6
-
7
- export type InvariantFn = (condition: unknown, message?: string, meta?: CallMetadata) => asserts condition;
8
-
9
- /**
10
- * Asserts that the condition is true.
11
- *
12
- * @param message Optional message.
13
- */
14
- export const invariant: InvariantFn = (
15
- condition: unknown,
16
- message?: string,
17
- meta?: CallMetadata,
18
- ): asserts condition => {
19
- if (condition) {
20
- return;
21
- }
22
-
23
- let errorMessage = 'invariant violation';
24
-
25
- if (message) {
26
- errorMessage += `: ${message}`;
27
- }
28
-
29
- if (meta?.A) {
30
- errorMessage += ` [${meta.A[0]}]`;
31
- }
32
-
33
- if (meta?.F) {
34
- errorMessage += ` at ${meta.F}:${meta.L}`;
35
- }
36
-
37
- throw new InvariantViolation(errorMessage);
38
- };
39
-
40
- export class InvariantViolation extends Error {
41
- constructor(message: string) {
42
- super(message);
43
- // NOTE: Restores prototype chain (https://stackoverflow.com/a/48342359).
44
- Object.setPrototypeOf(this, new.target.prototype);
45
- }
46
- }