@aryan-vashishth/advanced-logger 0.1.0 → 0.3.0
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/ARCHITECTURE.md +322 -0
- package/CHANGELOG.md +73 -0
- package/README.md +186 -4
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +8 -5
- package/dist/actions.js.map +1 -1
- package/dist/config.d.ts +49 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +200 -41
- package/dist/config.js.map +1 -1
- package/dist/configFile.d.ts +26 -0
- package/dist/configFile.d.ts.map +1 -0
- package/dist/configFile.js +214 -0
- package/dist/configFile.js.map +1 -0
- package/dist/core.d.ts +6 -3
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +32 -4
- package/dist/core.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/playwright.js +1 -1
- package/dist/playwright.js.map +1 -1
- package/dist/sinks.d.ts +7 -1
- package/dist/sinks.d.ts.map +1 -1
- package/dist/sinks.js +125 -5
- package/dist/sinks.js.map +1 -1
- package/dist/theme.d.ts +4 -1
- package/dist/theme.d.ts.map +1 -1
- package/dist/theme.js +8 -3
- package/dist/theme.js.map +1 -1
- package/package.json +4 -2
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.loadedConfigFile = exports.CONFIG_FILE_NAMES = void 0;
|
|
37
|
+
exports.resolveConfigFile = resolveConfigFile;
|
|
38
|
+
exports.loadConfigFile = loadConfigFile;
|
|
39
|
+
exports.forgetConfigFile = forgetConfigFile;
|
|
40
|
+
exports.checkPatch = checkPatch;
|
|
41
|
+
const fs = __importStar(require("node:fs"));
|
|
42
|
+
const path = __importStar(require("node:path"));
|
|
43
|
+
/** Looked up in this order in the project root; the first one that exists wins. */
|
|
44
|
+
exports.CONFIG_FILE_NAMES = ['logger.config.ts', 'logger.config.js', 'logger.config.cjs', 'logger.config.json'];
|
|
45
|
+
/** Resolved path for a config file, or undefined when none exists. An explicit VOID_LOG_CONFIG must exist. */
|
|
46
|
+
function resolveConfigFile(env, cwd) {
|
|
47
|
+
const explicit = env.VOID_LOG_CONFIG;
|
|
48
|
+
if (explicit) {
|
|
49
|
+
const file = path.resolve(cwd, explicit);
|
|
50
|
+
if (!fs.existsSync(file)) {
|
|
51
|
+
throw new Error(`[advanced-logger] VOID_LOG_CONFIG points to a file that does not exist: ${file}`);
|
|
52
|
+
}
|
|
53
|
+
return file;
|
|
54
|
+
}
|
|
55
|
+
for (const name of exports.CONFIG_FILE_NAMES) {
|
|
56
|
+
const file = path.join(cwd, name);
|
|
57
|
+
if (fs.existsSync(file))
|
|
58
|
+
return file;
|
|
59
|
+
}
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Load the project config file once per process. Returns undefined when there is none (silently fine).
|
|
64
|
+
* A file that exists but throws, or has the wrong shape, throws an Error naming the file.
|
|
65
|
+
*/
|
|
66
|
+
function loadConfigFile(env, cwd) {
|
|
67
|
+
const file = resolveConfigFile(env, cwd);
|
|
68
|
+
if (file === undefined)
|
|
69
|
+
return undefined;
|
|
70
|
+
LOADED = file;
|
|
71
|
+
let value;
|
|
72
|
+
try {
|
|
73
|
+
// Lazy require, so Playwright's TypeScript hook (or Node's own type stripping) handles .ts files.
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
75
|
+
const mod = require(file);
|
|
76
|
+
value = unwrapDefault(mod);
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
throw fail(file, err, 'could not be loaded');
|
|
80
|
+
}
|
|
81
|
+
if (typeof value === 'function') {
|
|
82
|
+
const fn = value;
|
|
83
|
+
return (cfg) => {
|
|
84
|
+
let result;
|
|
85
|
+
try {
|
|
86
|
+
result = fn(cfg);
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
throw fail(file, err, 'threw while computing the config');
|
|
90
|
+
}
|
|
91
|
+
return validatePatch(result, file, 'the function must return an object');
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return validatePatch(value, file, 'it must default-export an object or a function');
|
|
95
|
+
}
|
|
96
|
+
let LOADED;
|
|
97
|
+
/** Absolute path of the config file loaded in this process, if any. */
|
|
98
|
+
const loadedConfigFile = () => LOADED;
|
|
99
|
+
exports.loadedConfigFile = loadedConfigFile;
|
|
100
|
+
/** Drop the cached module so the next load re-reads the file (tests, resetConfig). */
|
|
101
|
+
function forgetConfigFile() {
|
|
102
|
+
if (LOADED !== undefined) {
|
|
103
|
+
try {
|
|
104
|
+
delete require.cache[require.resolve(LOADED)];
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
/* not cached */
|
|
108
|
+
}
|
|
109
|
+
LOADED = undefined;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/** `export default x` (transpiled or native), `module.exports = x`, and plain JSON all end up as x. */
|
|
113
|
+
function unwrapDefault(mod) {
|
|
114
|
+
if (mod !== null && typeof mod === 'object' && mod.__esModule) {
|
|
115
|
+
return mod.default;
|
|
116
|
+
}
|
|
117
|
+
return mod;
|
|
118
|
+
}
|
|
119
|
+
function fail(file, err, what) {
|
|
120
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
121
|
+
return new Error(`[advanced-logger] Config file ${file} ${what}: ${msg}`, { cause: err });
|
|
122
|
+
}
|
|
123
|
+
// -- Shape validation ----------------------------------------------------------
|
|
124
|
+
const isPlainObject = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
125
|
+
const bool = (v) => typeof v === 'boolean';
|
|
126
|
+
const str = (v) => typeof v === 'string';
|
|
127
|
+
const strList = (v) => (Array.isArray(v) || v instanceof Set) && [...v].every((x) => typeof x === 'string');
|
|
128
|
+
const strArr = (v) => Array.isArray(v) && v.every((x) => typeof x === 'string');
|
|
129
|
+
const oneOf = (...allowed) => (v) => typeof v === 'string' && allowed.includes(v);
|
|
130
|
+
const KEYS = {
|
|
131
|
+
level: [oneOf('debug', 'info', 'warn', 'error', 'off'), "one of 'debug' | 'info' | 'warn' | 'error' | 'off'"],
|
|
132
|
+
ansi: [bool, 'a boolean'],
|
|
133
|
+
fg: [bool, 'a boolean'],
|
|
134
|
+
bg: [bool, 'a boolean'],
|
|
135
|
+
infoLogsCharLimit: [(v) => v === null || (typeof v === 'number' && Number.isFinite(v) && v >= 0), 'a number >= 0 or null'],
|
|
136
|
+
maxLogFiles: [(v) => v === null || (Number.isInteger(v) && v >= 0), 'an integer >= 0 or null'],
|
|
137
|
+
maxRuns: [(v) => v === null || (Number.isInteger(v) && v >= 0), 'an integer >= 0 or null'],
|
|
138
|
+
consoleWorker: [bool, 'a boolean'],
|
|
139
|
+
consoleTest: [bool, 'a boolean'],
|
|
140
|
+
callerColor: [bool, 'a boolean'],
|
|
141
|
+
tsFormat: [(v) => str(v) || typeof v === 'function', 'a string or a function'],
|
|
142
|
+
segmentDivider: [str, 'a string'],
|
|
143
|
+
tableCellLimit: [(v) => typeof v === 'number' && Number.isFinite(v), 'a finite number'],
|
|
144
|
+
tableCellLimitEnabled: [bool, 'a boolean'],
|
|
145
|
+
suppressContains: [strList, 'an array of strings'],
|
|
146
|
+
suppressMethodPrefixes: [strList, 'an array of strings'],
|
|
147
|
+
includeOnlyPrefixes: [strList, 'an array of strings'],
|
|
148
|
+
projectRoots: [strArr, 'an array of strings'],
|
|
149
|
+
console: [bool, 'a boolean'],
|
|
150
|
+
files: [isPlainObject, 'an object'],
|
|
151
|
+
logDir: [str, 'a string'],
|
|
152
|
+
githubAnnotations: [bool, 'a boolean'],
|
|
153
|
+
redactKeys: [strArr, 'an array of strings'],
|
|
154
|
+
attach: [oneOf('on-failure', 'always', 'never'), "one of 'on-failure' | 'always' | 'never'"],
|
|
155
|
+
};
|
|
156
|
+
const FILE_KEYS = ['debugTrace', 'partialTrace', 'fullTrace', 'jsonl'];
|
|
157
|
+
/**
|
|
158
|
+
* Check a patch against KEYS. Every unknown key or wrong-typed value becomes a message naming `where`, and is left
|
|
159
|
+
* out of the returned patch; undefined values are dropped. Shared by config files (which throw on the first problem)
|
|
160
|
+
* and configure() (which warns and carries on).
|
|
161
|
+
*/
|
|
162
|
+
function checkPatch(value, where) {
|
|
163
|
+
const out = {};
|
|
164
|
+
const problems = [];
|
|
165
|
+
for (const [key, v] of Object.entries(value)) {
|
|
166
|
+
if (v === undefined)
|
|
167
|
+
continue;
|
|
168
|
+
const rule = KEYS[key];
|
|
169
|
+
if (!rule) {
|
|
170
|
+
problems.push(`[advanced-logger] ${where} has an unknown option '${key}'. Valid options: ${Object.keys(KEYS).join(', ')}.`);
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (!rule[0](v)) {
|
|
174
|
+
problems.push(`[advanced-logger] ${where}: option '${key}' must be ${rule[1]} (got ${describe(v)}).`);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (key === 'files') {
|
|
178
|
+
const files = {};
|
|
179
|
+
for (const [fk, fv] of Object.entries(v)) {
|
|
180
|
+
if (fv === undefined)
|
|
181
|
+
continue;
|
|
182
|
+
if (!FILE_KEYS.includes(fk) || typeof fv !== 'boolean') {
|
|
183
|
+
problems.push(`[advanced-logger] ${where}: option 'files.${fk}' must be a boolean and one of ${FILE_KEYS.join(', ')}.`);
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
files[fk] = fv;
|
|
187
|
+
}
|
|
188
|
+
out[key] = files;
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
out[key] = v;
|
|
192
|
+
}
|
|
193
|
+
return { patch: out, problems };
|
|
194
|
+
}
|
|
195
|
+
/** Unknown keys are rejected (a typo such as `levl` must not be silently ignored); undefined values are dropped. */
|
|
196
|
+
function validatePatch(value, file, hint) {
|
|
197
|
+
if (!isPlainObject(value)) {
|
|
198
|
+
throw new Error(`[advanced-logger] Config file ${file} has an invalid shape: ${hint} (got ${describe(value)}).`);
|
|
199
|
+
}
|
|
200
|
+
const { patch, problems } = checkPatch(value, `Config file ${file}`);
|
|
201
|
+
if (problems.length > 0)
|
|
202
|
+
throw new Error(problems[0]);
|
|
203
|
+
return patch;
|
|
204
|
+
}
|
|
205
|
+
function describe(v) {
|
|
206
|
+
if (v === null)
|
|
207
|
+
return 'null';
|
|
208
|
+
if (Array.isArray(v))
|
|
209
|
+
return 'an array';
|
|
210
|
+
if (typeof v === 'string')
|
|
211
|
+
return `string ${JSON.stringify(v)}`;
|
|
212
|
+
return typeof v === 'object' ? 'an object' : `${typeof v} ${String(v)}`;
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=configFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configFile.js","sourceRoot":"","sources":["../src/configFile.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,8CAcC;AAMD,wCA4BC;AAQD,4CASC;AA6DD,gCA8BC;AAtKD,4CAA8B;AAC9B,gDAAkC;AAGlC,mFAAmF;AACtE,QAAA,iBAAiB,GAAG,CAAC,kBAAkB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,oBAAoB,CAAU,CAAC;AAI9H,8GAA8G;AAC9G,SAAgB,iBAAiB,CAAC,GAAsB,EAAE,GAAW;IACnE,MAAM,QAAQ,GAAG,GAAG,CAAC,eAAe,CAAC;IACrC,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QACzC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,2EAA2E,IAAI,EAAE,CAAC,CAAC;QACrG,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,yBAAiB,EAAE,CAAC;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAClC,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;YAAE,O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,EAAE,CAAC;AAC1E,CAAC"}
|
package/dist/core.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { type LevelName,
|
|
2
|
-
/**
|
|
3
|
-
|
|
1
|
+
import { type LevelName, LogIntent } from './theme';
|
|
2
|
+
/**
|
|
3
|
+
* Tag subsequent events with the running test: `test` (the full path) goes to jsonl records, `title` (default: `test`)
|
|
4
|
+
* to the consoleTest prefix. Set by the Playwright fixture.
|
|
5
|
+
*/
|
|
6
|
+
export declare function setTestContext(test: string | undefined, title?: string): void;
|
|
4
7
|
export declare const getTestContext: () => string | undefined;
|
|
5
8
|
/**
|
|
6
9
|
* Single funnel for every log call. Sinks are asked first so no stack is captured
|
package/dist/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAgB,MAAM,SAAS,CAAC;AAKlE;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAG7E;AACD,eAAO,MAAM,cAAc,QAAO,MAAM,GAAG,SAAwB,CAAC;AAEpE;;;GAGG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,SAAS,GAAG,IAAI,EACxB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACjC,IAAI,CA2BN;AAuCD,wBAAgB,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM,CAElE"}
|
package/dist/core.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTestContext =
|
|
3
|
+
exports.getTestContext = void 0;
|
|
4
|
+
exports.setTestContext = setTestContext;
|
|
4
5
|
exports.dispatch = dispatch;
|
|
5
6
|
exports.themed = themed;
|
|
6
7
|
const caller_1 = require("./caller");
|
|
@@ -8,9 +9,15 @@ const config_1 = require("./config");
|
|
|
8
9
|
const sinks_1 = require("./sinks");
|
|
9
10
|
const theme_1 = require("./theme");
|
|
10
11
|
let currentTest;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
let currentTitle;
|
|
13
|
+
/**
|
|
14
|
+
* Tag subsequent events with the running test: `test` (the full path) goes to jsonl records, `title` (default: `test`)
|
|
15
|
+
* to the consoleTest prefix. Set by the Playwright fixture.
|
|
16
|
+
*/
|
|
17
|
+
function setTestContext(test, title) {
|
|
18
|
+
currentTest = test;
|
|
19
|
+
currentTitle = test === undefined ? undefined : (title ?? test);
|
|
20
|
+
}
|
|
14
21
|
const getTestContext = () => currentTest;
|
|
15
22
|
exports.getTestContext = getTestContext;
|
|
16
23
|
/**
|
|
@@ -18,6 +25,26 @@ exports.getTestContext = getTestContext;
|
|
|
18
25
|
* when nothing would write the event.
|
|
19
26
|
*/
|
|
20
27
|
function dispatch(level, intent, color, label, message) {
|
|
28
|
+
const cfg = (0, config_1.config)();
|
|
29
|
+
const limit = cfg.infoLogsCharLimit;
|
|
30
|
+
// Only INFO lines that the console would show, and never pre-colored blocks (tables, which have tableCellLimit).
|
|
31
|
+
if (level === 'INFO' &&
|
|
32
|
+
intent !== null &&
|
|
33
|
+
limit != null &&
|
|
34
|
+
limit > 0 &&
|
|
35
|
+
message != null &&
|
|
36
|
+
message.length > limit &&
|
|
37
|
+
(0, config_1.levelEnabled)(cfg.level, 'INFO')) {
|
|
38
|
+
const total = message.length;
|
|
39
|
+
emit(level, intent, color, label, `${message.slice(0, limit)}... (${total} chars)`);
|
|
40
|
+
emit('WARN', theme_1.LogIntent.BASE, themed('WARN', theme_1.LogIntent.BASE), 'WARN', `INFO log exceeded the ${limit} char threshold (${total} chars). Refer to the debug logs to see the full text. ${(0, config_1.infoLimitHint)()}`);
|
|
41
|
+
// A plain log() line is labelled with its own level; the full-text copy is a DEBUG line, so relabel it.
|
|
42
|
+
emit('DEBUG', intent, themed('DEBUG', intent), label === level ? 'DEBUG' : label, message);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
emit(level, intent, color, label, message);
|
|
46
|
+
}
|
|
47
|
+
function emit(level, intent, color, label, message) {
|
|
21
48
|
const cfg = (0, config_1.config)();
|
|
22
49
|
const sinks = (0, sinks_1.activeSinks)().filter((s) => s.accepts(level, cfg));
|
|
23
50
|
if (sinks.length === 0)
|
|
@@ -36,6 +63,7 @@ function dispatch(level, intent, color, label, message) {
|
|
|
36
63
|
chain,
|
|
37
64
|
worker: (0, config_1.workerLabel)(),
|
|
38
65
|
test: currentTest,
|
|
66
|
+
testTitle: currentTitle,
|
|
39
67
|
};
|
|
40
68
|
for (const s of sinks) {
|
|
41
69
|
try {
|
package/dist/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;AAYA,wCAGC;AAOD,4BAiCC;AAuCD,wBAEC;AAhGD,qCAAyC;AACzC,qCAAsF;AACtF,mCAAqD;AACrD,mCAAkE;AAElE,IAAI,WAA+B,CAAC;AACpC,IAAI,YAAgC,CAAC;AAErC;;;GAGG;AACH,SAAgB,cAAc,CAAC,IAAwB,EAAE,KAAc;IACrE,WAAW,GAAG,IAAI,CAAC;IACnB,YAAY,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK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AM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1D,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { debug, info, warn, error } from './logger';
|
|
2
2
|
export { LogActions, fields, formatValue } from './actions';
|
|
3
3
|
export type { Fields, Row } from './actions';
|
|
4
|
-
export { config, configure, resetConfig, initRun, getRun, workerLabel, enableAnsi, disableAnsi, isAnsiEnabled, enableCallerColor, disableCallerColor, isCallerColorEnabled, isDebugEnabled, includeOnlyPackages, suppressClassContains, suppressMethodPrefix, clearIncludes, setTableCellLimit, disableTableCellLimit, detectAnsiSupport, } from './config';
|
|
4
|
+
export { config, configure, defineConfig, resetConfig, initRun, getRun, workerLabel, runIdMissing, enableAnsi, disableAnsi, isAnsiEnabled, enableFg, disableFg, isFgEnabled, enableBg, disableBg, isBgEnabled, enableCallerColor, disableCallerColor, isCallerColorEnabled, isDebugEnabled, includeOnlyPackages, suppressClassContains, suppressMethodPrefix, clearIncludes, setTableCellLimit, disableTableCellLimit, detectAnsiSupport, } from './config';
|
|
5
5
|
export type { LogConfig, LogConfigPatch, RootLevel, AttachPolicy, FileToggles } from './config';
|
|
6
6
|
export { LogIntent } from './theme';
|
|
7
7
|
export type { LevelName } from './theme';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC5D,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EACL,MAAM,EACN,SAAS,EACT,WAAW,EACX,OAAO,EACP,MAAM,EACN,WAAW,EACX,UAAU,EACV,WAAW,EACX,a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qBAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAChG,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACzF,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.traceFilePath = exports.closeAllFiles = exports.captureLogs = exports.removeSink = exports.addSink = exports.getTestContext = exports.setTestContext = exports.fgFromStyle = exports.stripAnsi = exports.LogIntent = exports.detectAnsiSupport = exports.disableTableCellLimit = exports.setTableCellLimit = exports.clearIncludes = exports.suppressMethodPrefix = exports.suppressClassContains = exports.includeOnlyPackages = exports.isDebugEnabled = exports.isCallerColorEnabled = exports.disableCallerColor = exports.enableCallerColor = exports.isAnsiEnabled = exports.disableAnsi = exports.enableAnsi = exports.workerLabel = exports.getRun = exports.initRun = exports.resetConfig = exports.configure = exports.config = exports.formatValue = exports.fields = exports.LogActions = exports.error = exports.warn = exports.info = exports.debug = void 0;
|
|
3
|
+
exports.traceFilePath = exports.closeAllFiles = exports.captureLogs = exports.removeSink = exports.addSink = exports.getTestContext = exports.setTestContext = exports.fgFromStyle = exports.stripAnsi = exports.LogIntent = exports.detectAnsiSupport = exports.disableTableCellLimit = exports.setTableCellLimit = exports.clearIncludes = exports.suppressMethodPrefix = exports.suppressClassContains = exports.includeOnlyPackages = exports.isDebugEnabled = exports.isCallerColorEnabled = exports.disableCallerColor = exports.enableCallerColor = exports.isBgEnabled = exports.disableBg = exports.enableBg = exports.isFgEnabled = exports.disableFg = exports.enableFg = exports.isAnsiEnabled = exports.disableAnsi = exports.enableAnsi = exports.runIdMissing = exports.workerLabel = exports.getRun = exports.initRun = exports.resetConfig = exports.defineConfig = exports.configure = exports.config = exports.formatValue = exports.fields = exports.LogActions = exports.error = exports.warn = exports.info = exports.debug = void 0;
|
|
4
4
|
var logger_1 = require("./logger");
|
|
5
5
|
Object.defineProperty(exports, "debug", { enumerable: true, get: function () { return logger_1.debug; } });
|
|
6
6
|
Object.defineProperty(exports, "info", { enumerable: true, get: function () { return logger_1.info; } });
|
|
@@ -13,13 +13,21 @@ Object.defineProperty(exports, "formatValue", { enumerable: true, get: function
|
|
|
13
13
|
var config_1 = require("./config");
|
|
14
14
|
Object.defineProperty(exports, "config", { enumerable: true, get: function () { return config_1.config; } });
|
|
15
15
|
Object.defineProperty(exports, "configure", { enumerable: true, get: function () { return config_1.configure; } });
|
|
16
|
+
Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return config_1.defineConfig; } });
|
|
16
17
|
Object.defineProperty(exports, "resetConfig", { enumerable: true, get: function () { return config_1.resetConfig; } });
|
|
17
18
|
Object.defineProperty(exports, "initRun", { enumerable: true, get: function () { return config_1.initRun; } });
|
|
18
19
|
Object.defineProperty(exports, "getRun", { enumerable: true, get: function () { return config_1.getRun; } });
|
|
19
20
|
Object.defineProperty(exports, "workerLabel", { enumerable: true, get: function () { return config_1.workerLabel; } });
|
|
21
|
+
Object.defineProperty(exports, "runIdMissing", { enumerable: true, get: function () { return config_1.runIdMissing; } });
|
|
20
22
|
Object.defineProperty(exports, "enableAnsi", { enumerable: true, get: function () { return config_1.enableAnsi; } });
|
|
21
23
|
Object.defineProperty(exports, "disableAnsi", { enumerable: true, get: function () { return config_1.disableAnsi; } });
|
|
22
24
|
Object.defineProperty(exports, "isAnsiEnabled", { enumerable: true, get: function () { return config_1.isAnsiEnabled; } });
|
|
25
|
+
Object.defineProperty(exports, "enableFg", { enumerable: true, get: function () { return config_1.enableFg; } });
|
|
26
|
+
Object.defineProperty(exports, "disableFg", { enumerable: true, get: function () { return config_1.disableFg; } });
|
|
27
|
+
Object.defineProperty(exports, "isFgEnabled", { enumerable: true, get: function () { return config_1.isFgEnabled; } });
|
|
28
|
+
Object.defineProperty(exports, "enableBg", { enumerable: true, get: function () { return config_1.enableBg; } });
|
|
29
|
+
Object.defineProperty(exports, "disableBg", { enumerable: true, get: function () { return config_1.disableBg; } });
|
|
30
|
+
Object.defineProperty(exports, "isBgEnabled", { enumerable: true, get: function () { return config_1.isBgEnabled; } });
|
|
23
31
|
Object.defineProperty(exports, "enableCallerColor", { enumerable: true, get: function () { return config_1.enableCallerColor; } });
|
|
24
32
|
Object.defineProperty(exports, "disableCallerColor", { enumerable: true, get: function () { return config_1.disableCallerColor; } });
|
|
25
33
|
Object.defineProperty(exports, "isCallerColorEnabled", { enumerable: true, get: function () { return config_1.isCallerColorEnabled; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAoD;AAA3C,+FAAA,KAAK,OAAA;AAAE,8FAAA,IAAI,OAAA;AAAE,8FAAA,IAAI,OAAA;AAAE,+FAAA,KAAK,OAAA;AACjC,qCAA4D;AAAnD,qGAAA,UAAU,OAAA;AAAE,iGAAA,MAAM,OAAA;AAAE,sGAAA,WAAW,OAAA;AAExC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAoD;AAA3C,+FAAA,KAAK,OAAA;AAAE,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
|
@@ -18,7 +18,7 @@ const logger_1 = require("./logger");
|
|
|
18
18
|
exports.test = test_1.test.extend({
|
|
19
19
|
voidLog: [
|
|
20
20
|
async ({}, use, testInfo) => {
|
|
21
|
-
(0, core_1.setTestContext)(testInfo.titlePath.join(' > '));
|
|
21
|
+
(0, core_1.setTestContext)(testInfo.titlePath.join(' > '), testInfo.title);
|
|
22
22
|
const capture = (0, sinks_1.captureLogs)();
|
|
23
23
|
logger_1.info.log(`TEST START | ${testInfo.titlePath.join(' > ')}`);
|
|
24
24
|
try {
|
package/dist/playwright.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playwright.js","sourceRoot":"","sources":["../src/playwright.ts"],"names":[],"mappings":";;;AAAA,2CAAwD;AAwC/C,uFAxCc,aAAM,OAwCd;AAvCf,qCAAkC;AAClC,iCAAwC;AACxC,mCAAsC;AACtC,qCAAuC;AAEvC;;;;;;;GAOG;AACU,QAAA,IAAI,GAAG,WAAI,CAAC,MAAM,CAAoB;IACjD,OAAO,EAAE;QACP,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE;YAC1B,IAAA,qBAAc,EAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YAC/
|
|
1
|
+
{"version":3,"file":"playwright.js","sourceRoot":"","sources":["../src/playwright.ts"],"names":[],"mappings":";;;AAAA,2CAAwD;AAwC/C,uFAxCc,aAAM,OAwCd;AAvCf,qCAAkC;AAClC,iCAAwC;AACxC,mCAAsC;AACtC,qCAAuC;AAEvC;;;;;;;GAOG;AACU,QAAA,IAAI,GAAG,WAAI,CAAC,MAAM,CAAoB;IACjD,OAAO,EAAE;QACP,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE;YAC1B,IAAA,qBAAc,EAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC/D,MAAM,OAAO,GAAG,IAAA,mBAAW,GAAE,CAAC;YAC9B,aAAI,CAAC,GAAG,CAAC,gBAAgB,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC3D,IAAI,CAAC;gBACH,MAAM,GAAG,EAAE,CAAC;YACd,CAAC;oBAAS,CAAC;gBACT,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,cAAc,CAAC;gBAC3D,MAAM,IAAI,GAAG,cAAc,QAAQ,CAAC,MAAM,MAAM,QAAQ,CAAC,QAAQ,IAAI,CAAC;gBACtE,IAAI,MAAM;oBAAE,cAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;;oBAC1B,aAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBAExB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;gBAC5B,MAAM,MAAM,GAAG,IAAA,eAAM,GAAE,CAAC,MAAM,CAAC;gBAC/B,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,CAAC,MAAM,KAAK,YAAY,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC;oBACzE,MAAM,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC,CAAC;gBAC/E,CAAC;gBACD,IAAA,qBAAc,EAAC,SAAS,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;QACD,EAAE,IAAI,EAAE,IAAI,EAAE;KACf;CACF,CAAC,CAAC;AAGH,mCAAmC;AAA1B,iGAAA,OAAO,OAAA"}
|
package/dist/sinks.d.ts
CHANGED
|
@@ -11,14 +11,17 @@ export interface LogEvent {
|
|
|
11
11
|
label: string;
|
|
12
12
|
/** Full message, may be multi-line. */
|
|
13
13
|
message: string;
|
|
14
|
-
/** Resolved theme style (intentFg + levelBg). Ignored when ANSI is off. */
|
|
14
|
+
/** Resolved theme style (intentFg + levelBg, per the fg/bg toggles; '' when none). Ignored when ANSI is off. */
|
|
15
15
|
color: string;
|
|
16
16
|
/** Plain "Callee <- Caller" text, empty when unresolved. */
|
|
17
17
|
caller: string;
|
|
18
18
|
/** Plain in-project chain, empty when unresolved. */
|
|
19
19
|
chain: string;
|
|
20
20
|
worker: string;
|
|
21
|
+
/** Full test path ("file > describe > title"), as recorded in jsonl. */
|
|
21
22
|
test?: string;
|
|
23
|
+
/** Short test label for the console (the test's own title). */
|
|
24
|
+
testTitle?: string;
|
|
22
25
|
}
|
|
23
26
|
export interface Sink {
|
|
24
27
|
/** Cheap check run before any stack capture; return false to skip the event entirely. */
|
|
@@ -26,8 +29,11 @@ export interface Sink {
|
|
|
26
29
|
write(ev: LogEvent, cfg: LogConfig): void;
|
|
27
30
|
}
|
|
28
31
|
export declare const splitLines: (m: string) => string[];
|
|
32
|
+
export declare const TEST_TAG_MAX = 40;
|
|
29
33
|
export declare const consoleSink: Sink;
|
|
30
34
|
type FileKind = 'debug-trace' | 'partial-trace' | 'full-trace';
|
|
35
|
+
/** A run with any file modified this recently may still be writing (another runner, a CI shard): never pruned. */
|
|
36
|
+
export declare const RECENT_RUN_MS: number;
|
|
31
37
|
export declare function closeAllFiles(): void;
|
|
32
38
|
export declare function traceFilePath(cfg: LogConfig, kind: FileKind | 'jsonl', ext?: string): string;
|
|
33
39
|
export declare const partialTraceSink: Sink;
|
package/dist/sinks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sinks.d.ts","sourceRoot":"","sources":["../src/sinks.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"sinks.d.ts","sourceRoot":"","sources":["../src/sinks.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAAkF,MAAM,UAAU,CAAC;AAC1H,OAAO,EAAa,KAAK,SAAS,EAAE,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MAE5B,CAAC;AAEF,eAAO,MAAM,cAAc,MAK1B,CAAC;AAEF,eAAO,MAAM,aAAa,MAKzB,CAAC;AAIF,eAAO,MAAM,SAAS,EAAE,IAkBvB,CAAC;AAIF,MAAM,WAAW,OAAO;IACtB,8DAA8D;IAC9D,IAAI,IAAI,MAAM,CAAC;IACf,IAAI,IAAI,MAAM,CAAC;CAChB;AAID,eAAO,MAAM,WAAW,EAAE,IAMzB,CAAC;AAEF,wBAAgB,WAAW,IAAI,OAAO,CAUrC;AAKD,eAAO,MAAM,OAAO,GAAI,GAAG,IAAI,KAAG,IAA0B,CAAC;AAC7D,eAAO,MAAM,UAAU,GAAI,GAAG,IAAI,KAAG,IAA6B,CAAC;AAEnE,wBAAgB,WAAW,IAAI,IAAI,EAAE,CAEpC"}
|
package/dist/sinks.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.removeSink = exports.addSink = exports.captureSink = exports.jsonlSink = exports.fullTraceSink = exports.debugTraceSink = exports.partialTraceSink = exports.consoleSink = exports.splitLines = void 0;
|
|
36
|
+
exports.removeSink = exports.addSink = exports.captureSink = exports.jsonlSink = exports.fullTraceSink = exports.debugTraceSink = exports.partialTraceSink = exports.RECENT_RUN_MS = exports.consoleSink = exports.TEST_TAG_MAX = exports.splitLines = void 0;
|
|
37
37
|
exports.closeAllFiles = closeAllFiles;
|
|
38
38
|
exports.traceFilePath = traceFilePath;
|
|
39
39
|
exports.captureLogs = captureLogs;
|
|
@@ -56,6 +56,16 @@ function githubCommand(ev) {
|
|
|
56
56
|
return null;
|
|
57
57
|
}
|
|
58
58
|
const escapeGithub = (t) => t.replace(/%/g, '%25').replace(/\r/g, '%0D').replace(/\n/g, '%0A');
|
|
59
|
+
exports.TEST_TAG_MAX = 40;
|
|
60
|
+
/** The opt-in "w1 │ test title │ " console prefix. The worker part matches the trace files' prefix. */
|
|
61
|
+
function consolePrefix(ev, cfg) {
|
|
62
|
+
let p = cfg.consoleWorker ? `${ev.worker} │ ` : '';
|
|
63
|
+
if (cfg.consoleTest && ev.testTitle) {
|
|
64
|
+
const t = ev.testTitle.replace(config_1.LINE_BREAKS, ' ');
|
|
65
|
+
p += (t.length > exports.TEST_TAG_MAX ? t.slice(0, exports.TEST_TAG_MAX - 3) + '...' : t) + ' │ ';
|
|
66
|
+
}
|
|
67
|
+
return p;
|
|
68
|
+
}
|
|
59
69
|
exports.consoleSink = {
|
|
60
70
|
accepts: (level, cfg) => cfg.console && (0, config_1.levelEnabled)(cfg.level, level),
|
|
61
71
|
write(ev, cfg) {
|
|
@@ -63,16 +73,20 @@ exports.consoleSink = {
|
|
|
63
73
|
const showCaller = (0, config_1.levelEnabled)(cfg.level, 'DEBUG');
|
|
64
74
|
const callerText = showCaller ? ev.caller : '';
|
|
65
75
|
const lines = (0, exports.splitLines)(ev.message);
|
|
76
|
+
const prefix = consolePrefix(ev, cfg);
|
|
66
77
|
const out = [];
|
|
67
78
|
lines.forEach((line, i) => {
|
|
68
|
-
const b = body(ev, cfg, line);
|
|
79
|
+
const b = prefix + body(ev, cfg, line);
|
|
69
80
|
const first = i === 0 && callerText !== '';
|
|
70
81
|
let text;
|
|
71
82
|
if (cfg.ansi) {
|
|
83
|
+
// ev.color is '' when fg and bg are both off: leave the body bare rather than emit a lone reset.
|
|
84
|
+
const wrap = (s) => (ev.color ? ev.color + s + theme_1.THEME_RESET : s);
|
|
85
|
+
// callerColor is its own opt-in and is not gated by fg/bg (only ansi=false silences it).
|
|
72
86
|
text =
|
|
73
87
|
first && cfg.callerColor
|
|
74
|
-
?
|
|
75
|
-
:
|
|
88
|
+
? wrap(b) + div + theme_1.CALLER_FG + callerText + theme_1.THEME_RESET
|
|
89
|
+
: wrap(b + (first ? div + callerText : ''));
|
|
76
90
|
}
|
|
77
91
|
else {
|
|
78
92
|
text = b + (first ? div + callerText : '');
|
|
@@ -80,7 +94,7 @@ exports.consoleSink = {
|
|
|
80
94
|
out.push(text);
|
|
81
95
|
if (cfg.githubAnnotations) {
|
|
82
96
|
const cmd = githubCommand(ev);
|
|
83
|
-
const plain = ev.ts + div + line;
|
|
97
|
+
const plain = prefix + ev.ts + div + line;
|
|
84
98
|
if (cmd && plain.trim() !== '')
|
|
85
99
|
out.push(`::${cmd}::${escapeGithub(plain)}`);
|
|
86
100
|
}
|
|
@@ -102,7 +116,110 @@ function fdFor(file) {
|
|
|
102
116
|
function appendSync(file, text) {
|
|
103
117
|
fs.writeSync(fdFor(file), text);
|
|
104
118
|
}
|
|
119
|
+
/** Trace kinds already pruned by this process (once per kind, at its first write). */
|
|
120
|
+
const PRUNED = new Set();
|
|
121
|
+
/** A run with any file modified this recently may still be writing (another runner, a CI shard): never pruned. */
|
|
122
|
+
exports.RECENT_RUN_MS = 60 * 60 * 1000;
|
|
123
|
+
let RUN_ID_WARNED = false;
|
|
124
|
+
/** One stderr warning per process when a Playwright worker has no shared run id (initRun() was never called). */
|
|
125
|
+
function warnIfRunIdMissing() {
|
|
126
|
+
if (RUN_ID_WARNED || !(0, config_1.runIdMissing)())
|
|
127
|
+
return;
|
|
128
|
+
RUN_ID_WARNED = true;
|
|
129
|
+
process.stderr.write(`[advanced-logger] ${(0, config_1.workerLabel)()}: VOID_RUN_ID is not set, so this worker's log files use their own run id ` +
|
|
130
|
+
'and log retention is off in this process. Call initRun() from your Playwright globalSetup.\n');
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Retention per trace kind, across date folders: `maxLogFiles` keeps the newest N files by mtime, `maxRuns` keeps
|
|
134
|
+
* the newest N runs whole (a run is dated by its newest file). Both may be set; a file goes if either says so.
|
|
135
|
+
* Never deleted: the current run's files (parallel workers share one run id), and any run with a file modified in
|
|
136
|
+
* the last RECENT_RUN_MS. So neither limit is a hard cap. Skipped entirely in a worker without a shared run id,
|
|
137
|
+
* since its siblings' live files would look like an older run. Only files named like this logger's own output are
|
|
138
|
+
* touched. Best effort: errors never reach the caller.
|
|
139
|
+
*/
|
|
140
|
+
function pruneOnce(cfg, kind) {
|
|
141
|
+
const maxFiles = cfg.maxLogFiles != null && cfg.maxLogFiles > 0 ? cfg.maxLogFiles : null;
|
|
142
|
+
const maxRuns = cfg.maxRuns != null && cfg.maxRuns > 0 ? cfg.maxRuns : null;
|
|
143
|
+
if (maxFiles == null && maxRuns == null)
|
|
144
|
+
return;
|
|
145
|
+
if ((0, config_1.runIdMissing)())
|
|
146
|
+
return;
|
|
147
|
+
const key = `${path.resolve(cfg.logDir)}|${kind}`;
|
|
148
|
+
if (PRUNED.has(key))
|
|
149
|
+
return;
|
|
150
|
+
PRUNED.add(key);
|
|
151
|
+
try {
|
|
152
|
+
const { runId } = (0, config_1.getRun)();
|
|
153
|
+
const own = new RegExp(`^${kind}-.+\\.(log|jsonl)$`);
|
|
154
|
+
// kind-<runId>-<worker>.<ext>; a name without a worker suffix counts as its own run.
|
|
155
|
+
const runOf = (name) => new RegExp(`^${kind}-(.+)-(main|w\\d+)\\.(log|jsonl)$`).exec(name)?.[1] ?? name;
|
|
156
|
+
const files = [];
|
|
157
|
+
for (const day of fs.readdirSync(cfg.logDir, { withFileTypes: true })) {
|
|
158
|
+
if (!day.isDirectory())
|
|
159
|
+
continue;
|
|
160
|
+
const dir = path.join(cfg.logDir, day.name, kind);
|
|
161
|
+
let names;
|
|
162
|
+
try {
|
|
163
|
+
names = fs.readdirSync(dir);
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
for (const name of names) {
|
|
169
|
+
if (!own.test(name))
|
|
170
|
+
continue;
|
|
171
|
+
const file = path.join(dir, name);
|
|
172
|
+
try {
|
|
173
|
+
files.push({ file, mtime: fs.statSync(file).mtimeMs, run: runOf(name), current: name.includes(runId) });
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
/* removed by another worker */
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const newest = new Map();
|
|
181
|
+
for (const f of files)
|
|
182
|
+
newest.set(f.run, Math.max(newest.get(f.run) ?? 0, f.mtime));
|
|
183
|
+
const now = Date.now();
|
|
184
|
+
const others = files.filter((f) => !f.current);
|
|
185
|
+
const doomed = new Set();
|
|
186
|
+
if (maxFiles != null) {
|
|
187
|
+
const keep = Math.max(0, maxFiles - (files.length - others.length));
|
|
188
|
+
for (const f of [...others].sort((a, b) => b.mtime - a.mtime).slice(keep))
|
|
189
|
+
doomed.add(f);
|
|
190
|
+
}
|
|
191
|
+
if (maxRuns != null) {
|
|
192
|
+
const otherRuns = [...new Set(others.map((f) => f.run))].sort((a, b) => newest.get(b) - newest.get(a));
|
|
193
|
+
const keep = Math.max(0, maxRuns - (others.length < files.length ? 1 : 0));
|
|
194
|
+
const old = new Set(otherRuns.slice(keep));
|
|
195
|
+
for (const f of others)
|
|
196
|
+
if (old.has(f.run))
|
|
197
|
+
doomed.add(f);
|
|
198
|
+
}
|
|
199
|
+
for (const f of doomed) {
|
|
200
|
+
if (now - newest.get(f.run) < exports.RECENT_RUN_MS)
|
|
201
|
+
continue;
|
|
202
|
+
try {
|
|
203
|
+
fs.rmSync(f.file, { force: true });
|
|
204
|
+
const dir = path.dirname(f.file);
|
|
205
|
+
if (fs.readdirSync(dir).length === 0)
|
|
206
|
+
fs.rmdirSync(dir);
|
|
207
|
+
const day = path.dirname(dir);
|
|
208
|
+
if (fs.readdirSync(day).length === 0)
|
|
209
|
+
fs.rmdirSync(day);
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
/* in use, or already gone */
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
catch {
|
|
217
|
+
/* retention must never break logging */
|
|
218
|
+
}
|
|
219
|
+
}
|
|
105
220
|
function closeAllFiles() {
|
|
221
|
+
PRUNED.clear();
|
|
222
|
+
RUN_ID_WARNED = false;
|
|
106
223
|
for (const fd of FD_CACHE.values()) {
|
|
107
224
|
try {
|
|
108
225
|
fs.closeSync(fd);
|
|
@@ -114,6 +231,7 @@ function closeAllFiles() {
|
|
|
114
231
|
FD_CACHE.clear();
|
|
115
232
|
}
|
|
116
233
|
function traceFilePath(cfg, kind, ext = 'log') {
|
|
234
|
+
warnIfRunIdMissing();
|
|
117
235
|
const { runId, runDate } = (0, config_1.getRun)();
|
|
118
236
|
const w = (0, config_1.workerLabel)();
|
|
119
237
|
return path.join(cfg.logDir, runDate, kind, `${kind}-${runId}-${w}.${ext}`);
|
|
@@ -127,6 +245,7 @@ function fileSink(kind, enabled, rootOnly, render) {
|
|
|
127
245
|
return;
|
|
128
246
|
const prefix = `${ev.worker} │ `;
|
|
129
247
|
appendSync(traceFilePath(cfg, kind), lines.map((l) => `${prefix}${(0, ansi_1.stripAnsi)(l)}`).join('\n') + '\n');
|
|
248
|
+
pruneOnce(cfg, kind);
|
|
130
249
|
},
|
|
131
250
|
};
|
|
132
251
|
}
|
|
@@ -156,6 +275,7 @@ exports.jsonlSink = {
|
|
|
156
275
|
visible: (0, config_1.levelEnabled)(cfg.level, ev.level),
|
|
157
276
|
};
|
|
158
277
|
appendSync(traceFilePath(cfg, 'jsonl', 'jsonl'), JSON.stringify(rec) + '\n');
|
|
278
|
+
pruneOnce(cfg, 'jsonl');
|
|
159
279
|
},
|
|
160
280
|
};
|
|
161
281
|
const CAPTURES = new Set();
|