@void.01/advanced-logger 0.0.0-stage → 0.4.1
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 +342 -0
- package/CHANGELOG.md +115 -0
- package/LICENSE +21 -0
- package/README.md +308 -2
- package/dist/actions.d.ts +79 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +337 -0
- package/dist/actions.js.map +1 -0
- package/dist/ansi.d.ts +144 -0
- package/dist/ansi.d.ts.map +1 -0
- package/dist/ansi.js +219 -0
- package/dist/ansi.js.map +1 -0
- package/dist/caller.d.ts +21 -0
- package/dist/caller.d.ts.map +1 -0
- package/dist/caller.js +129 -0
- package/dist/caller.js.map +1 -0
- package/dist/config.d.ts +152 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +398 -0
- package/dist/config.js.map +1 -0
- package/dist/configFile.d.ts +31 -0
- package/dist/configFile.d.ts.map +1 -0
- package/dist/configFile.js +211 -0
- package/dist/configFile.js.map +1 -0
- package/dist/core.d.ts +17 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +89 -0
- package/dist/core.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +60 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +7 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +10 -0
- package/dist/logger.js.map +1 -0
- package/dist/playwright.d.ts +15 -0
- package/dist/playwright.d.ts.map +1 -0
- package/dist/playwright.js +47 -0
- package/dist/playwright.js.map +1 -0
- package/dist/redact.d.ts +8 -0
- package/dist/redact.d.ts.map +1 -0
- package/dist/redact.js +36 -0
- package/dist/redact.js.map +1 -0
- package/dist/sinks.d.ts +80 -0
- package/dist/sinks.d.ts.map +1 -0
- package/dist/sinks.js +461 -0
- package/dist/sinks.js.map +1 -0
- package/dist/theme.d.ts +71 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +115 -0
- package/dist/theme.js.map +1 -0
- package/package.json +51 -4
package/dist/config.js
ADDED
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.disableTableCellLimit = exports.LINE_BREAKS_NO_G = exports.LINE_BREAKS = exports.clearIncludes = 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.config = exports.levelEnabled = void 0;
|
|
4
|
+
exports.detectAnsiSupport = detectAnsiSupport;
|
|
5
|
+
exports.configure = configure;
|
|
6
|
+
exports.warnOnce = warnOnce;
|
|
7
|
+
exports.infoLimitHint = infoLimitHint;
|
|
8
|
+
exports.defineConfig = defineConfig;
|
|
9
|
+
exports.resetConfig = resetConfig;
|
|
10
|
+
exports.includeOnlyPackages = includeOnlyPackages;
|
|
11
|
+
exports.suppressClassContains = suppressClassContains;
|
|
12
|
+
exports.suppressMethodPrefix = suppressMethodPrefix;
|
|
13
|
+
exports.truncateCell = truncateCell;
|
|
14
|
+
exports.setTableCellLimit = setTableCellLimit;
|
|
15
|
+
exports.formatTs = formatTs;
|
|
16
|
+
exports.initRun = initRun;
|
|
17
|
+
exports.getRun = getRun;
|
|
18
|
+
exports.runIdMissing = runIdMissing;
|
|
19
|
+
exports.workerLabel = workerLabel;
|
|
20
|
+
const configFile_1 = require("./configFile");
|
|
21
|
+
const LEVEL_ORDER = { debug: 10, info: 20, warn: 30, error: 40, off: 99 };
|
|
22
|
+
const NAME_ORDER = { DEBUG: 10, INFO: 20, WARN: 30, ERROR: 40 };
|
|
23
|
+
const levelEnabled = (root, level) => NAME_ORDER[level] >= LEVEL_ORDER[root];
|
|
24
|
+
exports.levelEnabled = levelEnabled;
|
|
25
|
+
/** undefined for anything that is not a valid level, so an invalid env value never overrides a lower layer. */
|
|
26
|
+
function parseLevel(v) {
|
|
27
|
+
const l = (v ?? '').trim().toLowerCase();
|
|
28
|
+
return l in LEVEL_ORDER ? l : undefined;
|
|
29
|
+
}
|
|
30
|
+
function envBool(v) {
|
|
31
|
+
if (v == null || v === '')
|
|
32
|
+
return undefined;
|
|
33
|
+
return /^(1|true|yes|on)$/i.test(v);
|
|
34
|
+
}
|
|
35
|
+
/** The env-level ANSI decision: VOID_LOG_ANSI, then NO_COLOR, then FORCE_COLOR. undefined when none is set. */
|
|
36
|
+
function explicitAnsi(env) {
|
|
37
|
+
const explicit = envBool(env.VOID_LOG_ANSI);
|
|
38
|
+
if (explicit !== undefined)
|
|
39
|
+
return explicit;
|
|
40
|
+
if (env.NO_COLOR != null && env.NO_COLOR !== '')
|
|
41
|
+
return false;
|
|
42
|
+
if (env.FORCE_COLOR != null && env.FORCE_COLOR !== '')
|
|
43
|
+
return env.FORCE_COLOR !== '0' && env.FORCE_COLOR !== 'false';
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
/** TTY/terminal hints, then CI renderers that show ANSI. This is the lowest layer (a config file beats it). */
|
|
47
|
+
function heuristicAnsi(env, isTTY) {
|
|
48
|
+
if (isTTY)
|
|
49
|
+
return true;
|
|
50
|
+
if (env.GITHUB_ACTIONS === 'true')
|
|
51
|
+
return true;
|
|
52
|
+
if (env.COLORTERM)
|
|
53
|
+
return true;
|
|
54
|
+
return !!env.TERM && env.TERM !== 'dumb';
|
|
55
|
+
}
|
|
56
|
+
/** Explicit env wins, then NO_COLOR/FORCE_COLOR, then TTY/terminal hints, then CI renderers that show ANSI. */
|
|
57
|
+
function detectAnsiSupport(env = process.env, isTTY = !!process.stdout?.isTTY) {
|
|
58
|
+
return explicitAnsi(env) ?? heuristicAnsi(env, isTTY);
|
|
59
|
+
}
|
|
60
|
+
/** Built-in defaults only. Env overrides are applied separately so a config file can sit between the two. */
|
|
61
|
+
function builtinDefaults(env) {
|
|
62
|
+
return {
|
|
63
|
+
level: 'info',
|
|
64
|
+
ansi: heuristicAnsi(env, !!process.stdout?.isTTY),
|
|
65
|
+
fg: true,
|
|
66
|
+
bg: true,
|
|
67
|
+
infoLogsCharLimit: null,
|
|
68
|
+
maxLogFiles: null,
|
|
69
|
+
maxRuns: null,
|
|
70
|
+
recentRunMinutes: 60,
|
|
71
|
+
consoleWorker: false,
|
|
72
|
+
consoleTest: false,
|
|
73
|
+
callerColor: false,
|
|
74
|
+
tsFormat: 'yyyy-MM-dd HH:mm:ss.SSS',
|
|
75
|
+
segmentDivider: ' │ ',
|
|
76
|
+
tableCellLimit: 40,
|
|
77
|
+
tableCellLimitEnabled: false,
|
|
78
|
+
suppressContains: new Set(['node_modules', 'node:', '<anonymous>']),
|
|
79
|
+
suppressMethodPrefixes: new Set(),
|
|
80
|
+
includeOnlyPrefixes: new Set(),
|
|
81
|
+
projectRoots: [process.cwd()],
|
|
82
|
+
console: true,
|
|
83
|
+
files: {
|
|
84
|
+
debugTrace: true,
|
|
85
|
+
partialTrace: true,
|
|
86
|
+
fullTrace: true,
|
|
87
|
+
jsonl: false,
|
|
88
|
+
tables: true,
|
|
89
|
+
},
|
|
90
|
+
logDir: './logs',
|
|
91
|
+
githubAnnotations: env.GITHUB_ACTIONS === 'true',
|
|
92
|
+
redactKeys: ['password', 'passwd', 'secret', 'token', 'authorization', 'apikey', 'api_key'],
|
|
93
|
+
redactText: true,
|
|
94
|
+
attach: 'on-failure',
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/** Each env var is applied only when set (and, for the level, valid). */
|
|
98
|
+
function applyEnv(cfg, env) {
|
|
99
|
+
const level = parseLevel(env.VOID_LOG_LEVEL);
|
|
100
|
+
if (level)
|
|
101
|
+
cfg.level = level;
|
|
102
|
+
if (env.VOID_LOG_DIR)
|
|
103
|
+
cfg.logDir = env.VOID_LOG_DIR;
|
|
104
|
+
const ansi = explicitAnsi(env);
|
|
105
|
+
if (ansi !== undefined)
|
|
106
|
+
cfg.ansi = ansi;
|
|
107
|
+
const tables = envBool(env.VOID_LOG_TABLES);
|
|
108
|
+
if (tables !== undefined)
|
|
109
|
+
cfg.files.tables = tables;
|
|
110
|
+
const jsonl = envBool(env.VOID_LOG_JSONL);
|
|
111
|
+
if (jsonl !== undefined)
|
|
112
|
+
cfg.files.jsonl = jsonl;
|
|
113
|
+
const trunc = env.VOID_LOG_INFO_LOGS_CHAR_LIMIT?.trim();
|
|
114
|
+
if (trunc && /^\d+$/.test(trunc)) {
|
|
115
|
+
cfg.infoLogsCharLimit = Number(trunc) > 0 ? Number(trunc) : null;
|
|
116
|
+
LIMIT_SOURCE = 'env';
|
|
117
|
+
}
|
|
118
|
+
const maxFiles = env.VOID_LOG_MAX_FILES?.trim();
|
|
119
|
+
if (maxFiles && /^\d+$/.test(maxFiles))
|
|
120
|
+
cfg.maxLogFiles = Number(maxFiles) > 0 ? Number(maxFiles) : null;
|
|
121
|
+
const maxRuns = env.VOID_LOG_MAX_RUNS?.trim();
|
|
122
|
+
if (maxRuns && /^\d+$/.test(maxRuns))
|
|
123
|
+
cfg.maxRuns = Number(maxRuns) > 0 ? Number(maxRuns) : null;
|
|
124
|
+
const recent = env.VOID_LOG_RECENT_RUN_MINUTES?.trim();
|
|
125
|
+
if (recent && /^\d+$/.test(recent))
|
|
126
|
+
cfg.recentRunMinutes = Number(recent);
|
|
127
|
+
const redactText = envBool(env.VOID_LOG_REDACT_TEXT);
|
|
128
|
+
if (redactText !== undefined)
|
|
129
|
+
cfg.redactText = redactText;
|
|
130
|
+
const fg = envBool(env.VOID_LOG_FG);
|
|
131
|
+
if (fg !== undefined)
|
|
132
|
+
cfg.fg = fg;
|
|
133
|
+
const bg = envBool(env.VOID_LOG_BG);
|
|
134
|
+
if (bg !== undefined)
|
|
135
|
+
cfg.bg = bg;
|
|
136
|
+
}
|
|
137
|
+
function cloneConfig(c) {
|
|
138
|
+
return {
|
|
139
|
+
...c,
|
|
140
|
+
files: { ...c.files },
|
|
141
|
+
suppressContains: new Set(c.suppressContains),
|
|
142
|
+
suppressMethodPrefixes: new Set(c.suppressMethodPrefixes),
|
|
143
|
+
includeOnlyPrefixes: new Set(c.includeOnlyPrefixes),
|
|
144
|
+
projectRoots: [...c.projectRoots],
|
|
145
|
+
redactKeys: [...c.redactKeys],
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
let CURRENT;
|
|
149
|
+
/** Which layer set the active infoLogsCharLimit, so the truncation warning can say what to edit. */
|
|
150
|
+
let LIMIT_SOURCE = 'default';
|
|
151
|
+
/**
|
|
152
|
+
* Precedence, lowest to highest: built-in defaults, config file, env vars. configure() calls land on top afterwards.
|
|
153
|
+
* A failing config file throws on every call until it is fixed, so the mistake cannot be missed.
|
|
154
|
+
*/
|
|
155
|
+
function build(env = process.env) {
|
|
156
|
+
const cfg = builtinDefaults(env);
|
|
157
|
+
// Re-entrancy guard: a config file that imports this package and touches config() while loading sees the defaults.
|
|
158
|
+
CURRENT = cfg;
|
|
159
|
+
LIMIT_SOURCE = 'default';
|
|
160
|
+
try {
|
|
161
|
+
const loaded = (0, configFile_1.loadConfigFile)(env, process.cwd());
|
|
162
|
+
if (loaded !== undefined) {
|
|
163
|
+
const patch = typeof loaded === 'function' ? loaded(cloneConfig(cfg)) : loaded;
|
|
164
|
+
applyPatch(cfg, patch);
|
|
165
|
+
if (patch.infoLogsCharLimit !== undefined)
|
|
166
|
+
LIMIT_SOURCE = 'file';
|
|
167
|
+
}
|
|
168
|
+
applyEnv(cfg, env);
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
CURRENT = undefined;
|
|
172
|
+
throw err;
|
|
173
|
+
}
|
|
174
|
+
return cfg;
|
|
175
|
+
}
|
|
176
|
+
/** Built lazily on first use, so the project config file is read once in every process (every Playwright worker included). */
|
|
177
|
+
const config = () => CURRENT ?? build();
|
|
178
|
+
exports.config = config;
|
|
179
|
+
function applyPatch(target, patch) {
|
|
180
|
+
const { files, suppressContains, suppressMethodPrefixes, includeOnlyPrefixes, ...rest } = patch;
|
|
181
|
+
Object.assign(target, rest);
|
|
182
|
+
if (files)
|
|
183
|
+
Object.assign(target.files, files);
|
|
184
|
+
if (suppressContains)
|
|
185
|
+
target.suppressContains = new Set(suppressContains);
|
|
186
|
+
if (suppressMethodPrefixes)
|
|
187
|
+
target.suppressMethodPrefixes = new Set(suppressMethodPrefixes);
|
|
188
|
+
if (includeOnlyPrefixes)
|
|
189
|
+
target.includeOnlyPrefixes = new Set(includeOnlyPrefixes);
|
|
190
|
+
}
|
|
191
|
+
/** configure() problems already reported in this process, so a call inside a loop or hook warns once. */
|
|
192
|
+
const WARNED = new Set();
|
|
193
|
+
/**
|
|
194
|
+
* Merge a patch, or mutate in place with a callback. Set-typed fields accept arrays in a patch.
|
|
195
|
+
* Both forms are checked like a config file, but a problem never throws (a logger must not fail a test): an unknown
|
|
196
|
+
* option or a wrong-typed value prints one stderr warning and is skipped, and the rest still applies. For the
|
|
197
|
+
* callback, "skipped" means the bad option is put back to its value from before the call (an unknown one removed).
|
|
198
|
+
*/
|
|
199
|
+
function configure(patch) {
|
|
200
|
+
const cur = (0, exports.config)();
|
|
201
|
+
if (typeof patch === 'function') {
|
|
202
|
+
const before = cloneConfig(cur);
|
|
203
|
+
patch(cur);
|
|
204
|
+
checkLive(cur, before);
|
|
205
|
+
if (cur.infoLogsCharLimit !== before.infoLogsCharLimit)
|
|
206
|
+
LIMIT_SOURCE = 'code';
|
|
207
|
+
return cur;
|
|
208
|
+
}
|
|
209
|
+
if (typeof patch !== 'object' || patch === null || Array.isArray(patch)) {
|
|
210
|
+
warnOnce(`[advanced-logger] configure() expects an object or a function (got ${patch === null ? 'null' : typeof patch}); ignored.`);
|
|
211
|
+
return cur;
|
|
212
|
+
}
|
|
213
|
+
const checked = (0, configFile_1.checkPatch)(patch, 'configure()');
|
|
214
|
+
for (const p of checked.problems)
|
|
215
|
+
warnOnce(`${p.message} Skipped.`);
|
|
216
|
+
patch = checked.patch;
|
|
217
|
+
applyPatch(cur, patch);
|
|
218
|
+
if (patch.infoLogsCharLimit !== undefined)
|
|
219
|
+
LIMIT_SOURCE = 'code';
|
|
220
|
+
return cur;
|
|
221
|
+
}
|
|
222
|
+
const SET_KEYS = ['suppressContains', 'suppressMethodPrefixes', 'includeOnlyPrefixes'];
|
|
223
|
+
/** After a configure() callback: warn about and undo each invalid change, so the live config stays well-formed. */
|
|
224
|
+
function checkLive(cur, before) {
|
|
225
|
+
const live = cur;
|
|
226
|
+
// An array is a valid value for the Set-typed options (as in a patch), but the live config needs a real Set.
|
|
227
|
+
for (const k of SET_KEYS)
|
|
228
|
+
if (Array.isArray(live[k]))
|
|
229
|
+
live[k] = new Set(live[k]);
|
|
230
|
+
for (const p of (0, configFile_1.checkPatch)(live, 'configure() callback').problems) {
|
|
231
|
+
warnOnce(`${p.message} Reverted.`);
|
|
232
|
+
const [top, sub] = p.key.split('.');
|
|
233
|
+
const prev = before;
|
|
234
|
+
if (sub !== undefined) {
|
|
235
|
+
const files = cur.files;
|
|
236
|
+
if (sub in before.files)
|
|
237
|
+
files[sub] = before.files[sub];
|
|
238
|
+
else
|
|
239
|
+
delete files[sub];
|
|
240
|
+
}
|
|
241
|
+
else if (top in prev) {
|
|
242
|
+
live[top] = prev[top];
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
delete live[top];
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/** Print a warning to stderr once per process (reset by resetConfig()). Internal: used for misuse that must not throw. */
|
|
250
|
+
function warnOnce(msg) {
|
|
251
|
+
if (WARNED.has(msg))
|
|
252
|
+
return;
|
|
253
|
+
WARNED.add(msg);
|
|
254
|
+
process.stderr.write(msg + '\n');
|
|
255
|
+
}
|
|
256
|
+
/** Tells the reader where to raise infoLogsCharLimit, based on which layer set the active value. */
|
|
257
|
+
function infoLimitHint() {
|
|
258
|
+
const file = (0, configFile_1.loadedConfigFile)();
|
|
259
|
+
switch (LIMIT_SOURCE) {
|
|
260
|
+
case 'file':
|
|
261
|
+
return `To increase the limit, change infoLogsCharLimit in ${file}.`;
|
|
262
|
+
case 'env':
|
|
263
|
+
return 'To increase the limit, change the VOID_LOG_INFO_LOGS_CHAR_LIMIT environment variable.';
|
|
264
|
+
case 'code':
|
|
265
|
+
return 'To increase the limit, change the infoLogsCharLimit passed to configure() in your code.';
|
|
266
|
+
default:
|
|
267
|
+
return 'To increase the limit, set infoLogsCharLimit in your logger config file or VOID_LOG_INFO_LOGS_CHAR_LIMIT.';
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function defineConfig(c) {
|
|
271
|
+
return c;
|
|
272
|
+
}
|
|
273
|
+
/** Restore defaults and re-read env and the config file. Mainly for tests. */
|
|
274
|
+
function resetConfig() {
|
|
275
|
+
CURRENT = undefined;
|
|
276
|
+
WARNED.clear();
|
|
277
|
+
(0, configFile_1.forgetConfigFile)();
|
|
278
|
+
return (0, exports.config)();
|
|
279
|
+
}
|
|
280
|
+
// -- Convenience mutators (parity with CustomLogger) -------------------------
|
|
281
|
+
const enableAnsi = () => void ((0, exports.config)().ansi = true);
|
|
282
|
+
exports.enableAnsi = enableAnsi;
|
|
283
|
+
const disableAnsi = () => void ((0, exports.config)().ansi = false);
|
|
284
|
+
exports.disableAnsi = disableAnsi;
|
|
285
|
+
const isAnsiEnabled = () => (0, exports.config)().ansi;
|
|
286
|
+
exports.isAnsiEnabled = isAnsiEnabled;
|
|
287
|
+
const enableFg = () => void ((0, exports.config)().fg = true);
|
|
288
|
+
exports.enableFg = enableFg;
|
|
289
|
+
const disableFg = () => void ((0, exports.config)().fg = false);
|
|
290
|
+
exports.disableFg = disableFg;
|
|
291
|
+
const isFgEnabled = () => (0, exports.config)().fg;
|
|
292
|
+
exports.isFgEnabled = isFgEnabled;
|
|
293
|
+
const enableBg = () => void ((0, exports.config)().bg = true);
|
|
294
|
+
exports.enableBg = enableBg;
|
|
295
|
+
const disableBg = () => void ((0, exports.config)().bg = false);
|
|
296
|
+
exports.disableBg = disableBg;
|
|
297
|
+
const isBgEnabled = () => (0, exports.config)().bg;
|
|
298
|
+
exports.isBgEnabled = isBgEnabled;
|
|
299
|
+
const enableCallerColor = () => void ((0, exports.config)().callerColor = true);
|
|
300
|
+
exports.enableCallerColor = enableCallerColor;
|
|
301
|
+
const disableCallerColor = () => void ((0, exports.config)().callerColor = false);
|
|
302
|
+
exports.disableCallerColor = disableCallerColor;
|
|
303
|
+
const isCallerColorEnabled = () => (0, exports.config)().callerColor;
|
|
304
|
+
exports.isCallerColorEnabled = isCallerColorEnabled;
|
|
305
|
+
const isDebugEnabled = () => (0, exports.levelEnabled)((0, exports.config)().level, 'DEBUG');
|
|
306
|
+
exports.isDebugEnabled = isDebugEnabled;
|
|
307
|
+
function includeOnlyPackages(...prefixes) {
|
|
308
|
+
(0, exports.config)().includeOnlyPrefixes = new Set(prefixes.filter((p) => p && p.trim()));
|
|
309
|
+
}
|
|
310
|
+
function suppressClassContains(...substrings) {
|
|
311
|
+
for (const s of substrings)
|
|
312
|
+
if (s && s.trim())
|
|
313
|
+
(0, exports.config)().suppressContains.add(s);
|
|
314
|
+
}
|
|
315
|
+
function suppressMethodPrefix(...prefixes) {
|
|
316
|
+
for (const p of prefixes)
|
|
317
|
+
if (p && p.trim())
|
|
318
|
+
(0, exports.config)().suppressMethodPrefixes.add(p);
|
|
319
|
+
}
|
|
320
|
+
const clearIncludes = () => (0, exports.config)().includeOnlyPrefixes.clear();
|
|
321
|
+
exports.clearIncludes = clearIncludes;
|
|
322
|
+
// -- Line breaks (Java \R equivalent) ----------------------------------------
|
|
323
|
+
const EXTRA_BREAKS = String.fromCharCode(0x2028, 0x2029, 0x85, 0x0b, 0x0c);
|
|
324
|
+
const BREAK_SOURCE = `\\r\\n|[\\n\\r${EXTRA_BREAKS}]`;
|
|
325
|
+
exports.LINE_BREAKS = new RegExp(BREAK_SOURCE, 'g');
|
|
326
|
+
exports.LINE_BREAKS_NO_G = new RegExp(BREAK_SOURCE);
|
|
327
|
+
// -- Cell truncation ---------------------------------------------------------
|
|
328
|
+
function truncateCell(s) {
|
|
329
|
+
if (s == null)
|
|
330
|
+
return '';
|
|
331
|
+
const str = String(s).replace(exports.LINE_BREAKS, ' ');
|
|
332
|
+
const cfg = (0, exports.config)();
|
|
333
|
+
if (!cfg.tableCellLimitEnabled || str.length <= cfg.tableCellLimit)
|
|
334
|
+
return str;
|
|
335
|
+
return str.slice(0, Math.max(1, cfg.tableCellLimit - 3)) + '...';
|
|
336
|
+
}
|
|
337
|
+
/** Set a table cell limit (min 4) and enable it. */
|
|
338
|
+
function setTableCellLimit(limit) {
|
|
339
|
+
const cfg = (0, exports.config)();
|
|
340
|
+
cfg.tableCellLimit = Math.max(4, limit);
|
|
341
|
+
cfg.tableCellLimitEnabled = true;
|
|
342
|
+
}
|
|
343
|
+
const disableTableCellLimit = () => void ((0, exports.config)().tableCellLimitEnabled = false);
|
|
344
|
+
exports.disableTableCellLimit = disableTableCellLimit;
|
|
345
|
+
// -- Timestamp formatting ----------------------------------------------------
|
|
346
|
+
const pad = (n, w = 2) => String(n).padStart(w, '0');
|
|
347
|
+
function formatTs(cfg, d) {
|
|
348
|
+
if (typeof cfg.tsFormat === 'function')
|
|
349
|
+
return cfg.tsFormat(d);
|
|
350
|
+
return cfg.tsFormat.replace(/yyyy|SSS|MM|dd|HH|mm|ss/g, (t) => {
|
|
351
|
+
switch (t) {
|
|
352
|
+
case 'yyyy': return String(d.getFullYear());
|
|
353
|
+
case 'MM': return pad(d.getMonth() + 1);
|
|
354
|
+
case 'dd': return pad(d.getDate());
|
|
355
|
+
case 'HH': return pad(d.getHours());
|
|
356
|
+
case 'mm': return pad(d.getMinutes());
|
|
357
|
+
case 'ss': return pad(d.getSeconds());
|
|
358
|
+
default: return pad(d.getMilliseconds(), 3);
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
// -- Run identity ------------------------------------------------------------
|
|
363
|
+
const stamp = (d) => `${d.getFullYear()}${pad(d.getMonth() + 1)}${pad(d.getDate())}-${pad(d.getHours())}${pad(d.getMinutes())}${pad(d.getSeconds())}-${pad(d.getMilliseconds(), 3)}`;
|
|
364
|
+
/**
|
|
365
|
+
* Set VOID_RUN_ID / VOID_RUN_DATE if absent so every Playwright worker (which inherits the runner's env)
|
|
366
|
+
* shares one run id. Call from globalSetup. Idempotent.
|
|
367
|
+
*/
|
|
368
|
+
function initRun() {
|
|
369
|
+
const now = new Date();
|
|
370
|
+
process.env.VOID_RUN_DATE ||= `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`;
|
|
371
|
+
process.env.VOID_RUN_ID ||= `${stamp(now)}-pid${process.pid}`;
|
|
372
|
+
return getRun();
|
|
373
|
+
}
|
|
374
|
+
const FALLBACK_RUN = (() => {
|
|
375
|
+
const now = new Date();
|
|
376
|
+
return {
|
|
377
|
+
runId: `${stamp(now)}-pid${process.pid}`,
|
|
378
|
+
runDate: `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`,
|
|
379
|
+
};
|
|
380
|
+
})();
|
|
381
|
+
function getRun() {
|
|
382
|
+
return {
|
|
383
|
+
runId: process.env.VOID_RUN_ID || FALLBACK_RUN.runId,
|
|
384
|
+
runDate: process.env.VOID_RUN_DATE || FALLBACK_RUN.runDate,
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* True in a Playwright worker whose runner never called initRun(). Each such worker falls back to its own pid-based
|
|
389
|
+
* run id, so its files are split from its siblings' and retention would see their live files as an older run.
|
|
390
|
+
*/
|
|
391
|
+
function runIdMissing(env = process.env) {
|
|
392
|
+
return env.TEST_WORKER_INDEX != null && !env.VOID_RUN_ID;
|
|
393
|
+
}
|
|
394
|
+
/** Worker label for the thread column: w<TEST_WORKER_INDEX> under Playwright, else "main". */
|
|
395
|
+
function workerLabel(env = process.env) {
|
|
396
|
+
return env.TEST_WORKER_INDEX != null ? `w${env.TEST_WORKER_INDEX}` : 'main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,CAAC,MAAM,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { LogConfig, LogConfigPatch } from './config';
|
|
2
|
+
/** Looked up in this order in the project root; the first one that exists wins. */
|
|
3
|
+
export declare const CONFIG_FILE_NAMES: readonly ["logger.config.ts", "logger.config.js", "logger.config.cjs", "logger.config.json"];
|
|
4
|
+
type Loaded = LogConfigPatch | ((config: LogConfig) => LogConfigPatch);
|
|
5
|
+
/** Resolved path for a config file, or undefined when none exists. An explicit VOID_LOG_CONFIG must exist. */
|
|
6
|
+
export declare function resolveConfigFile(env: NodeJS.ProcessEnv, cwd: string): string | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Load the project config file once per process. Returns undefined when there is none (silently fine).
|
|
9
|
+
* A file that exists but throws, or has the wrong shape, throws an Error naming the file.
|
|
10
|
+
*/
|
|
11
|
+
export declare function loadConfigFile(env: NodeJS.ProcessEnv, cwd: string): Loaded | undefined;
|
|
12
|
+
/** Absolute path of the config file loaded in this process, if any. */
|
|
13
|
+
export declare const loadedConfigFile: () => string | undefined;
|
|
14
|
+
/** Drop the cached module so the next load re-reads the file (tests, resetConfig). */
|
|
15
|
+
export declare function forgetConfigFile(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Check a patch against KEYS. Every unknown key or wrong-typed value becomes a message naming `where`, and is left
|
|
18
|
+
* out of the returned patch; undefined values are dropped. Shared by config files (which throw on the first problem)
|
|
19
|
+
* and configure() (which warns and carries on).
|
|
20
|
+
*/
|
|
21
|
+
export interface PatchProblem {
|
|
22
|
+
/** The offending option: 'level', or 'files.jsonl' for a files entry. */
|
|
23
|
+
key: string;
|
|
24
|
+
message: string;
|
|
25
|
+
}
|
|
26
|
+
export declare function checkPatch(value: Record<string, unknown>, where: string): {
|
|
27
|
+
patch: LogConfigPatch;
|
|
28
|
+
problems: PatchProblem[];
|
|
29
|
+
};
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=configFile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configFile.d.ts","sourceRoot":"","sources":["../src/configFile.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1D,mFAAmF;AACnF,eAAO,MAAM,iBAAiB,8FAA+F,CAAC;AAE9H,KAAK,MAAM,GAAG,cAAc,GAAG,CAAC,CAAC,MAAM,EAAE,SAAS,KAAK,cAAc,CAAC,CAAC;AAEvE,8GAA8G;AAC9G,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAczF;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CA4BtF;AAID,uEAAuE;AACvE,eAAO,MAAM,gBAAgB,QAAO,MAAM,GAAG,SAAmB,CAAC;AAEjE,sFAAsF;AACtF,wBAAgB,gBAAgB,IAAI,IAAI,CASvC;AA0DD;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,yEAAyE;IACzE,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,cAAc,CAAC;IAAC,QAAQ,EAAE,YAAY,EAAE,CAAA;CAAE,CA8B7H"}
|
|
@@ -0,0 +1,211 @@
|
|
|
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
|
+
recentRunMinutes: [(v) => typeof v === 'number' && Number.isFinite(v) && v >= 0, 'a number >= 0'],
|
|
139
|
+
redactText: [bool, 'a boolean'],
|
|
140
|
+
consoleWorker: [bool, 'a boolean'],
|
|
141
|
+
consoleTest: [bool, 'a boolean'],
|
|
142
|
+
callerColor: [bool, 'a boolean'],
|
|
143
|
+
tsFormat: [(v) => str(v) || typeof v === 'function', 'a string or a function'],
|
|
144
|
+
segmentDivider: [str, 'a string'],
|
|
145
|
+
tableCellLimit: [(v) => typeof v === 'number' && Number.isFinite(v), 'a finite number'],
|
|
146
|
+
tableCellLimitEnabled: [bool, 'a boolean'],
|
|
147
|
+
suppressContains: [strList, 'an array of strings'],
|
|
148
|
+
suppressMethodPrefixes: [strList, 'an array of strings'],
|
|
149
|
+
includeOnlyPrefixes: [strList, 'an array of strings'],
|
|
150
|
+
projectRoots: [strArr, 'an array of strings'],
|
|
151
|
+
console: [bool, 'a boolean'],
|
|
152
|
+
files: [isPlainObject, 'an object'],
|
|
153
|
+
logDir: [str, 'a string'],
|
|
154
|
+
githubAnnotations: [bool, 'a boolean'],
|
|
155
|
+
redactKeys: [strArr, 'an array of strings'],
|
|
156
|
+
attach: [oneOf('on-failure', 'always', 'never'), "one of 'on-failure' | 'always' | 'never'"],
|
|
157
|
+
};
|
|
158
|
+
const FILE_KEYS = ['debugTrace', 'partialTrace', 'fullTrace', 'jsonl', 'tables'];
|
|
159
|
+
function checkPatch(value, where) {
|
|
160
|
+
const out = {};
|
|
161
|
+
const problems = [];
|
|
162
|
+
for (const [key, v] of Object.entries(value)) {
|
|
163
|
+
if (v === undefined)
|
|
164
|
+
continue;
|
|
165
|
+
const rule = KEYS[key];
|
|
166
|
+
if (!rule) {
|
|
167
|
+
problems.push({ key, message: `[advanced-logger] ${where} has an unknown option '${key}'. Valid options: ${Object.keys(KEYS).join(', ')}.` });
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
if (!rule[0](v)) {
|
|
171
|
+
problems.push({ key, message: `[advanced-logger] ${where}: option '${key}' must be ${rule[1]} (got ${describe(v)}).` });
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
if (key === 'files') {
|
|
175
|
+
const files = {};
|
|
176
|
+
for (const [fk, fv] of Object.entries(v)) {
|
|
177
|
+
if (fv === undefined)
|
|
178
|
+
continue;
|
|
179
|
+
if (!FILE_KEYS.includes(fk) || typeof fv !== 'boolean') {
|
|
180
|
+
problems.push({ key: `files.${fk}`, message: `[advanced-logger] ${where}: option 'files.${fk}' must be a boolean and one of ${FILE_KEYS.join(', ')}.` });
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
files[fk] = fv;
|
|
184
|
+
}
|
|
185
|
+
out[key] = files;
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
out[key] = v;
|
|
189
|
+
}
|
|
190
|
+
return { patch: out, problems };
|
|
191
|
+
}
|
|
192
|
+
/** Unknown keys are rejected (a typo such as `levl` must not be silently ignored); undefined values are dropped. */
|
|
193
|
+
function validatePatch(value, file, hint) {
|
|
194
|
+
if (!isPlainObject(value)) {
|
|
195
|
+
throw new Error(`[advanced-logger] Config file ${file} has an invalid shape: ${hint} (got ${describe(value)}).`);
|
|
196
|
+
}
|
|
197
|
+
const { patch, problems } = checkPatch(value, `Config file ${file}`);
|
|
198
|
+
if (problems.length > 0)
|
|
199
|
+
throw new Error(problems[0].message);
|
|
200
|
+
return patch;
|
|
201
|
+
}
|
|
202
|
+
function describe(v) {
|
|
203
|
+
if (v === null)
|
|
204
|
+
return 'null';
|
|
205
|
+
if (Array.isArray(v))
|
|
206
|
+
return 'an array';
|
|
207
|
+
if (typeof v === 'string')
|
|
208
|
+
return `string ${JSON.stringify(v)}`;
|
|
209
|
+
return typeof v === 'object' ? 'an object' : `${typeof v} ${String(v)}`;
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=configFile.js.map
|