@dxos/log 0.8.4-main.ef1bc66f44 → 0.8.4-main.f466a3d56e
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/LICENSE +102 -5
- 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 +224 -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 +224 -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.map +1 -1
- 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 +6 -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 +5 -10
- package/src/context.ts +242 -2
- package/src/dbg.ts +0 -1
- 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 +6 -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,6 +21,9 @@ __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,
|
|
@@ -30,21 +34,126 @@ __export(index_exports, {
|
|
|
30
34
|
getContextFromEntry: () => getContextFromEntry,
|
|
31
35
|
getCurrentOwnershipScope: () => getCurrentOwnershipScope,
|
|
32
36
|
getRelativeFilename: () => getRelativeFilename,
|
|
37
|
+
inferEnvironmentName: () => inferEnvironmentName,
|
|
38
|
+
isLogMeta: () => isLogMeta,
|
|
33
39
|
levels: () => levels,
|
|
34
40
|
log: () => log,
|
|
35
41
|
logInfo: () => logInfo,
|
|
36
42
|
omit: () => omit,
|
|
37
43
|
parseFilter: () => parseFilter,
|
|
38
44
|
pick: () => pick,
|
|
45
|
+
serializeToJsonl: () => serializeToJsonl,
|
|
39
46
|
shortLevelName: () => shortLevelName,
|
|
40
47
|
shouldLog: () => shouldLog
|
|
41
48
|
});
|
|
42
|
-
import omit from "
|
|
43
|
-
|
|
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
|
+
};
|
|
44
153
|
|
|
45
154
|
// src/decorators.ts
|
|
46
|
-
import { inspect } from "@dxos/node-std/util";
|
|
47
155
|
import chalk from "chalk";
|
|
156
|
+
import { inspect } from "@dxos/node-std/util";
|
|
48
157
|
var nextPromiseId = 0;
|
|
49
158
|
var createMethodLogDecorator = (log2) => (arg0, arg1, meta) => (target, propertyKey, descriptor) => {
|
|
50
159
|
const method = descriptor.value;
|
|
@@ -170,15 +279,7 @@ __export(processors_exports, {
|
|
|
170
279
|
});
|
|
171
280
|
|
|
172
281
|
// src/processors/browser-processor.ts
|
|
173
|
-
import {
|
|
174
|
-
var getRelativeFilename2 = (filename) => {
|
|
175
|
-
const match = filename.match(/.+\/(packages\/.+\/.+)/);
|
|
176
|
-
if (match) {
|
|
177
|
-
const [, filePath] = match;
|
|
178
|
-
return filePath;
|
|
179
|
-
}
|
|
180
|
-
return filename;
|
|
181
|
-
};
|
|
282
|
+
import { safariCheck } from "@dxos/util";
|
|
182
283
|
var CONFIG = {
|
|
183
284
|
useTestProcessor: false,
|
|
184
285
|
printFileLinks: false
|
|
@@ -189,18 +290,20 @@ var APP_BROWSER_PROCESSOR = (config, entry) => {
|
|
|
189
290
|
}
|
|
190
291
|
const LOG_BROWSER_PREFIX = config.prefix ?? "https://vscode.dev/github.com/dxos/dxos/blob/main/";
|
|
191
292
|
const LOG_BROWSER_CSS = [];
|
|
293
|
+
const { filename, line: lineNumber, context: scopeDebugName } = entry.computedMeta;
|
|
192
294
|
let link = "";
|
|
193
|
-
if (
|
|
194
|
-
const filename = getRelativeFilename2(entry.meta.F);
|
|
295
|
+
if (filename !== void 0 && lineNumber !== void 0) {
|
|
195
296
|
const filepath = `${LOG_BROWSER_PREFIX.replace(/\/$/, "")}/${filename}`;
|
|
196
|
-
link = `${filepath}#L${
|
|
297
|
+
link = `${filepath}#L${lineNumber}`;
|
|
197
298
|
}
|
|
198
299
|
let args = [];
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const scopeName = scope.name ||
|
|
202
|
-
|
|
203
|
-
|
|
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
|
+
}
|
|
204
307
|
}
|
|
205
308
|
if (entry.message) {
|
|
206
309
|
args.push(entry.message);
|
|
@@ -208,9 +311,9 @@ var APP_BROWSER_PROCESSOR = (config, entry) => {
|
|
|
208
311
|
const context = getContextFromEntry(entry);
|
|
209
312
|
if (context) {
|
|
210
313
|
if (Object.keys(context).length === 1 && "error" in context) {
|
|
211
|
-
args.push(context.error);
|
|
314
|
+
args.push(unwrapEffectError(context.error));
|
|
212
315
|
} else if (Object.keys(context).length === 1 && "err" in context) {
|
|
213
|
-
args.push(context.err);
|
|
316
|
+
args.push(unwrapEffectError(context.err));
|
|
214
317
|
} else {
|
|
215
318
|
args.push(context);
|
|
216
319
|
}
|
|
@@ -245,10 +348,8 @@ var TEST_BROWSER_PROCESSOR = (config, entry) => {
|
|
|
245
348
|
if (!shouldLog(entry, config.filters)) {
|
|
246
349
|
return;
|
|
247
350
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
path = `${getRelativeFilename2(entry.meta.F)}:${entry.meta.L}`;
|
|
251
|
-
}
|
|
351
|
+
const { filename, line: lineNumber } = entry.computedMeta;
|
|
352
|
+
const path = filename !== void 0 && lineNumber !== void 0 ? `${filename}:${lineNumber}` : "";
|
|
252
353
|
let args = [];
|
|
253
354
|
const processPrefix = entry.meta?.S?.hostSessionId ? "[worker] " : "";
|
|
254
355
|
args.push(`${processPrefix}${entry.message}`);
|
|
@@ -275,6 +376,13 @@ var TEST_BROWSER_PROCESSOR = (config, entry) => {
|
|
|
275
376
|
}
|
|
276
377
|
};
|
|
277
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
|
+
};
|
|
278
386
|
|
|
279
387
|
// src/processors/index.ts
|
|
280
388
|
__reExport(processors_exports, console_processor_star);
|
|
@@ -289,7 +397,6 @@ var DEBUG_PROCESSOR = (config, entry) => {
|
|
|
289
397
|
// src/processors/file-processor.ts
|
|
290
398
|
import { appendFileSync, mkdirSync, openSync } from "@dxos/node-std/fs";
|
|
291
399
|
import { dirname } from "@dxos/node-std/path";
|
|
292
|
-
import { jsonlogify } from "@dxos/util";
|
|
293
400
|
var EAGAIN_MAX_DURATION = 1e3;
|
|
294
401
|
var createFileProcessor = ({ pathOrFd, levels: levels2, filters }) => {
|
|
295
402
|
let fd;
|
|
@@ -310,15 +417,12 @@ var createFileProcessor = ({ pathOrFd, levels: levels2, filters }) => {
|
|
|
310
417
|
fd = openSync(pathOrFd, "a");
|
|
311
418
|
}
|
|
312
419
|
const record = {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
} : {},
|
|
321
|
-
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
|
|
322
426
|
};
|
|
323
427
|
let retryTS = 0;
|
|
324
428
|
while (true) {
|
|
@@ -417,13 +521,14 @@ var createLog = () => {
|
|
|
417
521
|
get: () => log2._config
|
|
418
522
|
});
|
|
419
523
|
const processLog = (level, message, context = {}, meta, error) => {
|
|
420
|
-
|
|
524
|
+
const entry = new LogEntry({
|
|
421
525
|
level,
|
|
422
526
|
message,
|
|
423
527
|
context,
|
|
424
528
|
meta,
|
|
425
529
|
error
|
|
426
|
-
})
|
|
530
|
+
});
|
|
531
|
+
log2._config.processors.forEach((processor) => processor(log2._config, entry));
|
|
427
532
|
};
|
|
428
533
|
Object.assign(log2, {
|
|
429
534
|
/**
|
|
@@ -431,7 +536,7 @@ var createLog = () => {
|
|
|
431
536
|
* NOTE: Preserves any processors that were already added to this logger instance
|
|
432
537
|
* unless an explicit processor option is provided.
|
|
433
538
|
*/
|
|
434
|
-
config: ({ processor, ...options }) => {
|
|
539
|
+
config: ({ processor, ...options } = {}) => {
|
|
435
540
|
const config = createConfig(options);
|
|
436
541
|
const processors2 = processor ? config.processors : log2._config.processors;
|
|
437
542
|
log2._config = {
|
|
@@ -488,6 +593,12 @@ var getFormattedStackTrace = () => new Error().stack.split("\n").slice(3).join("
|
|
|
488
593
|
// src/index.ts
|
|
489
594
|
__reExport(index_exports, processors_exports);
|
|
490
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
|
+
|
|
491
602
|
// src/dbg.ts
|
|
492
603
|
var dbg = (arg, meta) => {
|
|
493
604
|
if (meta?.A) {
|
|
@@ -498,11 +609,75 @@ var dbg = (arg, meta) => {
|
|
|
498
609
|
return arg;
|
|
499
610
|
};
|
|
500
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
|
+
|
|
501
678
|
// src/experimental/ownership.ts
|
|
502
679
|
import { inspect as inspect3 } from "@dxos/node-std/util";
|
|
503
|
-
var
|
|
504
|
-
var kCurrentOwnershipScope = Symbol("kCurrentOwnershipScope");
|
|
505
|
-
var kDebugInfoProperties = Symbol("kDebugInfoProperties");
|
|
680
|
+
var kDebugInfoProperties = /* @__PURE__ */ Symbol("kDebugInfoProperties");
|
|
506
681
|
var OwnershipScope = class {
|
|
507
682
|
constr;
|
|
508
683
|
parent;
|
|
@@ -535,6 +710,9 @@ export {
|
|
|
535
710
|
BROWSER_PROCESSOR,
|
|
536
711
|
DEBUG_PROCESSOR,
|
|
537
712
|
FILE_PROCESSOR,
|
|
713
|
+
LOG_META_MARKER,
|
|
714
|
+
LogBuffer,
|
|
715
|
+
LogEntry,
|
|
538
716
|
LogLevel,
|
|
539
717
|
LogProcessorType,
|
|
540
718
|
createFileProcessor,
|
|
@@ -545,12 +723,15 @@ export {
|
|
|
545
723
|
getContextFromEntry,
|
|
546
724
|
getCurrentOwnershipScope,
|
|
547
725
|
getRelativeFilename,
|
|
726
|
+
inferEnvironmentName,
|
|
727
|
+
isLogMeta,
|
|
548
728
|
levels,
|
|
549
729
|
log,
|
|
550
730
|
logInfo,
|
|
551
731
|
omit,
|
|
552
732
|
parseFilter,
|
|
553
733
|
pick,
|
|
734
|
+
serializeToJsonl,
|
|
554
735
|
shortLevelName,
|
|
555
736
|
shouldLog
|
|
556
737
|
};
|