@dxos/log 0.8.4-main.1f223c7 → 0.8.4-main.21d9917

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 (56) 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 +141 -201
  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 +137 -284
  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.map +1 -1
  32. package/dist/types/src/context.d.ts.map +1 -1
  33. package/dist/types/src/decorators.d.ts +1 -1
  34. package/dist/types/src/decorators.d.ts.map +1 -1
  35. package/dist/types/src/log.d.ts +12 -18
  36. package/dist/types/src/log.d.ts.map +1 -1
  37. package/dist/types/src/options.d.ts +1 -6
  38. package/dist/types/src/options.d.ts.map +1 -1
  39. package/dist/types/src/platform/index.d.ts +1 -1
  40. package/dist/types/src/platform/index.d.ts.map +1 -1
  41. package/dist/types/src/processors/browser-processor.d.ts.map +1 -1
  42. package/dist/types/src/processors/file-processor.d.ts.map +1 -1
  43. package/dist/types/src/processors/index.d.ts +3 -3
  44. package/dist/types/src/processors/index.d.ts.map +1 -1
  45. package/dist/types/tsconfig.tsbuildinfo +1 -1
  46. package/package.json +29 -9
  47. package/src/config.ts +1 -0
  48. package/src/context.ts +36 -5
  49. package/src/decorators.ts +3 -3
  50. package/src/log.test.ts +48 -18
  51. package/src/log.ts +101 -57
  52. package/src/options.ts +26 -10
  53. package/src/platform/index.ts +1 -1
  54. package/src/processors/browser-processor.ts +2 -0
  55. package/src/processors/file-processor.ts +2 -0
  56. package/src/processors/index.ts +3 -3
@@ -1,104 +1,47 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+ import {
3
+ LogLevel,
4
+ LogProcessorType,
5
+ gatherLogInfoFromScope,
6
+ getContextFromEntry,
7
+ getRelativeFilename,
8
+ levels,
9
+ logInfo,
10
+ shortLevelName,
11
+ shouldLog
12
+ } from "./chunk-QPYJZ4SO.mjs";
13
+ import {
14
+ __export,
15
+ __reExport
16
+ } from "./chunk-2SZHAWBN.mjs";
2
17
 
3
18
  // src/index.ts
19
+ var index_exports = {};
20
+ __export(index_exports, {
21
+ BROWSER_PROCESSOR: () => BROWSER_PROCESSOR,
22
+ DEBUG_PROCESSOR: () => DEBUG_PROCESSOR,
23
+ FILE_PROCESSOR: () => FILE_PROCESSOR,
24
+ LogLevel: () => LogLevel,
25
+ LogProcessorType: () => LogProcessorType,
26
+ createFileProcessor: () => createFileProcessor,
27
+ createLog: () => createLog,
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
+ });
4
42
  import omit from "lodash.omit";
5
43
  import { pick } from "@dxos/util";
6
44
 
7
- // src/config.ts
8
- var LogLevel = /* @__PURE__ */ function(LogLevel2) {
9
- LogLevel2[LogLevel2["TRACE"] = 5] = "TRACE";
10
- LogLevel2[LogLevel2["DEBUG"] = 10] = "DEBUG";
11
- LogLevel2[LogLevel2["VERBOSE"] = 11] = "VERBOSE";
12
- LogLevel2[LogLevel2["INFO"] = 12] = "INFO";
13
- LogLevel2[LogLevel2["WARN"] = 13] = "WARN";
14
- LogLevel2[LogLevel2["ERROR"] = 14] = "ERROR";
15
- return LogLevel2;
16
- }({});
17
- var levels = {
18
- trace: 5,
19
- debug: 10,
20
- verbose: 11,
21
- info: 12,
22
- warn: 13,
23
- error: 14
24
- };
25
- var shortLevelName = {
26
- [5]: "T",
27
- [10]: "D",
28
- [11]: "V",
29
- [12]: "I",
30
- [13]: "W",
31
- [14]: "E"
32
- };
33
- var LogProcessorType = /* @__PURE__ */ function(LogProcessorType2) {
34
- LogProcessorType2["CONSOLE"] = "console";
35
- LogProcessorType2["BROWSER"] = "browser";
36
- LogProcessorType2["DEBUG"] = "debug";
37
- return LogProcessorType2;
38
- }({});
39
-
40
- // src/scope.ts
41
- var logInfoProperties = Symbol("logInfoProperties");
42
- var logInfo = (target, propertyKey, descriptor) => {
43
- var _target, _logInfoProperties;
44
- ((_target = target)[_logInfoProperties = logInfoProperties] ?? (_target[_logInfoProperties] = [])).push(propertyKey);
45
- };
46
- var gatherLogInfoFromScope = (scope) => {
47
- if (!scope) {
48
- return {};
49
- }
50
- const res = {};
51
- const prototype = Object.getPrototypeOf(scope);
52
- const infoProps = (typeof prototype === "object" && prototype !== null ? prototype[logInfoProperties] : []) ?? [];
53
- for (const prop of infoProps) {
54
- try {
55
- res[prop] = typeof scope[prop] === "function" ? scope[prop]() : scope[prop];
56
- } catch (err) {
57
- res[prop] = err.message;
58
- }
59
- }
60
- return res;
61
- };
62
-
63
- // src/context.ts
64
- var matchFilter = (filter, level, path) => {
65
- return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
66
- };
67
- var shouldLog = (entry, filters) => {
68
- if (filters === void 0) {
69
- return true;
70
- } else {
71
- return filters.some((filter) => matchFilter(filter, entry.level, entry.meta?.F ?? ""));
72
- }
73
- };
74
- var getContextFromEntry = (entry) => {
75
- let context;
76
- if (entry.meta) {
77
- const scopeInfo = gatherLogInfoFromScope(entry.meta.S);
78
- if (Object.keys(scopeInfo).length > 0) {
79
- context = Object.assign(context ?? {}, scopeInfo);
80
- }
81
- }
82
- const entryContext = typeof entry.context === "function" ? entry.context() : entry.context;
83
- if (entryContext) {
84
- if (entryContext instanceof Error) {
85
- const c = entryContext.context;
86
- context = Object.assign(context ?? {}, {
87
- error: entryContext.stack,
88
- ...c
89
- });
90
- } else if (typeof entryContext === "object") {
91
- context = Object.assign(context ?? {}, entryContext);
92
- }
93
- }
94
- if (entry.error) {
95
- context = Object.assign(context ?? {}, {
96
- error: entry.error
97
- });
98
- }
99
- return context && Object.keys(context).length > 0 ? context : void 0;
100
- };
101
-
102
45
  // src/decorators.ts
103
46
  import { inspect } from "node:util";
104
47
  import chalk from "chalk";
@@ -198,144 +141,33 @@ var logAsyncResolved = (log2, methodName, resolvedValue, promiseId, startTime, c
198
141
  var logAsyncRejected = (log2, methodName, err, promiseId, startTime, combinedMeta) => {
199
142
  log2.info(`.${formatFunction(methodName)} \u21B2 \u{1F525} ${chalk.gray("reject")} ${formatPromise(promiseId)} ${formatTimeElapsed(startTime)} ${chalk.gray("=>")} ${err}`, {}, combinedMeta);
200
143
  };
201
- var greenCheck = typeof chalk.green === "function" ? chalk.green("\u2714") : "\u2714";
202
- var formatTimeElapsed = (startTime) => chalk.gray(`${(performance.now() - startTime).toFixed(0)}ms`);
203
144
  var COLOR_FUNCTION = [
204
145
  220,
205
146
  220,
206
147
  170
207
148
  ];
149
+ var greenCheck = typeof chalk.green === "function" ? chalk.green("\u2714") : "\u2714";
150
+ var formatTimeElapsed = (startTime) => chalk.gray(`${(performance.now() - startTime).toFixed(0)}ms`);
208
151
  var formatFunction = (name) => chalk.bold(chalk.rgb(...COLOR_FUNCTION)(name));
209
152
  var formatPromise = (id) => chalk.blue(`Promise#${id}`);
210
153
 
211
154
  // src/options.ts
212
155
  import defaultsDeep from "lodash.defaultsdeep";
213
156
 
214
- // src/platform/node/index.ts
215
- import fs from "node:fs";
216
- import yaml from "js-yaml";
217
- var loadOptions = (filepath) => {
218
- if (filepath) {
219
- try {
220
- const text = fs.readFileSync(filepath, "utf-8");
221
- if (text) {
222
- return yaml.load(text);
223
- }
224
- } catch (err) {
225
- console.warn(`Invalid log file: ${filepath}`);
226
- }
227
- }
228
- };
229
-
230
- // src/processors/console-processor.ts
231
- import { inspect as inspect2 } from "node:util";
232
- import chalk2 from "chalk";
233
- import { getPrototypeSpecificInstanceId, pickBy } from "@dxos/util";
234
-
235
- // src/processors/common.ts
236
- var getRelativeFilename = (filename) => {
237
- const match = filename.match(/.+\/(packages\/.+\/.+)/);
238
- if (match) {
239
- const [, filePath] = match;
240
- return filePath;
241
- }
242
- return filename;
243
- };
244
-
245
- // src/processors/console-processor.ts
246
- var LEVEL_COLORS = {
247
- [LogLevel.TRACE]: "gray",
248
- [LogLevel.DEBUG]: "gray",
249
- [LogLevel.VERBOSE]: "gray",
250
- [LogLevel.INFO]: "white",
251
- [LogLevel.WARN]: "yellow",
252
- [LogLevel.ERROR]: "red"
253
- };
254
- var truncate = (text, length = 0, right = false) => {
255
- const str = text && length ? right ? text.slice(-length) : text.substring(0, length) : text ?? "";
256
- return right ? str.padStart(length, " ") : str.padEnd(length, " ");
257
- };
258
- var DEFAULT_FORMATTER = (config, { path, line, level, message, context, error, scope }) => {
259
- const column = config.options?.formatter?.column;
260
- const filepath = path !== void 0 && line !== void 0 ? chalk2.grey(`${path}:${line}`) : void 0;
261
- let instance;
262
- if (scope) {
263
- const prototype = Object.getPrototypeOf(scope);
264
- if (prototype !== null) {
265
- const id = getPrototypeSpecificInstanceId(scope);
266
- instance = chalk2.magentaBright(`${prototype.constructor.name}#${id}`);
267
- }
268
- }
269
- const formattedTimestamp = config.options?.formatter?.timestamp ? (/* @__PURE__ */ new Date()).toISOString() : void 0;
270
- const formattedLevel = chalk2[LEVEL_COLORS[level]](column ? shortLevelName[level] : LogLevel[level]);
271
- const padding = column && filepath ? "".padStart(column - filepath.length) : void 0;
272
- return config.options?.formatter?.timestampFirst ? [
273
- formattedTimestamp,
274
- filepath,
275
- padding,
276
- formattedLevel,
277
- instance,
278
- message,
279
- context,
280
- error
281
- ] : [
282
- // NOTE: File path must come fist for console hyperlinks.
283
- // Must not truncate for terminal output.
284
- filepath,
285
- padding,
286
- formattedTimestamp,
287
- formattedLevel,
288
- instance,
289
- message,
290
- context,
291
- error
292
- ];
293
- };
294
- var SHORT_FORMATTER = (config, { path, level, message }) => {
295
- return [
296
- chalk2.grey(truncate(path, 16, true)),
297
- chalk2[LEVEL_COLORS[level]](shortLevelName[level]),
298
- message
299
- ];
300
- };
301
- var formatter = DEFAULT_FORMATTER;
302
- var CONSOLE_PROCESSOR = (config, entry) => {
303
- const { level, message, meta, error } = entry;
304
- if (!shouldLog(entry, config.filters)) {
305
- return;
306
- }
307
- const parts = {
308
- level,
309
- message,
310
- error,
311
- path: void 0,
312
- line: void 0,
313
- scope: void 0,
314
- context: void 0
315
- };
316
- if (meta) {
317
- parts.path = getRelativeFilename(meta.F);
318
- parts.line = meta.L;
319
- parts.scope = meta.S;
320
- }
321
- const context = getContextFromEntry(entry);
322
- if (context) {
323
- parts.context = inspect2(pickBy(context, (value) => value !== void 0), {
324
- depth: config.options.depth,
325
- colors: true,
326
- maxArrayLength: 8,
327
- sorted: false
328
- });
329
- }
330
- const line = formatter(config, parts).filter(Boolean).join(" ");
331
- console.log(line);
332
- };
157
+ // src/platform/index.ts
158
+ var platform_exports = {};
159
+ __reExport(platform_exports, platform_star);
160
+ import * as platform_star from "#platform";
333
161
 
334
- // src/processors/debug-processor.ts
335
- import { inspect as inspect3 } from "node:util";
336
- var DEBUG_PROCESSOR = (config, entry) => {
337
- console.log(inspect3(entry, false, null, true));
338
- };
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
+ });
339
171
 
340
172
  // src/processors/browser-processor.ts
341
173
  import { getDebugName, safariCheck } from "@dxos/util";
@@ -377,6 +209,8 @@ var APP_BROWSER_PROCESSOR = (config, entry) => {
377
209
  if (context) {
378
210
  if (Object.keys(context).length === 1 && "error" in context) {
379
211
  args.push(context.error);
212
+ } else if (Object.keys(context).length === 1 && "err" in context) {
213
+ args.push(context.err);
380
214
  } else {
381
215
  args.push(context);
382
216
  }
@@ -442,6 +276,16 @@ var TEST_BROWSER_PROCESSOR = (config, entry) => {
442
276
  };
443
277
  var BROWSER_PROCESSOR = CONFIG.useTestProcessor ? TEST_BROWSER_PROCESSOR : APP_BROWSER_PROCESSOR;
444
278
 
279
+ // src/processors/index.ts
280
+ __reExport(processors_exports, console_processor_star);
281
+ import * as console_processor_star from "#console-processor";
282
+
283
+ // src/processors/debug-processor.ts
284
+ import { inspect as inspect2 } from "node:util";
285
+ var DEBUG_PROCESSOR = (config, entry) => {
286
+ console.log(inspect2(entry, false, null, true));
287
+ };
288
+
445
289
  // src/processors/file-processor.ts
446
290
  import { appendFileSync, mkdirSync, openSync } from "node:fs";
447
291
  import { dirname } from "node:path";
@@ -498,7 +342,7 @@ var createFileProcessor = ({ pathOrFd, levels: levels2, filters }) => {
498
342
  };
499
343
  var logFilePath;
500
344
  var getLogFilePath = () => {
501
- logFilePath ?? (logFilePath = process.env.LOG_FILE ?? (process.env.HOME ? `${process.env.HOME}/.dxlog/${(/* @__PURE__ */ new Date()).toISOString()}.log` : void 0));
345
+ logFilePath ??= process.env.LOG_FILE ?? (process.env.HOME ? `${process.env.HOME}/.dxlog/${(/* @__PURE__ */ new Date()).toISOString()}.log` : void 0);
502
346
  return logFilePath;
503
347
  };
504
348
  var FILE_PROCESSOR = createFileProcessor({
@@ -513,14 +357,15 @@ var FILE_PROCESSOR = createFileProcessor({
513
357
 
514
358
  // src/options.ts
515
359
  var processors = {
516
- [LogProcessorType.CONSOLE]: CONSOLE_PROCESSOR,
360
+ [LogProcessorType.CONSOLE]: processors_exports.CONSOLE_PROCESSOR,
517
361
  [LogProcessorType.BROWSER]: BROWSER_PROCESSOR,
518
362
  [LogProcessorType.DEBUG]: DEBUG_PROCESSOR
519
363
  };
520
- var IS_BROWSER = typeof window !== "undefined" || typeof navigator !== "undefined";
364
+ var browser = (typeof window !== "undefined" || typeof navigator !== "undefined") && !(typeof process !== "undefined" && process?.env?.VITEST);
521
365
  var DEFAULT_PROCESSORS = [
522
- IS_BROWSER ? BROWSER_PROCESSOR : CONSOLE_PROCESSOR
366
+ browser ? BROWSER_PROCESSOR : processors_exports.CONSOLE_PROCESSOR
523
367
  ];
368
+ var parseLogLevel = (level, defValue = LogLevel.WARN) => levels[level.toLowerCase()] ?? defValue;
524
369
  var parseFilter = (filter) => {
525
370
  if (typeof filter === "number") {
526
371
  return [
@@ -529,7 +374,6 @@ var parseFilter = (filter) => {
529
374
  }
530
375
  ];
531
376
  }
532
- const parseLogLevel = (level, defValue = LogLevel.WARN) => levels[level.toLowerCase()] ?? defValue;
533
377
  const lines = typeof filter === "string" ? filter.split(/,\s*/) : filter;
534
378
  return lines.map((filter2) => {
535
379
  const [pattern, level] = filter2.split(":");
@@ -541,55 +385,37 @@ var parseFilter = (filter) => {
541
385
  };
542
386
  });
543
387
  };
544
- var getConfig = (options) => {
545
- const nodeOptions = "process" in globalThis ? {
388
+ var createConfig = (options) => {
389
+ const envOptions = "process" in globalThis ? {
546
390
  file: process.env.LOG_CONFIG,
547
391
  filter: process.env.LOG_FILTER,
548
392
  processor: process.env.LOG_PROCESSOR
549
393
  } : void 0;
550
- const mergedOptions = defaultsDeep({}, loadOptions(nodeOptions?.file), nodeOptions, options);
394
+ const mergedOptions = defaultsDeep({}, (0, platform_exports.loadOptions)(envOptions?.file), envOptions, options);
551
395
  return {
552
396
  options: mergedOptions,
553
397
  filters: parseFilter(mergedOptions.filter ?? LogLevel.INFO),
554
398
  captureFilters: parseFilter(mergedOptions.captureFilter ?? LogLevel.WARN),
555
399
  processors: mergedOptions.processor ? [
556
400
  processors[mergedOptions.processor]
557
- ] : DEFAULT_PROCESSORS,
401
+ ] : [
402
+ ...DEFAULT_PROCESSORS
403
+ ],
558
404
  prefix: mergedOptions.prefix
559
405
  };
560
406
  };
561
407
 
562
408
  // src/log.ts
563
- var _globalThis;
409
+ var logCount = 0;
564
410
  var createLog = () => {
565
411
  const log2 = (...params) => processLog(LogLevel.DEBUG, ...params);
566
- log2._config = getConfig();
412
+ Object.assign(log2, {
413
+ _id: `log-${++logCount}`,
414
+ _config: createConfig()
415
+ });
567
416
  Object.defineProperty(log2, "runtimeConfig", {
568
417
  get: () => log2._config
569
418
  });
570
- log2.addProcessor = (processor) => {
571
- if (DEFAULT_PROCESSORS.filter((p) => p === processor).length === 0) {
572
- DEFAULT_PROCESSORS.push(processor);
573
- }
574
- if (log2._config.processors.filter((p) => p === processor).length === 0) {
575
- log2._config.processors.push(processor);
576
- }
577
- };
578
- log2.config = (options) => {
579
- log2._config = getConfig(options);
580
- };
581
- log2.trace = (...params) => processLog(LogLevel.TRACE, ...params);
582
- log2.debug = (...params) => processLog(LogLevel.DEBUG, ...params);
583
- log2.verbose = (...params) => processLog(LogLevel.VERBOSE, ...params);
584
- log2.info = (...params) => processLog(LogLevel.INFO, ...params);
585
- log2.warn = (...params) => processLog(LogLevel.WARN, ...params);
586
- log2.error = (...params) => processLog(LogLevel.ERROR, ...params);
587
- log2.catch = (error, context, meta) => processLog(LogLevel.ERROR, void 0, context, meta, error);
588
- 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");
589
- log2.stack = (message, context, meta) => processLog(LogLevel.INFO, `${message ?? "Stack Dump"}
590
- ${getFormattedStackTrace()}`, context, meta);
591
- log2.method = createMethodLogDecorator(log2);
592
- log2.func = createFunctionLogDecorator(log2);
593
419
  const processLog = (level, message, context = {}, meta, error) => {
594
420
  log2._config.processors.forEach((processor) => processor(log2._config, {
595
421
  level,
@@ -599,9 +425,50 @@ ${getFormattedStackTrace()}`, context, meta);
599
425
  error
600
426
  }));
601
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
+ });
602
469
  return log2;
603
470
  };
604
- var log = (_globalThis = globalThis).dx_log ?? (_globalThis.dx_log = createLog());
471
+ var log = globalThis.DX_LOG ??= createLog();
605
472
  var start = Date.now();
606
473
  var last = start;
607
474
  var debug = (label, args) => {
@@ -618,26 +485,22 @@ var debug = (label, args) => {
618
485
  };
619
486
  var getFormattedStackTrace = () => new Error().stack.split("\n").slice(3).join("\n");
620
487
 
488
+ // src/index.ts
489
+ __reExport(index_exports, processors_exports);
490
+
621
491
  // src/experimental/ownership.ts
622
- import { inspect as inspect4 } from "node:util";
623
- function _define_property(obj, key, value) {
624
- if (key in obj) {
625
- Object.defineProperty(obj, key, {
626
- value,
627
- enumerable: true,
628
- configurable: true,
629
- writable: true
630
- });
631
- } else {
632
- obj[key] = value;
633
- }
634
- return obj;
635
- }
492
+ import { inspect as inspect3 } from "node:util";
636
493
  var kOwnershipScope = Symbol("kOwnershipScope");
637
494
  var kCurrentOwnershipScope = Symbol("kCurrentOwnershipScope");
638
495
  var kDebugInfoProperties = Symbol("kDebugInfoProperties");
639
- var _inspect_custom = inspect4.custom;
640
496
  var OwnershipScope = class {
497
+ constr;
498
+ parent;
499
+ instance;
500
+ constructor(constr, parent) {
501
+ this.constr = constr;
502
+ this.parent = parent;
503
+ }
641
504
  getInfo() {
642
505
  if (!this.instance) {
643
506
  return {};
@@ -649,32 +512,23 @@ var OwnershipScope = class {
649
512
  }
650
513
  return info;
651
514
  }
652
- [_inspect_custom]() {
515
+ [inspect3.custom]() {
653
516
  return {
654
517
  className: this.constr.name,
655
518
  info: this.getInfo(),
656
519
  parent: this.parent
657
520
  };
658
521
  }
659
- constructor(constr, parent) {
660
- _define_property(this, "constr", void 0);
661
- _define_property(this, "parent", void 0);
662
- _define_property(this, "instance", void 0);
663
- this.constr = constr;
664
- this.parent = parent;
665
- }
666
522
  };
667
523
  var getCurrentOwnershipScope = (thisRef) => thisRef;
668
524
  export {
669
525
  BROWSER_PROCESSOR,
670
- CONSOLE_PROCESSOR,
671
526
  DEBUG_PROCESSOR,
672
- DEFAULT_FORMATTER,
673
527
  FILE_PROCESSOR,
674
528
  LogLevel,
675
529
  LogProcessorType,
676
- SHORT_FORMATTER,
677
530
  createFileProcessor,
531
+ createLog,
678
532
  debug,
679
533
  gatherLogInfoFromScope,
680
534
  getContextFromEntry,
@@ -687,7 +541,6 @@ export {
687
541
  parseFilter,
688
542
  pick,
689
543
  shortLevelName,
690
- shouldLog,
691
- truncate
544
+ shouldLog
692
545
  };
693
546
  //# sourceMappingURL=index.mjs.map