Repository navigation
Expand file tree
/
Copy pathsession-log-layout.ts
More file actions
60 lines (50 loc) · 2.13 KB
/
Copy pathsession-log-layout.ts
File metadata and controls
60 lines (50 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* The dependency-free naming contract for one debug session's logs.
*
* This module is bundled into the proxy worker, so it intentionally depends
* only on `node:path`. Keeping every producer, reader, and cleanup predicate
* here prevents a diagnostic path from drifting away from the file that was
* actually written.
*/
import path from 'node:path';
const RUN_DIRECTORY_PATTERN = /^run-\d+$/;
/** Directory name for one launch attempt. */
export function sessionRunDirectoryName(startedAt: number): string {
return `run-${startedAt}`;
}
/** Whether an entry is a managed launch-attempt directory. */
export function isSessionRunDirectoryName(name: string): boolean {
return RUN_DIRECTORY_PATTERN.test(name);
}
/** Absolute directory for one launch attempt of a debug session. */
export function sessionRunDirectoryFor(
sessionLogBase: string,
sessionId: string,
startedAt: number
): string {
return path.join(sessionLogBase, sessionId, sessionRunDirectoryName(startedAt));
}
/** File name (no directory) of the proxy log for one debug session. */
export function proxyLogFileName(sessionId: string): string {
return `proxy-${sessionId}.log`;
}
/** Absolute path to the proxy log for one launch attempt. */
export function proxyLogPathFor(runDirectory: string, sessionId: string): string {
return path.join(runDirectory, proxyLogFileName(sessionId));
}
/** File name (no directory) of the debug adapter log for one session. */
export function adapterLogFileName(sessionId: string): string {
return `${sessionId}.log`;
}
/** Absolute path to the debug adapter log for one launch attempt. */
export function adapterLogPathFor(runDirectory: string, sessionId: string): string {
return path.join(runDirectory, adapterLogFileName(sessionId));
}
/** File name (no directory) of the opt-in DAP protocol trace. */
export function dapTraceFileName(sessionId: string): string {
return `dap-trace-${sessionId}.ndjson`;
}
/** Absolute path to the opt-in DAP protocol trace for one launch attempt. */
export function dapTracePathFor(runDirectory: string, sessionId: string): string {
return path.join(runDirectory, dapTraceFileName(sessionId));
}