@dxos/log 0.8.4-main.fbb7a13 → 0.8.4-main.fcc0d83b33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/chunk-V7FYKT4H.mjs +311 -0
- package/dist/lib/browser/chunk-V7FYKT4H.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +236 -43
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/platform/node/index.mjs +1 -1
- package/dist/lib/browser/platform/node/index.mjs.map +3 -3
- package/dist/lib/browser/processors/console-processor.mjs +6 -11
- package/dist/lib/browser/processors/console-processor.mjs.map +3 -3
- package/dist/lib/node-esm/chunk-5TBDXMQF.mjs +313 -0
- package/dist/lib/node-esm/chunk-5TBDXMQF.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +236 -43
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/platform/node/index.mjs +1 -1
- package/dist/lib/node-esm/platform/node/index.mjs.map +3 -3
- package/dist/lib/node-esm/processors/console-processor.mjs +6 -11
- package/dist/lib/node-esm/processors/console-processor.mjs.map +3 -3
- package/dist/types/src/context.d.ts +78 -2
- package/dist/types/src/context.d.ts.map +1 -1
- package/dist/types/src/dbg.d.ts +23 -0
- package/dist/types/src/dbg.d.ts.map +1 -0
- package/dist/types/src/decorators.d.ts.map +1 -1
- package/dist/types/src/environment.d.ts +24 -0
- package/dist/types/src/environment.d.ts.map +1 -0
- package/dist/types/src/environment.test.d.ts +2 -0
- package/dist/types/src/environment.test.d.ts.map +1 -0
- package/dist/types/src/experimental/ownership.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +7 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/jsonl.d.ts +53 -0
- package/dist/types/src/jsonl.d.ts.map +1 -0
- package/dist/types/src/jsonl.test.d.ts +2 -0
- package/dist/types/src/jsonl.test.d.ts.map +1 -0
- package/dist/types/src/log-buffer.d.ts +20 -0
- package/dist/types/src/log-buffer.d.ts.map +1 -0
- package/dist/types/src/log-buffer.test.d.ts +2 -0
- package/dist/types/src/log-buffer.test.d.ts.map +1 -0
- package/dist/types/src/log.d.ts +44 -1
- package/dist/types/src/log.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +20 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/platform/browser/index.d.ts.map +1 -1
- package/dist/types/src/platform/node/index.d.ts.map +1 -1
- package/dist/types/src/processors/browser-processor.d.ts.map +1 -1
- package/dist/types/src/processors/common.d.ts.map +1 -1
- package/dist/types/src/processors/console-processor.d.ts.map +1 -1
- package/dist/types/src/processors/file-processor.d.ts.map +1 -1
- package/dist/types/src/scope.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -9
- package/src/context.ts +242 -2
- package/src/dbg.ts +34 -0
- package/src/decorators.ts +1 -2
- package/src/environment.test.ts +222 -0
- package/src/environment.ts +129 -0
- package/src/experimental/classes.test.ts +0 -1
- package/src/index.ts +7 -4
- package/src/jsonl.test.ts +121 -0
- package/src/jsonl.ts +104 -0
- package/src/log-buffer.test.ts +158 -0
- package/src/log-buffer.ts +89 -0
- package/src/log.test.ts +0 -1
- package/src/log.ts +56 -12
- package/src/meta.ts +29 -1
- package/src/platform/node/index.ts +1 -2
- package/src/processors/browser-processor.ts +27 -28
- package/src/processors/console-processor.ts +5 -13
- package/src/processors/file-processor.ts +7 -9
- package/dist/lib/browser/chunk-GPOFUMLO.mjs +0 -133
- package/dist/lib/browser/chunk-GPOFUMLO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QPYJZ4SO.mjs +0 -135
- package/dist/lib/node-esm/chunk-QPYJZ4SO.mjs.map +0 -7
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
LogEntry,
|
|
2
3
|
LogLevel,
|
|
3
4
|
LogProcessorType,
|
|
4
5
|
gatherLogInfoFromScope,
|
|
@@ -8,7 +9,7 @@ import {
|
|
|
8
9
|
logInfo,
|
|
9
10
|
shortLevelName,
|
|
10
11
|
shouldLog
|
|
11
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-V7FYKT4H.mjs";
|
|
12
13
|
import {
|
|
13
14
|
__export,
|
|
14
15
|
__reExport
|
|
@@ -20,30 +21,139 @@ __export(index_exports, {
|
|
|
20
21
|
BROWSER_PROCESSOR: () => BROWSER_PROCESSOR,
|
|
21
22
|
DEBUG_PROCESSOR: () => DEBUG_PROCESSOR,
|
|
22
23
|
FILE_PROCESSOR: () => FILE_PROCESSOR,
|
|
24
|
+
LOG_META_MARKER: () => LOG_META_MARKER,
|
|
25
|
+
LogBuffer: () => LogBuffer,
|
|
26
|
+
LogEntry: () => LogEntry,
|
|
23
27
|
LogLevel: () => LogLevel,
|
|
24
28
|
LogProcessorType: () => LogProcessorType,
|
|
25
29
|
createFileProcessor: () => createFileProcessor,
|
|
26
30
|
createLog: () => createLog,
|
|
31
|
+
dbg: () => dbg,
|
|
27
32
|
debug: () => debug,
|
|
28
33
|
gatherLogInfoFromScope: () => gatherLogInfoFromScope,
|
|
29
34
|
getContextFromEntry: () => getContextFromEntry,
|
|
30
35
|
getCurrentOwnershipScope: () => getCurrentOwnershipScope,
|
|
31
36
|
getRelativeFilename: () => getRelativeFilename,
|
|
37
|
+
inferEnvironmentName: () => inferEnvironmentName,
|
|
38
|
+
isLogMeta: () => isLogMeta,
|
|
32
39
|
levels: () => levels,
|
|
33
40
|
log: () => log,
|
|
34
41
|
logInfo: () => logInfo,
|
|
35
42
|
omit: () => omit,
|
|
36
43
|
parseFilter: () => parseFilter,
|
|
37
44
|
pick: () => pick,
|
|
45
|
+
serializeToJsonl: () => serializeToJsonl,
|
|
38
46
|
shortLevelName: () => shortLevelName,
|
|
39
47
|
shouldLog: () => shouldLog
|
|
40
48
|
});
|
|
41
|
-
import omit from "
|
|
42
|
-
|
|
49
|
+
import { omit, pick } from "@dxos/util";
|
|
50
|
+
|
|
51
|
+
// src/environment.ts
|
|
52
|
+
var TAB_SUFFIX_STORAGE_KEY = "@dxos/log:env-suffix";
|
|
53
|
+
var SUFFIX_LENGTH = 6;
|
|
54
|
+
var randomSuffix = () => {
|
|
55
|
+
const cryptoRef = globalThis.crypto;
|
|
56
|
+
if (cryptoRef?.getRandomValues) {
|
|
57
|
+
const bytes = new Uint8Array(SUFFIX_LENGTH);
|
|
58
|
+
cryptoRef.getRandomValues(bytes);
|
|
59
|
+
let suffix = "";
|
|
60
|
+
for (const byte of bytes) {
|
|
61
|
+
suffix += (byte % 36).toString(36);
|
|
62
|
+
}
|
|
63
|
+
return suffix;
|
|
64
|
+
}
|
|
65
|
+
return Math.random().toString(36).slice(2, 2 + SUFFIX_LENGTH).padEnd(SUFFIX_LENGTH, "0");
|
|
66
|
+
};
|
|
67
|
+
var getOrCreateTabSuffix = (session) => {
|
|
68
|
+
if (!session) {
|
|
69
|
+
return randomSuffix();
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
const existing = session.getItem(TAB_SUFFIX_STORAGE_KEY);
|
|
73
|
+
if (existing && existing.length > 0) {
|
|
74
|
+
return existing;
|
|
75
|
+
}
|
|
76
|
+
const suffix = randomSuffix();
|
|
77
|
+
session.setItem(TAB_SUFFIX_STORAGE_KEY, suffix);
|
|
78
|
+
return suffix;
|
|
79
|
+
} catch {
|
|
80
|
+
return randomSuffix();
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
var isInstanceOf = (scope, ctorName) => {
|
|
84
|
+
const ctor = scope?.[ctorName];
|
|
85
|
+
return typeof ctor === "function" && scope instanceof ctor;
|
|
86
|
+
};
|
|
87
|
+
var CF_WORKER_USER_AGENT = "Cloudflare-Workers";
|
|
88
|
+
var inferEnvironmentName = (options = {}) => {
|
|
89
|
+
const scope = options.scope ?? globalThis;
|
|
90
|
+
if (scope.navigator?.userAgent === CF_WORKER_USER_AGENT) {
|
|
91
|
+
return `cf-worker::${randomSuffix()}`;
|
|
92
|
+
}
|
|
93
|
+
if (isInstanceOf(scope, "SharedWorkerGlobalScope")) {
|
|
94
|
+
return `shared-worker:${scope.name ?? ""}:${randomSuffix()}`;
|
|
95
|
+
}
|
|
96
|
+
if (isInstanceOf(scope, "ServiceWorkerGlobalScope")) {
|
|
97
|
+
return `service-worker::${randomSuffix()}`;
|
|
98
|
+
}
|
|
99
|
+
if (isInstanceOf(scope, "DedicatedWorkerGlobalScope")) {
|
|
100
|
+
return `dedicated-worker:${scope.name ?? ""}:${randomSuffix()}`;
|
|
101
|
+
}
|
|
102
|
+
if (scope.window !== void 0 && scope.window === scope) {
|
|
103
|
+
const origin = scope.location?.origin ?? "";
|
|
104
|
+
return `tab:${origin}:${getOrCreateTabSuffix(scope.sessionStorage)}`;
|
|
105
|
+
}
|
|
106
|
+
const proc = scope.process;
|
|
107
|
+
if (proc && typeof proc === "object" && proc.versions?.node) {
|
|
108
|
+
const pid = typeof proc.pid === "number" ? String(proc.pid) : "";
|
|
109
|
+
return `node:${pid}:${randomSuffix()}`;
|
|
110
|
+
}
|
|
111
|
+
return `unknown::${randomSuffix()}`;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// src/jsonl.ts
|
|
115
|
+
var serializeToJsonl = (entry, opts = {}) => {
|
|
116
|
+
if (entry.level <= LogLevel.TRACE) {
|
|
117
|
+
return void 0;
|
|
118
|
+
}
|
|
119
|
+
const { filename, line, context: scopeName } = entry.computedMeta;
|
|
120
|
+
const record = {
|
|
121
|
+
t: new Date(entry.timestamp).toISOString(),
|
|
122
|
+
l: shortLevelName[entry.level] ?? "?",
|
|
123
|
+
m: entry.message ?? ""
|
|
124
|
+
};
|
|
125
|
+
if (filename !== void 0) {
|
|
126
|
+
record.f = filename;
|
|
127
|
+
}
|
|
128
|
+
if (line !== void 0) {
|
|
129
|
+
record.n = line;
|
|
130
|
+
}
|
|
131
|
+
if (scopeName !== void 0) {
|
|
132
|
+
record.o = scopeName;
|
|
133
|
+
}
|
|
134
|
+
if (entry.computedError !== void 0) {
|
|
135
|
+
record.e = entry.computedError;
|
|
136
|
+
}
|
|
137
|
+
if (opts.env !== void 0) {
|
|
138
|
+
record.i = opts.env;
|
|
139
|
+
}
|
|
140
|
+
const computedContext = entry.computedContext;
|
|
141
|
+
if (Object.keys(computedContext).length > 0) {
|
|
142
|
+
try {
|
|
143
|
+
record.c = JSON.stringify(computedContext);
|
|
144
|
+
} catch {
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
try {
|
|
148
|
+
return JSON.stringify(record);
|
|
149
|
+
} catch {
|
|
150
|
+
return void 0;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
43
153
|
|
|
44
154
|
// src/decorators.ts
|
|
45
|
-
import { inspect } from "@dxos/node-std/util";
|
|
46
155
|
import chalk from "chalk";
|
|
156
|
+
import { inspect } from "@dxos/node-std/util";
|
|
47
157
|
var nextPromiseId = 0;
|
|
48
158
|
var createMethodLogDecorator = (log2) => (arg0, arg1, meta) => (target, propertyKey, descriptor) => {
|
|
49
159
|
const method = descriptor.value;
|
|
@@ -169,15 +279,7 @@ __export(processors_exports, {
|
|
|
169
279
|
});
|
|
170
280
|
|
|
171
281
|
// src/processors/browser-processor.ts
|
|
172
|
-
import {
|
|
173
|
-
var getRelativeFilename2 = (filename) => {
|
|
174
|
-
const match = filename.match(/.+\/(packages\/.+\/.+)/);
|
|
175
|
-
if (match) {
|
|
176
|
-
const [, filePath] = match;
|
|
177
|
-
return filePath;
|
|
178
|
-
}
|
|
179
|
-
return filename;
|
|
180
|
-
};
|
|
282
|
+
import { safariCheck } from "@dxos/util";
|
|
181
283
|
var CONFIG = {
|
|
182
284
|
useTestProcessor: false,
|
|
183
285
|
printFileLinks: false
|
|
@@ -188,18 +290,20 @@ var APP_BROWSER_PROCESSOR = (config, entry) => {
|
|
|
188
290
|
}
|
|
189
291
|
const LOG_BROWSER_PREFIX = config.prefix ?? "https://vscode.dev/github.com/dxos/dxos/blob/main/";
|
|
190
292
|
const LOG_BROWSER_CSS = [];
|
|
293
|
+
const { filename, line: lineNumber, context: scopeDebugName } = entry.computedMeta;
|
|
191
294
|
let link = "";
|
|
192
|
-
if (
|
|
193
|
-
const filename = getRelativeFilename2(entry.meta.F);
|
|
295
|
+
if (filename !== void 0 && lineNumber !== void 0) {
|
|
194
296
|
const filepath = `${LOG_BROWSER_PREFIX.replace(/\/$/, "")}/${filename}`;
|
|
195
|
-
link = `${filepath}#L${
|
|
297
|
+
link = `${filepath}#L${lineNumber}`;
|
|
196
298
|
}
|
|
197
299
|
let args = [];
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
const scopeName = scope.name ||
|
|
201
|
-
|
|
202
|
-
|
|
300
|
+
const scope = entry.meta?.S;
|
|
301
|
+
if (scope) {
|
|
302
|
+
const scopeName = scope.name || scopeDebugName;
|
|
303
|
+
if (scopeName) {
|
|
304
|
+
const processPrefix = scope.hostSessionId ? "[worker] " : "";
|
|
305
|
+
args.push(`%c${processPrefix}${scopeName}`, "color:#C026D3;font-weight:bold");
|
|
306
|
+
}
|
|
203
307
|
}
|
|
204
308
|
if (entry.message) {
|
|
205
309
|
args.push(entry.message);
|
|
@@ -207,9 +311,9 @@ var APP_BROWSER_PROCESSOR = (config, entry) => {
|
|
|
207
311
|
const context = getContextFromEntry(entry);
|
|
208
312
|
if (context) {
|
|
209
313
|
if (Object.keys(context).length === 1 && "error" in context) {
|
|
210
|
-
args.push(context.error);
|
|
314
|
+
args.push(unwrapEffectError(context.error));
|
|
211
315
|
} else if (Object.keys(context).length === 1 && "err" in context) {
|
|
212
|
-
args.push(context.err);
|
|
316
|
+
args.push(unwrapEffectError(context.err));
|
|
213
317
|
} else {
|
|
214
318
|
args.push(context);
|
|
215
319
|
}
|
|
@@ -244,10 +348,8 @@ var TEST_BROWSER_PROCESSOR = (config, entry) => {
|
|
|
244
348
|
if (!shouldLog(entry, config.filters)) {
|
|
245
349
|
return;
|
|
246
350
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
path = `${getRelativeFilename2(entry.meta.F)}:${entry.meta.L}`;
|
|
250
|
-
}
|
|
351
|
+
const { filename, line: lineNumber } = entry.computedMeta;
|
|
352
|
+
const path = filename !== void 0 && lineNumber !== void 0 ? `${filename}:${lineNumber}` : "";
|
|
251
353
|
let args = [];
|
|
252
354
|
const processPrefix = entry.meta?.S?.hostSessionId ? "[worker] " : "";
|
|
253
355
|
args.push(`${processPrefix}${entry.message}`);
|
|
@@ -274,6 +376,13 @@ var TEST_BROWSER_PROCESSOR = (config, entry) => {
|
|
|
274
376
|
}
|
|
275
377
|
};
|
|
276
378
|
var BROWSER_PROCESSOR = CONFIG.useTestProcessor ? TEST_BROWSER_PROCESSOR : APP_BROWSER_PROCESSOR;
|
|
379
|
+
var originalSymbol = /* @__PURE__ */ Symbol.for("effect/OriginalAnnotation");
|
|
380
|
+
var unwrapEffectError = (error) => {
|
|
381
|
+
if (typeof error === "object" && error !== null && originalSymbol in error) {
|
|
382
|
+
return error[originalSymbol];
|
|
383
|
+
}
|
|
384
|
+
return error;
|
|
385
|
+
};
|
|
277
386
|
|
|
278
387
|
// src/processors/index.ts
|
|
279
388
|
__reExport(processors_exports, console_processor_star);
|
|
@@ -288,7 +397,6 @@ var DEBUG_PROCESSOR = (config, entry) => {
|
|
|
288
397
|
// src/processors/file-processor.ts
|
|
289
398
|
import { appendFileSync, mkdirSync, openSync } from "@dxos/node-std/fs";
|
|
290
399
|
import { dirname } from "@dxos/node-std/path";
|
|
291
|
-
import { jsonlogify } from "@dxos/util";
|
|
292
400
|
var EAGAIN_MAX_DURATION = 1e3;
|
|
293
401
|
var createFileProcessor = ({ pathOrFd, levels: levels2, filters }) => {
|
|
294
402
|
let fd;
|
|
@@ -309,15 +417,12 @@ var createFileProcessor = ({ pathOrFd, levels: levels2, filters }) => {
|
|
|
309
417
|
fd = openSync(pathOrFd, "a");
|
|
310
418
|
}
|
|
311
419
|
const record = {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}
|
|
319
|
-
} : {},
|
|
320
|
-
context: jsonlogify(getContextFromEntry(entry))
|
|
420
|
+
level: entry.level,
|
|
421
|
+
message: entry.message,
|
|
422
|
+
timestamp: entry.timestamp,
|
|
423
|
+
meta: entry.computedMeta,
|
|
424
|
+
context: entry.computedContext,
|
|
425
|
+
error: entry.computedError
|
|
321
426
|
};
|
|
322
427
|
let retryTS = 0;
|
|
323
428
|
while (true) {
|
|
@@ -416,13 +521,14 @@ var createLog = () => {
|
|
|
416
521
|
get: () => log2._config
|
|
417
522
|
});
|
|
418
523
|
const processLog = (level, message, context = {}, meta, error) => {
|
|
419
|
-
|
|
524
|
+
const entry = new LogEntry({
|
|
420
525
|
level,
|
|
421
526
|
message,
|
|
422
527
|
context,
|
|
423
528
|
meta,
|
|
424
529
|
error
|
|
425
|
-
})
|
|
530
|
+
});
|
|
531
|
+
log2._config.processors.forEach((processor) => processor(log2._config, entry));
|
|
426
532
|
};
|
|
427
533
|
Object.assign(log2, {
|
|
428
534
|
/**
|
|
@@ -430,7 +536,7 @@ var createLog = () => {
|
|
|
430
536
|
* NOTE: Preserves any processors that were already added to this logger instance
|
|
431
537
|
* unless an explicit processor option is provided.
|
|
432
538
|
*/
|
|
433
|
-
config: ({ processor, ...options }) => {
|
|
539
|
+
config: ({ processor, ...options } = {}) => {
|
|
434
540
|
const config = createConfig(options);
|
|
435
541
|
const processors2 = processor ? config.processors : log2._config.processors;
|
|
436
542
|
log2._config = {
|
|
@@ -487,11 +593,91 @@ var getFormattedStackTrace = () => new Error().stack.split("\n").slice(3).join("
|
|
|
487
593
|
// src/index.ts
|
|
488
594
|
__reExport(index_exports, processors_exports);
|
|
489
595
|
|
|
596
|
+
// src/meta.ts
|
|
597
|
+
var LOG_META_MARKER = "~LogMeta";
|
|
598
|
+
var isLogMeta = (value) => {
|
|
599
|
+
return value != null && typeof value === "object" && value[LOG_META_MARKER] === LOG_META_MARKER;
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
// src/dbg.ts
|
|
603
|
+
var dbg = (arg, meta) => {
|
|
604
|
+
if (meta?.A) {
|
|
605
|
+
console.log(`${meta.A[0]} =`, arg);
|
|
606
|
+
} else {
|
|
607
|
+
console.log(arg);
|
|
608
|
+
}
|
|
609
|
+
return arg;
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
// src/log-buffer.ts
|
|
613
|
+
import { CircularBuffer } from "@dxos/util";
|
|
614
|
+
var DEFAULT_BUFFER_SIZE = 2e3;
|
|
615
|
+
var MAX_CONTEXT_LENGTH = 500;
|
|
616
|
+
var LogBuffer = class {
|
|
617
|
+
_buffer;
|
|
618
|
+
constructor(size = DEFAULT_BUFFER_SIZE) {
|
|
619
|
+
this._buffer = new CircularBuffer(size);
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Log processor that can be registered with `log.runtimeConfig.processors`.
|
|
623
|
+
* Captures every level except TRACE (does not apply `shouldLog` / filter; use for full debug dumps).
|
|
624
|
+
*/
|
|
625
|
+
logProcessor = (_config, entry) => {
|
|
626
|
+
if (entry.level <= LogLevel.TRACE) {
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
const { filename, line, context: scopeName } = entry.computedMeta;
|
|
630
|
+
const record = {
|
|
631
|
+
t: new Date(entry.timestamp).toISOString(),
|
|
632
|
+
l: shortLevelName[entry.level] ?? "?",
|
|
633
|
+
m: entry.message ?? ""
|
|
634
|
+
};
|
|
635
|
+
if (filename !== void 0) {
|
|
636
|
+
record.f = filename;
|
|
637
|
+
}
|
|
638
|
+
if (line !== void 0) {
|
|
639
|
+
record.n = line;
|
|
640
|
+
}
|
|
641
|
+
if (scopeName !== void 0) {
|
|
642
|
+
record.o = scopeName;
|
|
643
|
+
}
|
|
644
|
+
if (entry.computedError !== void 0) {
|
|
645
|
+
record.e = entry.computedError;
|
|
646
|
+
}
|
|
647
|
+
const computedContext = entry.computedContext;
|
|
648
|
+
if (Object.keys(computedContext).length > 0) {
|
|
649
|
+
try {
|
|
650
|
+
let json = JSON.stringify(computedContext);
|
|
651
|
+
if (json.length > MAX_CONTEXT_LENGTH) {
|
|
652
|
+
json = json.slice(0, MAX_CONTEXT_LENGTH);
|
|
653
|
+
}
|
|
654
|
+
record.c = json;
|
|
655
|
+
} catch {
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
this._buffer.push(record);
|
|
659
|
+
};
|
|
660
|
+
/** Number of entries currently in the buffer. */
|
|
661
|
+
get size() {
|
|
662
|
+
return this._buffer.elementCount;
|
|
663
|
+
}
|
|
664
|
+
/** Discard all buffered entries. */
|
|
665
|
+
clear() {
|
|
666
|
+
this._buffer.clear();
|
|
667
|
+
}
|
|
668
|
+
/** Serialize buffer contents as NDJSON (newline-delimited JSON). */
|
|
669
|
+
serialize() {
|
|
670
|
+
const lines = [];
|
|
671
|
+
for (const record of this._buffer) {
|
|
672
|
+
lines.push(JSON.stringify(record));
|
|
673
|
+
}
|
|
674
|
+
return lines.join("\n");
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
|
|
490
678
|
// src/experimental/ownership.ts
|
|
491
679
|
import { inspect as inspect3 } from "@dxos/node-std/util";
|
|
492
|
-
var
|
|
493
|
-
var kCurrentOwnershipScope = Symbol("kCurrentOwnershipScope");
|
|
494
|
-
var kDebugInfoProperties = Symbol("kDebugInfoProperties");
|
|
680
|
+
var kDebugInfoProperties = /* @__PURE__ */ Symbol("kDebugInfoProperties");
|
|
495
681
|
var OwnershipScope = class {
|
|
496
682
|
constr;
|
|
497
683
|
parent;
|
|
@@ -524,21 +710,28 @@ export {
|
|
|
524
710
|
BROWSER_PROCESSOR,
|
|
525
711
|
DEBUG_PROCESSOR,
|
|
526
712
|
FILE_PROCESSOR,
|
|
713
|
+
LOG_META_MARKER,
|
|
714
|
+
LogBuffer,
|
|
715
|
+
LogEntry,
|
|
527
716
|
LogLevel,
|
|
528
717
|
LogProcessorType,
|
|
529
718
|
createFileProcessor,
|
|
530
719
|
createLog,
|
|
720
|
+
dbg,
|
|
531
721
|
debug,
|
|
532
722
|
gatherLogInfoFromScope,
|
|
533
723
|
getContextFromEntry,
|
|
534
724
|
getCurrentOwnershipScope,
|
|
535
725
|
getRelativeFilename,
|
|
726
|
+
inferEnvironmentName,
|
|
727
|
+
isLogMeta,
|
|
536
728
|
levels,
|
|
537
729
|
log,
|
|
538
730
|
logInfo,
|
|
539
731
|
omit,
|
|
540
732
|
parseFilter,
|
|
541
733
|
pick,
|
|
734
|
+
serializeToJsonl,
|
|
542
735
|
shortLevelName,
|
|
543
736
|
shouldLog
|
|
544
737
|
};
|