ahpJsonlLogger.ts ×15

Frontier kind: Joint frontier

unlabeled · c_724e970f558f

10 tests · 11018 LOC · 46 files · introduces 1 test · 119 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
15 ranges119 lines · 1 files
Tests
1 test

Contains — complete concept membership

All code (extent)
1610 ranges11018 lines · 46 files · Browse complete extent
All tests (intent)
10 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Introduced files, introduced tests, and structurally relevant concept specializationahpJsonlLogger.ts ×4 · 17 introduced LOCahpJsonlLogger.ts ×4ahpJsonlLogger.ts ×1 · 2 introduced LOCahpJsonlLogger.ts ×1ahpJsonlLogger.test|title=AhpJsonlLogger flush waits for batched writes and ordering is preserved across drains|occurrence=1 · 0 introduced LOCahpJsonlLogger.test|titl…ahpJsonlLogger.ts ×2 · 15 introduced LOCahpJsonlLogger.ts ×2ahpJsonlLogger.test|title=AhpJsonlLogger coalesces synchronously queued log calls into a single write|occurrence=1 · 0 introduced LOCahpJsonlLogger.test|titl…ahpJsonlLogger.ts ×15 · 103 introduced LOCahpJsonlLogger.ts ×15ahpJsonlLogger.test|title=AhpJsonlLogger stringifyAhpLogEntry serialises URIs nested in arrays and objects|occurrence=1 · 0 introduced LOCahpJsonlLogger.test|titl…ahpJsonlLogger.test|title=AhpJsonlLogger stringifyAhpLogEntry round-trips raw UriComponents marked with $mid|occurrence=1 · 0 introduced LOCahpJsonlLogger.test|titl…ahpJsonlLogger.test|title=AhpJsonlLogger stringifyAhpLogEntry serialises a top-level URI as its string form|occurrence=1 · 0 introduced LOCahpJsonlLogger.test|titl…ahpJsonlLogger.ts ×1 · 2 introduced LOCahpJsonlLogger.ts ×1ahpJsonlLogger.ts ×1 · 1 introduced LOCahpJsonlLogger.ts ×1fileService.ts ×18 · 102 introduced LOCfileService.ts ×18inMemoryFilesystemProvider.ts ×7 · 56 introduced LOCinMemoryFilesystemProvid…log.ts ×72 · 446 introduced LOClog.ts ×72buffer.test|title=Buffer Performance issue with VSBuffer#slice #76076|occurrence=1 · 0 introduced LOCbuffer.test|title=Buffer…contextkey.ts ×1 · 2 introduced LOCcontextkey.ts ×1contextkey.ts ×3 · 7 introduced LOCcontextkey.ts ×3async.ts ×202 · 1247 introduced LOCasync.ts ×202contextkey.ts ×1 · 3 introduced LOCcontextkey.ts ×1contextkey.ts ×1 · 2 introduced LOCcontextkey.ts ×1contextkey.ts ×1 · 3 introduced LOCcontextkey.ts ×1contextkey.ts ×1 · 2 introduced LOCcontextkey.ts ×1contextkey.ts ×2 · 3 introduced LOCcontextkey.ts ×2contextkey.ts ×1 · 2 introduced LOCcontextkey.ts ×1contextkey.ts ×2 · 3 introduced LOCcontextkey.ts ×2contextkey.ts ×2 · 3 introduced LOCcontextkey.ts ×2contextkey.ts ×1 · 2 introduced LOCcontextkey.ts ×1contextkey.ts ×1 · 4 introduced LOCcontextkey.ts ×1contextkey.ts ×201 · 796 introduced LOCcontextkey.ts ×201files.ts ×1 · 4 introduced LOCfiles.ts ×1files.ts ×1 · 4 introduced LOCfiles.ts ×1files.ts ×1 · 4 introduced LOCfiles.ts ×1files.ts ×41 · 1348 introduced LOCfiles.ts ×41hash.ts ×17 · 74 introduced LOChash.ts ×17ternarySearchTree.ts ×60 · 193 introduced LOCternarySearchTree.ts ×60resources.ts ×23 · 253 introduced LOCresources.ts ×23network.ts ×20 · 292 introduced LOCnetwork.ts ×20strings.test|title=Strings trimWhitespace|occurrence=1 · 0 introduced LOCstrings.test|title=Strin…extpath.ts ×17 · 91 introduced LOCextpath.ts ×17instantiation.ts ×1 · 1 introduced LOCinstantiation.ts ×1strings.ts ×101 · 542 introduced LOCstrings.ts ×101cancellation.test|title=CancellationToken None|occurrence=1 · 0 introduced LOCcancellation.test|title=…cancellation.ts ×18 · 90 introduced LOCcancellation.ts ×18event.ts ×1 · 1 introduced LOCevent.ts ×1event.ts ×4 · 9 introduced LOCevent.ts ×4event.ts ×2 · 6 introduced LOCevent.ts ×2event.ts ×93 · 864 introduced LOCevent.ts ×93buffer.ts ×42 · 483 introduced LOCbuffer.ts ×42scanner.ts ×13 · 13 introduced LOCscanner.ts ×13scanner.ts ×3 · 3 introduced LOCscanner.ts ×3scanner.ts ×1 · 1 introduced LOCscanner.ts ×1scanner.ts ×1 · 1 introduced LOCscanner.ts ×1scanner.ts ×1 · 1 introduced LOCscanner.ts ×1scanner.ts ×1 · 1 introduced LOCscanner.ts ×1scanner.ts ×1 · 1 introduced LOCscanner.ts ×1scanner.ts ×1 · 1 introduced LOCscanner.ts ×1scanner.ts ×36 · 181 introduced LOCscanner.ts ×36uri.test|title=URI URI#file, win-speciale|occurrence=1, charCode.test|title=CharCode has good values|occurrence=1, +2 · 0 introduced LOCuri.test|title=URI URI#f…utils.ts ×3 · 9 introduced LOCutils.ts ×3instantiation.ts ×4 · 10 introduced LOCinstantiation.ts ×4nls.ts ×1 · 1 introduced LOCnls.ts ×1errorMessage.ts ×6 · 29 introduced LOCerrorMessage.ts ×6linkedList.ts ×13 · 44 introduced LOClinkedList.ts ×13nls.ts ×6 · 13 introduced LOCnls.ts ×6performance.ts ×6 · 84 introduced LOCperformance.ts ×6instantiation.ts ×5 · 111 introduced LOCinstantiation.ts ×5lifecycle.ts ×2 · 4 introduced LOClifecycle.ts ×2lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×4 · 8 introduced LOClifecycle.ts ×4lifecycle.ts ×6 · 16 introduced LOClifecycle.ts ×6lazy.ts ×1 · 2 introduced LOClazy.ts ×1lazy.ts ×3 · 37 introduced LOClazy.ts ×3lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1uint.ts ×2 · 43 introduced LOCuint.ts ×2lifecycle.ts ×1 · 3 introduced LOClifecycle.ts ×1map.ts ×97 · 3334 introduced LOCmap.ts ×97src/vs/base/common/arrays.ts · 949 LOCcommon/arrays.tssrc/vs/base/common/arraysFind.ts · 226 LOCcommon/arraysFind.tssrc/vs/base/common/assert.ts · 91 LOCcommon/assert.tssrc/vs/base/common/async.ts · 2749 LOCcommon/async.tssrc/vs/base/common/buffer.ts · 499 LOCcommon/buffer.tssrc/vs/base/common/cache.ts · 153 LOCcommon/cache.tssrc/vs/base/common/cancellation.ts · 206 LOCcommon/cancellation.tssrc/vs/base/common/charCode.ts · 450 LOCcommon/charCode.tssrc/vs/base/common/collections.ts · 176 LOCcommon/collections.tssrc/vs/base/common/errorMessage.ts · 113 LOCcommon/errorMessage.tssrc/vs/base/common/errors.ts · 357 LOCcommon/errors.tssrc/vs/base/common/event.ts · 1964 LOCcommon/event.tssrc/vs/base/common/extpath.ts · 433 LOCcommon/extpath.tssrc/vs/base/common/functional.ts · 32 LOCcommon/functional.tssrc/vs/base/common/hash.ts · 324 LOCcommon/hash.tssrc/vs/base/common/iterator.ts · 194 LOCcommon/iterator.tssrc/vs/base/common/lazy.ts · 57 LOCcommon/lazy.tssrc/vs/base/common/lifecycle.ts · 974 LOCcommon/lifecycle.tssrc/vs/base/common/linkedList.ts · 151 LOCcommon/linkedList.tssrc/vs/base/common/map.ts · 1016 LOCcommon/map.tssrc/vs/base/common/marshallingIds.ts · 33 LOCcommon/marshallingIds.tssrc/vs/base/common/network.ts · 440 LOCcommon/network.tssrc/vs/base/common/path.ts · 1589 LOCcommon/path.tssrc/vs/base/common/performance.ts · 149 LOCcommon/performance.tssrc/vs/base/common/platform.ts · 281 LOCcommon/platform.tssrc/vs/base/common/process.ts · 76 LOCcommon/process.tssrc/vs/base/common/resources.ts · 444 LOCcommon/resources.tssrc/vs/base/common/stopwatch.ts · 41 LOCcommon/stopwatch.tssrc/vs/base/common/stream.ts · 790 LOCcommon/stream.tssrc/vs/base/common/strings.ts · 1413 LOCcommon/strings.tssrc/vs/base/common/symbols.ts · 9 LOCcommon/symbols.tssrc/vs/base/common/ternarySearchTree.ts · 796 LOCcommon/ternarySearchTree…src/vs/base/common/types.ts · 410 LOCcommon/types.tssrc/vs/base/common/uint.ts · 59 LOCcommon/uint.tssrc/vs/base/common/uri.ts · 754 LOCcommon/uri.tssrc/vs/base/test/common/utils.ts · 107 LOCcommon/utils.tssrc/vs/nls.ts · 244 LOCvs/nls.tssrc/vs/platform/agentHost/common/ahpJsonlLogger.ts · 261 LOCcommon/ahpJsonlLogger.tssrc/vs/platform/contextkey/common/contextkey.ts · 2183 LOCcommon/contextkey.tssrc/vs/platform/contextkey/common/scanner.ts · 384 LOCcommon/scanner.tssrc/vs/platform/files/common/fileService.ts · 1491 LOCcommon/fileService.tssrc/vs/platform/files/common/files.ts · 1658 LOCcommon/files.tssrc/vs/platform/files/common/inMemoryFilesystemProvider.ts · 358 LOCcommon/inMemoryFilesyste…src/vs/platform/files/common/io.ts · 133 LOCcommon/io.tssrc/vs/platform/instantiation/common/instantiation.ts · 130 LOCcommon/instantiation.tssrc/vs/platform/log/common/log.ts · 926 LOCcommon/log.tsbuffer.test|title=Buffer Performance issue with VSBuffer#slice #76076|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/buffer.test|title=Buffer Performance issue with VSBuffer#slice #76076|occurrence=1buffer.test|title=Buffer…cancellation.test|title=CancellationToken None|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/cancellation.test|title=CancellationToken None|occurrence=1cancellation.test|title=…charCode.test|title=CharCode has good values|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/charCode.test|title=CharCode has good values|occurrence=1charCode.test|title=Char…path.test|title=Paths (Node Implementation) path|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/path.test|title=Paths (Node Implementation) path|occurrence=1path.test|title=Paths (N…strings.test|title=Strings trimWhitespace|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/strings.test|title=Strings trimWhitespace|occurrence=1strings.test|title=Strin…uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1uri.test|title=URI File …uri.test|title=URI URI#file, win-speciale|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI URI#file, win-speciale|occurrence=1uri.test|title=URI URI#f…ahpJsonlLogger.test|title=AhpJsonlLogger coalesces synchronously queued log calls into a single write|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/common/ahpJsonlLogger.test|title=AhpJsonlLogger coalesces synchronously queued log calls into a single write|occurrence=1ahpJsonlLogger.test|titl…ahpJsonlLogger.test|title=AhpJsonlLogger elides oversized string payloads while keeping the line valid JSONL|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/common/ahpJsonlLogger.test|title=AhpJsonlLogger elides oversized string payloads while keeping the line valid JSONL|occurrence=1ahpJsonlLogger.test|titl…ahpJsonlLogger.test|title=AhpJsonlLogger flush waits for batched writes and ordering is preserved across drains|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/common/ahpJsonlLogger.test|title=AhpJsonlLogger flush waits for batched writes and ordering is preserved across drains|occurrence=1ahpJsonlLogger.test|titl…ahpJsonlLogger.test|title=AhpJsonlLogger rotates JSONL files and keeps bounded history|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/common/ahpJsonlLogger.test|title=AhpJsonlLogger rotates JSONL files and keeps bounded history|occurrence=1ahpJsonlLogger.test|titl…ahpJsonlLogger.test|title=AhpJsonlLogger stringifyAhpLogEntry does not misidentify non-URI objects that carry $mid: 1|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/common/ahpJsonlLogger.test|title=AhpJsonlLogger stringifyAhpLogEntry does not misidentify non-URI objects that carry $mid: 1|occurrence=1ahpJsonlLogger.test|titl…ahpJsonlLogger.test|title=AhpJsonlLogger stringifyAhpLogEntry leaves URI-shaped objects without $mid as plain objects|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/common/ahpJsonlLogger.test|title=AhpJsonlLogger stringifyAhpLogEntry leaves URI-shaped objects without $mid as plain objects|occurrence=1ahpJsonlLogger.test|titl…ahpJsonlLogger.test|title=AhpJsonlLogger stringifyAhpLogEntry round-trips raw UriComponents marked with $mid|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/common/ahpJsonlLogger.test|title=AhpJsonlLogger stringifyAhpLogEntry round-trips raw UriComponents marked with $mid|occurrence=1ahpJsonlLogger.test|titl…ahpJsonlLogger.test|title=AhpJsonlLogger stringifyAhpLogEntry serialises URIs nested in arrays and objects|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/common/ahpJsonlLogger.test|title=AhpJsonlLogger stringifyAhpLogEntry serialises URIs nested in arrays and objects|occurrence=1ahpJsonlLogger.test|titl…ahpJsonlLogger.test|title=AhpJsonlLogger stringifyAhpLogEntry serialises a top-level URI as its string form|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/common/ahpJsonlLogger.test|title=AhpJsonlLogger stringifyAhpLogEntry serialises a top-level URI as its string form|occurrence=1ahpJsonlLogger.test|titl…ahpJsonlLogger.test|title=AhpJsonlLogger writes canonical JSON-RPC JSONL with metadata at the root|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/common/ahpJsonlLogger.test|title=AhpJsonlLogger writes canonical JSON-RPC JSONL with metadata at the root|occurrence=1ahpJsonlLogger.test|titl…Focused concept · ahpJsonlLogger.ts ×15 · 119 introduced LOCahpJsonlLogger.ts ×15

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

1 test introduced at this concept.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 119 introduced LOC across 15 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/common/ahpJsonlLogger.ts 119 introduced LOC · 15 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- ahpJsonlLogger.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { VSBuffer } from '../../../base/common/buffer.js';
7 > import { Disposable } from '../../../base/common/lifecycle.js';
8 > import { MarshalledId } from '../../../base/common/marshallingIds.js';
9 > import { joinPath } from '../../../base/common/resources.js';
10 > import { isUriComponents, URI, UriComponents } from '../../../base/common/uri.js';
11 > import { IFileService, IFileStatWithMetadata } from '../../files/common/files.js';
12 > import { ILogService } from '../../log/common/log.js';
13 >
14 > export type AhpLogDirection = 'c2s' | 's2c';
15 >
16 > interface IAhpLogMeta {
17 > readonly ts: string;
18 > readonly dir: AhpLogDirection;
19 > readonly connectionId: string;
20 > readonly transport: string;
21 > readonly byteLength?: number;
22 > /** Set when oversized string values in the entry were elided (see {@link stringifyAhpLogEntryTruncated}). */
23 > truncated?: boolean;
24 > }
25 >
26 > export interface IAhpJsonlLoggerOptions {
27 > readonly logsHome: URI;
28 > readonly connectionId: string;
29 > readonly transport: string;
30 > readonly maxFileSizeBytes?: number;
31 > readonly maxFiles?: number;
32 > }
33 >
34 > const AHP_LOG_DIR = 'ahp';
35 > const DEFAULT_MAX_FILE_SIZE_BYTES = 75 * 1024 * 1024;
36 > const DEFAULT_MAX_FILES = 5;
37 > // Cap the size of any single coalesced writeFile to avoid producing huge
38 > // concatenated VSBuffers (which would just create the GC pressure we're
39 > // trying to avoid). 1 MiB strikes a balance between amortizing IPC overhead
40 > // and keeping per-write allocations modest.
41 > const MAX_BATCH_BYTES = 1024 * 1024;
42 >
43 > // A single AHP protocol message can be enormous (e.g. a `resourceRead` carrying
44 > // a base64-encoded file, or an `action` carrying a full session snapshot). We
45 > // don't want to write hundreds of MB on a single JSONL line — it bloats the log
46 > // directory and, more importantly, building/holding that line creates exactly
47 > // the GC pressure these logs are meant to help diagnose. When a serialized
48 > // entry exceeds this size we re-serialize it with oversized string values
49 > // elided so the line stays well-formed JSONL.
50 > const MAX_LOG_LINE_LENGTH = 1024 * 1024;
51 > // When trimming an oversized entry, individual string values are capped to this
52 > // length. Generous enough to keep messages useful for debugging.
53 > const MAX_LOGGED_STRING_LENGTH = 16 * 1024;
54 >
55 >
56 > export class AhpJsonlLogger extends Disposable {
57 >
58 > private readonly _directory: URI;
59 > private readonly _baseName: string;
60 > private readonly _maxFileSizeBytes: number;
61 > private readonly _maxFiles: number;
62 > private _currentFile: URI;
63 > private _currentSize = 0;
64 > private _segment = 0;
65 > private _queue = Promise.resolve();
66 > private _pending: VSBuffer[] = [];
67 > private _drainScheduled = false;
68 > private _folderCreated: Promise<IFileStatWithMetadata> | undefined;
69 >
70 > constructor(
71 private readonly _options: IAhpJsonlLoggerOptions,
72 @IFileService private readonly _fileService: IFileService,
82 this._currentFile = joinPath(this._directory, this._baseName);
83 }
85 > get resource(): URI {
86 return this._currentFile;
87 }
89 > log(message: object, dir: AhpLogDirection, byteLength?: number): void {
90 const meta: IAhpLogMeta = {
91 ts: new Date().toISOString(),
111 this._scheduleDrain();
112 }
114 > async flush(): Promise<void> {
115 // Pending entries always have a drain scheduled (see _scheduleDrain), so
116 // awaiting the queue is sufficient to flush everything submitted before
118 await this._queue;
119 }
121 > private _scheduleDrain(): void {
122 if (this._drainScheduled) {
123 return;
128 });
129 }
131 > private async _drainPending(): Promise<void> {
132 // Clear the scheduled flag before snapshotting _pending so that any log()
133 // calls happening during the awaits below will schedule a fresh drain.
179 await flushChunk();
180 }
182 > private async _rotate(): Promise<void> {
183 this._segment++;
184 const oldSegment = this._segment - this._maxFiles;
191 this._currentSize = await this._getFileSize(this._currentFile);
192 }
194 > private _resourceForSegment(segment: number): URI {
195 if (segment === 0) {
196 return joinPath(this._directory, this._baseName);
199 return joinPath(this._directory, `${currentBaseName}.${segment}.jsonl`);
200 }
202 > private async _getFileSize(resource: URI): Promise<number> {
203 try {
204 return (await this._fileService.resolve(resource)).size ?? 0;
207 }
208 }
210 >
211 > export function getAhpLogByteLength(text: string): number {
212 return VSBuffer.fromString(text).byteLength;
213 }
215 > export function stringifyAhpLogEntry(value: unknown): string {
216 > return JSON.stringify(value, _ahpReplacer);
217 > }
218 >
219 > /**
220 > * Like {@link stringifyAhpLogEntry} but additionally elides any string value
221 > * longer than {@param maxStringLength}, replacing the overflow with a short
222 > * marker. The result is still well-formed JSON, so the log remains valid JSONL.
223 > * Only used for the rare oversized entry, so the extra per-value work is fine.
224 > */
225 function stringifyAhpLogEntryTruncated(value: unknown, maxStringLength: number): string {
226 return JSON.stringify(value, function (this: unknown, key: string, val: unknown): unknown {
232 });
233 }
235 > /**
236 > * JSON.stringify replacer that converts URI values to their canonical string
237 > * form. `URI.prototype.toJSON()` runs before this replacer is invoked and
238 > * produces a {@link UriComponents}-shaped object stamped with
239 > * `$mid: MarshalledId.Uri`, which we detect here to round-trip back through
240 > * {@link URI.revive}. This avoids the expensive deep-clone tree walk that
241 > * would otherwise be required to find every URI in a message payload.
242 > */
243 > function _ahpReplacer(this: unknown, _key: string, value: unknown): unknown {
244 > if (
245 > value
246 > && typeof value === 'object'
247 > && (value as { $mid?: number }).$mid === MarshalledId.Uri
248 && isUriComponents(value)
249 > ) { ahpJsonlLogger.ts
250 return URI.revive(value as UriComponents).toString();
251 }
252 > return value; ahpJsonlLogger.ts
253 > }
254 >
255 function toFileTimestamp(date: Date): string {
256 return date.toISOString().replace(/[:.]/g, '-');
257 }
259 function sanitizeFilePart(value: string): string {
260 return value.replace(/[\\/:\*\?"<>\|\s]+/g, '-').replace(/^-+|-+$/g, '') || 'connection';