@dxos/log 0.8.3 → 0.8.4-main.1068cf700f

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.
Files changed (74) hide show
  1. package/dist/lib/browser/chunk-GPOFUMLO.mjs +133 -0
  2. package/dist/lib/browser/chunk-GPOFUMLO.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-IEP6GGEX.mjs +23 -0
  4. package/dist/lib/browser/chunk-IEP6GGEX.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +159 -188
  6. package/dist/lib/browser/index.mjs.map +4 -4
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/browser/platform/browser/index.mjs +26 -0
  9. package/dist/lib/browser/platform/browser/index.mjs.map +7 -0
  10. package/dist/lib/browser/platform/node/index.mjs +21 -0
  11. package/dist/lib/browser/platform/node/index.mjs.map +7 -0
  12. package/dist/lib/browser/processors/console-processor.mjs +107 -0
  13. package/dist/lib/browser/processors/console-processor.mjs.map +7 -0
  14. package/dist/lib/browser/processors/console-stub.mjs +9 -0
  15. package/dist/lib/browser/processors/console-stub.mjs.map +7 -0
  16. package/dist/lib/node-esm/chunk-2SZHAWBN.mjs +24 -0
  17. package/dist/lib/node-esm/chunk-2SZHAWBN.mjs.map +7 -0
  18. package/dist/lib/node-esm/chunk-QPYJZ4SO.mjs +135 -0
  19. package/dist/lib/node-esm/chunk-QPYJZ4SO.mjs.map +7 -0
  20. package/dist/lib/node-esm/index.mjs +156 -270
  21. package/dist/lib/node-esm/index.mjs.map +4 -4
  22. package/dist/lib/node-esm/meta.json +1 -1
  23. package/dist/lib/node-esm/platform/browser/index.mjs +27 -0
  24. package/dist/lib/node-esm/platform/browser/index.mjs.map +7 -0
  25. package/dist/lib/node-esm/platform/node/index.mjs +22 -0
  26. package/dist/lib/node-esm/platform/node/index.mjs.map +7 -0
  27. package/dist/lib/node-esm/processors/console-processor.mjs +108 -0
  28. package/dist/lib/node-esm/processors/console-processor.mjs.map +7 -0
  29. package/dist/lib/node-esm/processors/console-stub.mjs +10 -0
  30. package/dist/lib/node-esm/processors/console-stub.mjs.map +7 -0
  31. package/dist/types/src/config.d.ts +2 -3
  32. package/dist/types/src/config.d.ts.map +1 -1
  33. package/dist/types/src/context.d.ts +1 -1
  34. package/dist/types/src/context.d.ts.map +1 -1
  35. package/dist/types/src/dbg.d.ts +23 -0
  36. package/dist/types/src/dbg.d.ts.map +1 -0
  37. package/dist/types/src/decorators.d.ts +1 -1
  38. package/dist/types/src/decorators.d.ts.map +1 -1
  39. package/dist/types/src/index.d.ts +2 -1
  40. package/dist/types/src/index.d.ts.map +1 -1
  41. package/dist/types/src/log.d.ts +12 -18
  42. package/dist/types/src/log.d.ts.map +1 -1
  43. package/dist/types/src/options.d.ts +1 -6
  44. package/dist/types/src/options.d.ts.map +1 -1
  45. package/dist/types/src/platform/index.d.ts +1 -1
  46. package/dist/types/src/platform/index.d.ts.map +1 -1
  47. package/dist/types/src/platform/node/index.d.ts.map +1 -1
  48. package/dist/types/src/processors/browser-processor.d.ts.map +1 -1
  49. package/dist/types/src/processors/console-processor.d.ts +1 -1
  50. package/dist/types/src/processors/console-processor.d.ts.map +1 -1
  51. package/dist/types/src/processors/file-processor.d.ts.map +1 -1
  52. package/dist/types/src/processors/index.d.ts +3 -3
  53. package/dist/types/src/processors/index.d.ts.map +1 -1
  54. package/dist/types/tsconfig.tsbuildinfo +1 -1
  55. package/package.json +31 -11
  56. package/src/config.ts +3 -2
  57. package/src/context.ts +38 -8
  58. package/src/dbg.ts +35 -0
  59. package/src/decorators.ts +5 -4
  60. package/src/experimental/classes.test.ts +2 -1
  61. package/src/index.ts +2 -1
  62. package/src/log.test.ts +59 -23
  63. package/src/log.ts +102 -59
  64. package/src/options.ts +27 -11
  65. package/src/platform/index.ts +1 -1
  66. package/src/platform/node/index.ts +2 -1
  67. package/src/processors/browser-processor.ts +6 -2
  68. package/src/processors/console-processor.ts +11 -7
  69. package/src/processors/file-processor.ts +4 -1
  70. package/src/processors/index.ts +3 -3
  71. package/src/scope.ts +1 -1
  72. package/dist/lib/node/index.cjs +0 -695
  73. package/dist/lib/node/index.cjs.map +0 -7
  74. package/dist/lib/node/meta.json +0 -1
@@ -1,106 +1,50 @@
1
- // packages/common/log/src/index.ts
1
+ import {
2
+ LogLevel,
3
+ LogProcessorType,
4
+ gatherLogInfoFromScope,
5
+ getContextFromEntry,
6
+ getRelativeFilename,
7
+ levels,
8
+ logInfo,
9
+ shortLevelName,
10
+ shouldLog
11
+ } from "./chunk-GPOFUMLO.mjs";
12
+ import {
13
+ __export,
14
+ __reExport
15
+ } from "./chunk-IEP6GGEX.mjs";
16
+
17
+ // src/index.ts
18
+ var index_exports = {};
19
+ __export(index_exports, {
20
+ BROWSER_PROCESSOR: () => BROWSER_PROCESSOR,
21
+ DEBUG_PROCESSOR: () => DEBUG_PROCESSOR,
22
+ FILE_PROCESSOR: () => FILE_PROCESSOR,
23
+ LogLevel: () => LogLevel,
24
+ LogProcessorType: () => LogProcessorType,
25
+ createFileProcessor: () => createFileProcessor,
26
+ createLog: () => createLog,
27
+ dbg: () => dbg,
28
+ debug: () => debug,
29
+ gatherLogInfoFromScope: () => gatherLogInfoFromScope,
30
+ getContextFromEntry: () => getContextFromEntry,
31
+ getCurrentOwnershipScope: () => getCurrentOwnershipScope,
32
+ getRelativeFilename: () => getRelativeFilename,
33
+ levels: () => levels,
34
+ log: () => log,
35
+ logInfo: () => logInfo,
36
+ omit: () => omit,
37
+ parseFilter: () => parseFilter,
38
+ pick: () => pick,
39
+ shortLevelName: () => shortLevelName,
40
+ shouldLog: () => shouldLog
41
+ });
2
42
  import omit from "lodash.omit";
3
43
  import { pick } from "@dxos/util";
4
44
 
5
- // packages/common/log/src/config.ts
6
- var LogLevel = /* @__PURE__ */ function(LogLevel2) {
7
- LogLevel2[LogLevel2["TRACE"] = 5] = "TRACE";
8
- LogLevel2[LogLevel2["DEBUG"] = 10] = "DEBUG";
9
- LogLevel2[LogLevel2["VERBOSE"] = 11] = "VERBOSE";
10
- LogLevel2[LogLevel2["INFO"] = 12] = "INFO";
11
- LogLevel2[LogLevel2["WARN"] = 13] = "WARN";
12
- LogLevel2[LogLevel2["ERROR"] = 14] = "ERROR";
13
- return LogLevel2;
14
- }({});
15
- var levels = {
16
- trace: 5,
17
- debug: 10,
18
- verbose: 11,
19
- info: 12,
20
- warn: 13,
21
- error: 14
22
- };
23
- var shortLevelName = {
24
- [5]: "T",
25
- [10]: "D",
26
- [11]: "V",
27
- [12]: "I",
28
- [13]: "W",
29
- [14]: "E"
30
- };
31
- var LogProcessorType = /* @__PURE__ */ function(LogProcessorType2) {
32
- LogProcessorType2["CONSOLE"] = "console";
33
- LogProcessorType2["BROWSER"] = "browser";
34
- LogProcessorType2["DEBUG"] = "debug";
35
- return LogProcessorType2;
36
- }({});
37
-
38
- // packages/common/log/src/scope.ts
39
- var logInfoProperties = Symbol("logInfoProperties");
40
- var logInfo = (target, propertyKey, descriptor) => {
41
- (target[logInfoProperties] ??= []).push(propertyKey);
42
- };
43
- var gatherLogInfoFromScope = (scope) => {
44
- if (!scope) {
45
- return {};
46
- }
47
- const res = {};
48
- const prototype = Object.getPrototypeOf(scope);
49
- const infoProps = prototype[logInfoProperties] ?? [];
50
- for (const prop of infoProps) {
51
- try {
52
- res[prop] = typeof scope[prop] === "function" ? scope[prop]() : scope[prop];
53
- } catch (err) {
54
- res[prop] = err.message;
55
- }
56
- }
57
- return res;
58
- };
59
-
60
- // packages/common/log/src/context.ts
61
- var matchFilter = (filter, level, path) => {
62
- return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
63
- };
64
- var shouldLog = (entry, filters) => {
65
- if (filters === void 0) {
66
- return true;
67
- } else {
68
- return filters.some((filter) => matchFilter(filter, entry.level, entry.meta?.F ?? ""));
69
- }
70
- };
71
- var getContextFromEntry = (entry) => {
72
- let context;
73
- if (entry.meta) {
74
- const scopeInfo = gatherLogInfoFromScope(entry.meta.S);
75
- if (Object.keys(scopeInfo).length > 0) {
76
- context = Object.assign(context ?? {}, scopeInfo);
77
- }
78
- }
79
- const entryContext = typeof entry.context === "function" ? entry.context() : entry.context;
80
- if (entryContext) {
81
- if (entryContext instanceof Error) {
82
- const c = entryContext.context;
83
- context = Object.assign(context ?? {}, {
84
- error: entryContext.stack,
85
- ...c
86
- });
87
- } else if (typeof entryContext === "object") {
88
- context = Object.assign(context ?? {}, entryContext);
89
- }
90
- }
91
- if (entry.error) {
92
- const errorContext = entry.error.context;
93
- context = Object.assign(context ?? {}, {
94
- error: entry.error,
95
- ...errorContext
96
- });
97
- }
98
- return context && Object.keys(context).length > 0 ? context : void 0;
99
- };
100
-
101
- // packages/common/log/src/decorators.ts
102
- import chalk from "chalk";
45
+ // src/decorators.ts
103
46
  import { inspect } from "@dxos/node-std/util";
47
+ import chalk from "chalk";
104
48
  var nextPromiseId = 0;
105
49
  var createMethodLogDecorator = (log2) => (arg0, arg1, meta) => (target, propertyKey, descriptor) => {
106
50
  const method = descriptor.value;
@@ -197,53 +141,37 @@ var logAsyncResolved = (log2, methodName, resolvedValue, promiseId, startTime, c
197
141
  var logAsyncRejected = (log2, methodName, err, promiseId, startTime, combinedMeta) => {
198
142
  log2.info(`.${formatFunction(methodName)} \u21B2 \u{1F525} ${chalk.gray("reject")} ${formatPromise(promiseId)} ${formatTimeElapsed(startTime)} ${chalk.gray("=>")} ${err}`, {}, combinedMeta);
199
143
  };
200
- var greenCheck = typeof chalk.green === "function" ? chalk.green("\u2714") : "\u2714";
201
- var formatTimeElapsed = (startTime) => chalk.gray(`${(performance.now() - startTime).toFixed(0)}ms`);
202
144
  var COLOR_FUNCTION = [
203
145
  220,
204
146
  220,
205
147
  170
206
148
  ];
149
+ var greenCheck = typeof chalk.green === "function" ? chalk.green("\u2714") : "\u2714";
150
+ var formatTimeElapsed = (startTime) => chalk.gray(`${(performance.now() - startTime).toFixed(0)}ms`);
207
151
  var formatFunction = (name) => chalk.bold(chalk.rgb(...COLOR_FUNCTION)(name));
208
152
  var formatPromise = (id) => chalk.blue(`Promise#${id}`);
209
153
 
210
- // packages/common/log/src/options.ts
154
+ // src/options.ts
211
155
  import defaultsDeep from "lodash.defaultsdeep";
212
156
 
213
- // packages/common/log/src/platform/browser/index.ts
214
- var loadOptions = (filepath) => {
215
- try {
216
- let dxlog;
217
- if (typeof localStorage === "undefined") {
218
- if (globalThis.localStorage_dxlog) {
219
- dxlog = globalThis.localStorage_dxlog;
220
- }
221
- } else {
222
- dxlog = localStorage.getItem("dxlog") ?? void 0;
223
- }
224
- if (!dxlog) {
225
- return void 0;
226
- }
227
- return JSON.parse(dxlog);
228
- } catch (err) {
229
- console.info("can't parse dxlog config", err);
230
- return void 0;
231
- }
232
- };
233
-
234
- // packages/common/log/src/processors/console-stub.ts
235
- var CONSOLE_PROCESSOR = () => {
236
- };
157
+ // src/platform/index.ts
158
+ var platform_exports = {};
159
+ __reExport(platform_exports, platform_star);
160
+ import * as platform_star from "#platform";
237
161
 
238
- // packages/common/log/src/processors/debug-processor.ts
239
- import { inspect as inspect2 } from "@dxos/node-std/util";
240
- var DEBUG_PROCESSOR = (config, entry) => {
241
- console.log(inspect2(entry, false, null, true));
242
- };
162
+ // src/processors/index.ts
163
+ var processors_exports = {};
164
+ __export(processors_exports, {
165
+ BROWSER_PROCESSOR: () => BROWSER_PROCESSOR,
166
+ DEBUG_PROCESSOR: () => DEBUG_PROCESSOR,
167
+ FILE_PROCESSOR: () => FILE_PROCESSOR,
168
+ createFileProcessor: () => createFileProcessor,
169
+ getRelativeFilename: () => getRelativeFilename
170
+ });
243
171
 
244
- // packages/common/log/src/processors/browser-processor.ts
172
+ // src/processors/browser-processor.ts
245
173
  import { getDebugName, safariCheck } from "@dxos/util";
246
- var getRelativeFilename = (filename) => {
174
+ var getRelativeFilename2 = (filename) => {
247
175
  const match = filename.match(/.+\/(packages\/.+\/.+)/);
248
176
  if (match) {
249
177
  const [, filePath] = match;
@@ -263,7 +191,7 @@ var APP_BROWSER_PROCESSOR = (config, entry) => {
263
191
  const LOG_BROWSER_CSS = [];
264
192
  let link = "";
265
193
  if (entry.meta) {
266
- const filename = getRelativeFilename(entry.meta.F);
194
+ const filename = getRelativeFilename2(entry.meta.F);
267
195
  const filepath = `${LOG_BROWSER_PREFIX.replace(/\/$/, "")}/${filename}`;
268
196
  link = `${filepath}#L${entry.meta.L}`;
269
197
  }
@@ -274,11 +202,15 @@ var APP_BROWSER_PROCESSOR = (config, entry) => {
274
202
  const processPrefix = entry.meta.S?.hostSessionId ? "[worker] " : "";
275
203
  args.push(`%c${processPrefix}${scopeName}`, "color:#C026D3;font-weight:bold");
276
204
  }
277
- args.push(entry.message);
205
+ if (entry.message) {
206
+ args.push(entry.message);
207
+ }
278
208
  const context = getContextFromEntry(entry);
279
209
  if (context) {
280
210
  if (Object.keys(context).length === 1 && "error" in context) {
281
211
  args.push(context.error);
212
+ } else if (Object.keys(context).length === 1 && "err" in context) {
213
+ args.push(context.err);
282
214
  } else {
283
215
  args.push(context);
284
216
  }
@@ -315,7 +247,7 @@ var TEST_BROWSER_PROCESSOR = (config, entry) => {
315
247
  }
316
248
  let path = "";
317
249
  if (entry.meta) {
318
- path = `${getRelativeFilename(entry.meta.F)}:${entry.meta.L}`;
250
+ path = `${getRelativeFilename2(entry.meta.F)}:${entry.meta.L}`;
319
251
  }
320
252
  let args = [];
321
253
  const processPrefix = entry.meta?.S?.hostSessionId ? "[worker] " : "";
@@ -344,22 +276,20 @@ var TEST_BROWSER_PROCESSOR = (config, entry) => {
344
276
  };
345
277
  var BROWSER_PROCESSOR = CONFIG.useTestProcessor ? TEST_BROWSER_PROCESSOR : APP_BROWSER_PROCESSOR;
346
278
 
347
- // packages/common/log/src/processors/file-processor.ts
348
- import { appendFileSync, mkdirSync, openSync } from "@dxos/node-std/fs";
349
- import { dirname } from "@dxos/node-std/path";
350
- import { jsonlogify } from "@dxos/util";
279
+ // src/processors/index.ts
280
+ __reExport(processors_exports, console_processor_star);
281
+ import * as console_processor_star from "#console-processor";
351
282
 
352
- // packages/common/log/src/processors/common.ts
353
- var getRelativeFilename2 = (filename) => {
354
- const match = filename.match(/.+\/(packages\/.+\/.+)/);
355
- if (match) {
356
- const [, filePath] = match;
357
- return filePath;
358
- }
359
- return filename;
283
+ // src/processors/debug-processor.ts
284
+ import { inspect as inspect2 } from "@dxos/node-std/util";
285
+ var DEBUG_PROCESSOR = (config, entry) => {
286
+ console.log(inspect2(entry, false, null, true));
360
287
  };
361
288
 
362
- // packages/common/log/src/processors/file-processor.ts
289
+ // src/processors/file-processor.ts
290
+ import { appendFileSync, mkdirSync, openSync } from "@dxos/node-std/fs";
291
+ import { dirname } from "@dxos/node-std/path";
292
+ import { jsonlogify } from "@dxos/util";
363
293
  var EAGAIN_MAX_DURATION = 1e3;
364
294
  var createFileProcessor = ({ pathOrFd, levels: levels2, filters }) => {
365
295
  let fd;
@@ -384,7 +314,7 @@ var createFileProcessor = ({ pathOrFd, levels: levels2, filters }) => {
384
314
  timestamp: Date.now(),
385
315
  ...entry.meta ? {
386
316
  meta: {
387
- file: getRelativeFilename2(entry.meta.F),
317
+ file: getRelativeFilename(entry.meta.F),
388
318
  line: entry.meta.L
389
319
  }
390
320
  } : {},
@@ -425,16 +355,17 @@ var FILE_PROCESSOR = createFileProcessor({
425
355
  ]
426
356
  });
427
357
 
428
- // packages/common/log/src/options.ts
358
+ // src/options.ts
429
359
  var processors = {
430
- [LogProcessorType.CONSOLE]: CONSOLE_PROCESSOR,
360
+ [LogProcessorType.CONSOLE]: processors_exports.CONSOLE_PROCESSOR,
431
361
  [LogProcessorType.BROWSER]: BROWSER_PROCESSOR,
432
362
  [LogProcessorType.DEBUG]: DEBUG_PROCESSOR
433
363
  };
434
- var IS_BROWSER = typeof window !== "undefined" || typeof navigator !== "undefined";
364
+ var browser = (typeof window !== "undefined" || typeof navigator !== "undefined") && !(typeof process !== "undefined" && process?.env?.VITEST);
435
365
  var DEFAULT_PROCESSORS = [
436
- IS_BROWSER ? BROWSER_PROCESSOR : CONSOLE_PROCESSOR
366
+ browser ? BROWSER_PROCESSOR : processors_exports.CONSOLE_PROCESSOR
437
367
  ];
368
+ var parseLogLevel = (level, defValue = LogLevel.WARN) => levels[level.toLowerCase()] ?? defValue;
438
369
  var parseFilter = (filter) => {
439
370
  if (typeof filter === "number") {
440
371
  return [
@@ -443,7 +374,6 @@ var parseFilter = (filter) => {
443
374
  }
444
375
  ];
445
376
  }
446
- const parseLogLevel = (level, defValue = LogLevel.WARN) => levels[level.toLowerCase()] ?? defValue;
447
377
  const lines = typeof filter === "string" ? filter.split(/,\s*/) : filter;
448
378
  return lines.map((filter2) => {
449
379
  const [pattern, level] = filter2.split(":");
@@ -455,54 +385,37 @@ var parseFilter = (filter) => {
455
385
  };
456
386
  });
457
387
  };
458
- var getConfig = (options) => {
459
- const nodeOptions = "process" in globalThis ? {
388
+ var createConfig = (options) => {
389
+ const envOptions = "process" in globalThis ? {
460
390
  file: process.env.LOG_CONFIG,
461
391
  filter: process.env.LOG_FILTER,
462
392
  processor: process.env.LOG_PROCESSOR
463
393
  } : void 0;
464
- const mergedOptions = defaultsDeep({}, loadOptions(nodeOptions?.file), nodeOptions, options);
394
+ const mergedOptions = defaultsDeep({}, (0, platform_exports.loadOptions)(envOptions?.file), envOptions, options);
465
395
  return {
466
396
  options: mergedOptions,
467
397
  filters: parseFilter(mergedOptions.filter ?? LogLevel.INFO),
468
398
  captureFilters: parseFilter(mergedOptions.captureFilter ?? LogLevel.WARN),
469
399
  processors: mergedOptions.processor ? [
470
400
  processors[mergedOptions.processor]
471
- ] : DEFAULT_PROCESSORS,
401
+ ] : [
402
+ ...DEFAULT_PROCESSORS
403
+ ],
472
404
  prefix: mergedOptions.prefix
473
405
  };
474
406
  };
475
407
 
476
- // packages/common/log/src/log.ts
408
+ // src/log.ts
409
+ var logCount = 0;
477
410
  var createLog = () => {
478
411
  const log2 = (...params) => processLog(LogLevel.DEBUG, ...params);
479
- log2._config = getConfig();
412
+ Object.assign(log2, {
413
+ _id: `log-${++logCount}`,
414
+ _config: createConfig()
415
+ });
480
416
  Object.defineProperty(log2, "runtimeConfig", {
481
417
  get: () => log2._config
482
418
  });
483
- log2.addProcessor = (processor) => {
484
- if (DEFAULT_PROCESSORS.filter((p) => p === processor).length === 0) {
485
- DEFAULT_PROCESSORS.push(processor);
486
- }
487
- if (log2._config.processors.filter((p) => p === processor).length === 0) {
488
- log2._config.processors.push(processor);
489
- }
490
- };
491
- log2.config = (options) => {
492
- log2._config = getConfig(options);
493
- };
494
- log2.trace = (...params) => processLog(LogLevel.TRACE, ...params);
495
- log2.debug = (...params) => processLog(LogLevel.DEBUG, ...params);
496
- log2.verbose = (...params) => processLog(LogLevel.VERBOSE, ...params);
497
- log2.info = (...params) => processLog(LogLevel.INFO, ...params);
498
- log2.warn = (...params) => processLog(LogLevel.WARN, ...params);
499
- log2.error = (...params) => processLog(LogLevel.ERROR, ...params);
500
- log2.catch = (error, context, meta) => processLog(LogLevel.ERROR, error?.message ?? String(error), context, meta, error);
501
- log2.break = () => log2.info("\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014");
502
- log2.stack = (message, context, meta) => processLog(LogLevel.INFO, `${message ?? "Stack Dump"}
503
- ${getFormattedStackTrace()}`, context, meta);
504
- log2.method = createMethodLogDecorator(log2);
505
- log2.func = createFunctionLogDecorator(log2);
506
419
  const processLog = (level, message, context = {}, meta, error) => {
507
420
  log2._config.processors.forEach((processor) => processor(log2._config, {
508
421
  level,
@@ -512,9 +425,50 @@ ${getFormattedStackTrace()}`, context, meta);
512
425
  error
513
426
  }));
514
427
  };
428
+ Object.assign(log2, {
429
+ /**
430
+ * Update config.
431
+ * NOTE: Preserves any processors that were already added to this logger instance
432
+ * unless an explicit processor option is provided.
433
+ */
434
+ config: ({ processor, ...options }) => {
435
+ const config = createConfig(options);
436
+ const processors2 = processor ? config.processors : log2._config.processors;
437
+ log2._config = {
438
+ ...config,
439
+ processors: processors2
440
+ };
441
+ return log2;
442
+ },
443
+ /**
444
+ * Adds a processor to the logger.
445
+ */
446
+ addProcessor: (processor) => {
447
+ if (log2._config.processors.filter((p) => p === processor).length === 0) {
448
+ log2._config.processors.push(processor);
449
+ }
450
+ return () => {
451
+ log2._config.processors = log2._config.processors.filter((p) => p !== processor);
452
+ };
453
+ },
454
+ trace: (...params) => processLog(LogLevel.TRACE, ...params),
455
+ debug: (...params) => processLog(LogLevel.DEBUG, ...params),
456
+ verbose: (...params) => processLog(LogLevel.VERBOSE, ...params),
457
+ info: (...params) => processLog(LogLevel.INFO, ...params),
458
+ warn: (...params) => processLog(LogLevel.WARN, ...params),
459
+ error: (...params) => processLog(LogLevel.ERROR, ...params),
460
+ catch: (error, context, meta) => processLog(LogLevel.ERROR, void 0, context, meta, error),
461
+ method: createMethodLogDecorator(log2),
462
+ function: createFunctionLogDecorator(log2),
463
+ break: () => log2.info("-".repeat(80)),
464
+ stack: (message, context, meta) => {
465
+ return processLog(LogLevel.INFO, `${message ?? "Stack Dump"}
466
+ ${getFormattedStackTrace()}`, context, meta);
467
+ }
468
+ });
515
469
  return log2;
516
470
  };
517
- var log = globalThis.dx_log ??= createLog();
471
+ var log = globalThis.DX_LOG ??= createLog();
518
472
  var start = Date.now();
519
473
  var last = start;
520
474
  var debug = (label, args) => {
@@ -531,12 +485,28 @@ var debug = (label, args) => {
531
485
  };
532
486
  var getFormattedStackTrace = () => new Error().stack.split("\n").slice(3).join("\n");
533
487
 
534
- // packages/common/log/src/experimental/ownership.ts
488
+ // src/index.ts
489
+ __reExport(index_exports, processors_exports);
490
+
491
+ // src/dbg.ts
492
+ var dbg = (arg, meta) => {
493
+ if (meta?.A) {
494
+ console.log(`${meta.A[0]} =`, arg);
495
+ } else {
496
+ console.log(arg);
497
+ }
498
+ return arg;
499
+ };
500
+
501
+ // src/experimental/ownership.ts
535
502
  import { inspect as inspect3 } from "@dxos/node-std/util";
536
503
  var kOwnershipScope = Symbol("kOwnershipScope");
537
504
  var kCurrentOwnershipScope = Symbol("kCurrentOwnershipScope");
538
505
  var kDebugInfoProperties = Symbol("kDebugInfoProperties");
539
506
  var OwnershipScope = class {
507
+ constr;
508
+ parent;
509
+ instance;
540
510
  constructor(constr, parent) {
541
511
  this.constr = constr;
542
512
  this.parent = parent;
@@ -563,17 +533,18 @@ var OwnershipScope = class {
563
533
  var getCurrentOwnershipScope = (thisRef) => thisRef;
564
534
  export {
565
535
  BROWSER_PROCESSOR,
566
- CONSOLE_PROCESSOR,
567
536
  DEBUG_PROCESSOR,
568
537
  FILE_PROCESSOR,
569
538
  LogLevel,
570
539
  LogProcessorType,
571
540
  createFileProcessor,
541
+ createLog,
542
+ dbg,
572
543
  debug,
573
544
  gatherLogInfoFromScope,
574
545
  getContextFromEntry,
575
546
  getCurrentOwnershipScope,
576
- getRelativeFilename2 as getRelativeFilename,
547
+ getRelativeFilename,
577
548
  levels,
578
549
  log,
579
550
  logInfo,