@aryan-vashishth/advanced-logger 0.1.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/README.md +47 -0
- package/dist/actions.d.ts +71 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +265 -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 +89 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +196 -0
- package/dist/config.js.map +1 -0
- package/dist/core.d.ts +11 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +53 -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 +48 -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/sinks.d.ts +48 -0
- package/dist/sinks.d.ts.map +1 -0
- package/dist/sinks.js +190 -0
- package/dist/sinks.js.map +1 -0
- package/dist/theme.d.ts +18 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +45 -0
- package/dist/theme.js.map +1 -0
- package/package.json +49 -0
package/dist/config.js
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
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.isAnsiEnabled = exports.disableAnsi = exports.enableAnsi = exports.config = exports.levelEnabled = void 0;
|
|
4
|
+
exports.detectAnsiSupport = detectAnsiSupport;
|
|
5
|
+
exports.configure = configure;
|
|
6
|
+
exports.resetConfig = resetConfig;
|
|
7
|
+
exports.includeOnlyPackages = includeOnlyPackages;
|
|
8
|
+
exports.suppressClassContains = suppressClassContains;
|
|
9
|
+
exports.suppressMethodPrefix = suppressMethodPrefix;
|
|
10
|
+
exports.truncateCell = truncateCell;
|
|
11
|
+
exports.setTableCellLimit = setTableCellLimit;
|
|
12
|
+
exports.formatTs = formatTs;
|
|
13
|
+
exports.initRun = initRun;
|
|
14
|
+
exports.getRun = getRun;
|
|
15
|
+
exports.workerLabel = workerLabel;
|
|
16
|
+
const LEVEL_ORDER = { debug: 10, info: 20, warn: 30, error: 40, off: 99 };
|
|
17
|
+
const NAME_ORDER = { DEBUG: 10, INFO: 20, WARN: 30, ERROR: 40 };
|
|
18
|
+
const levelEnabled = (root, level) => NAME_ORDER[level] >= LEVEL_ORDER[root];
|
|
19
|
+
exports.levelEnabled = levelEnabled;
|
|
20
|
+
function parseLevel(v) {
|
|
21
|
+
const l = (v ?? '').trim().toLowerCase();
|
|
22
|
+
return l in LEVEL_ORDER ? l : 'info';
|
|
23
|
+
}
|
|
24
|
+
function envBool(v) {
|
|
25
|
+
if (v == null || v === '')
|
|
26
|
+
return undefined;
|
|
27
|
+
return /^(1|true|yes|on)$/i.test(v);
|
|
28
|
+
}
|
|
29
|
+
/** Explicit env wins, then NO_COLOR/FORCE_COLOR, then TTY/terminal hints, then CI renderers that show ANSI. */
|
|
30
|
+
function detectAnsiSupport(env = process.env, isTTY = !!process.stdout?.isTTY) {
|
|
31
|
+
const explicit = envBool(env.VOID_LOG_ANSI);
|
|
32
|
+
if (explicit !== undefined)
|
|
33
|
+
return explicit;
|
|
34
|
+
if (env.NO_COLOR != null && env.NO_COLOR !== '')
|
|
35
|
+
return false;
|
|
36
|
+
if (env.FORCE_COLOR != null && env.FORCE_COLOR !== '')
|
|
37
|
+
return env.FORCE_COLOR !== '0' && env.FORCE_COLOR !== 'false';
|
|
38
|
+
if (isTTY)
|
|
39
|
+
return true;
|
|
40
|
+
if (env.GITHUB_ACTIONS === 'true')
|
|
41
|
+
return true;
|
|
42
|
+
if (env.COLORTERM)
|
|
43
|
+
return true;
|
|
44
|
+
return !!env.TERM && env.TERM !== 'dumb';
|
|
45
|
+
}
|
|
46
|
+
function defaults(env = process.env) {
|
|
47
|
+
return {
|
|
48
|
+
level: parseLevel(env.VOID_LOG_LEVEL),
|
|
49
|
+
ansi: detectAnsiSupport(env),
|
|
50
|
+
callerColor: false,
|
|
51
|
+
tsFormat: 'yyyy-MM-dd HH:mm:ss.SSS',
|
|
52
|
+
segmentDivider: ' │ ',
|
|
53
|
+
tableCellLimit: 40,
|
|
54
|
+
tableCellLimitEnabled: false,
|
|
55
|
+
suppressContains: new Set(['node_modules', 'node:', '<anonymous>']),
|
|
56
|
+
suppressMethodPrefixes: new Set(),
|
|
57
|
+
includeOnlyPrefixes: new Set(),
|
|
58
|
+
projectRoots: [process.cwd()],
|
|
59
|
+
console: true,
|
|
60
|
+
files: {
|
|
61
|
+
debugTrace: true,
|
|
62
|
+
partialTrace: true,
|
|
63
|
+
fullTrace: true,
|
|
64
|
+
jsonl: envBool(env.VOID_LOG_JSONL) ?? false,
|
|
65
|
+
},
|
|
66
|
+
logDir: env.VOID_LOG_DIR || './logs',
|
|
67
|
+
githubAnnotations: env.GITHUB_ACTIONS === 'true',
|
|
68
|
+
redactKeys: ['password', 'passwd', 'secret', 'token', 'authorization', 'apikey', 'api_key'],
|
|
69
|
+
attach: 'on-failure',
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
let CURRENT = defaults();
|
|
73
|
+
const config = () => CURRENT;
|
|
74
|
+
exports.config = config;
|
|
75
|
+
/** Merge a patch, or mutate in place with a callback. Set-typed fields accept arrays in a patch. */
|
|
76
|
+
function configure(patch) {
|
|
77
|
+
if (typeof patch === 'function') {
|
|
78
|
+
patch(CURRENT);
|
|
79
|
+
return CURRENT;
|
|
80
|
+
}
|
|
81
|
+
const { files, suppressContains, suppressMethodPrefixes, includeOnlyPrefixes, ...rest } = patch;
|
|
82
|
+
Object.assign(CURRENT, rest);
|
|
83
|
+
if (files)
|
|
84
|
+
Object.assign(CURRENT.files, files);
|
|
85
|
+
if (suppressContains)
|
|
86
|
+
CURRENT.suppressContains = new Set(suppressContains);
|
|
87
|
+
if (suppressMethodPrefixes)
|
|
88
|
+
CURRENT.suppressMethodPrefixes = new Set(suppressMethodPrefixes);
|
|
89
|
+
if (includeOnlyPrefixes)
|
|
90
|
+
CURRENT.includeOnlyPrefixes = new Set(includeOnlyPrefixes);
|
|
91
|
+
return CURRENT;
|
|
92
|
+
}
|
|
93
|
+
/** Restore defaults (re-reads env). Mainly for tests. */
|
|
94
|
+
function resetConfig() {
|
|
95
|
+
CURRENT = defaults();
|
|
96
|
+
return CURRENT;
|
|
97
|
+
}
|
|
98
|
+
// -- Convenience mutators (parity with CustomLogger) -------------------------
|
|
99
|
+
const enableAnsi = () => void (CURRENT.ansi = true);
|
|
100
|
+
exports.enableAnsi = enableAnsi;
|
|
101
|
+
const disableAnsi = () => void (CURRENT.ansi = false);
|
|
102
|
+
exports.disableAnsi = disableAnsi;
|
|
103
|
+
const isAnsiEnabled = () => CURRENT.ansi;
|
|
104
|
+
exports.isAnsiEnabled = isAnsiEnabled;
|
|
105
|
+
const enableCallerColor = () => void (CURRENT.callerColor = true);
|
|
106
|
+
exports.enableCallerColor = enableCallerColor;
|
|
107
|
+
const disableCallerColor = () => void (CURRENT.callerColor = false);
|
|
108
|
+
exports.disableCallerColor = disableCallerColor;
|
|
109
|
+
const isCallerColorEnabled = () => CURRENT.callerColor;
|
|
110
|
+
exports.isCallerColorEnabled = isCallerColorEnabled;
|
|
111
|
+
const isDebugEnabled = () => (0, exports.levelEnabled)(CURRENT.level, 'DEBUG');
|
|
112
|
+
exports.isDebugEnabled = isDebugEnabled;
|
|
113
|
+
function includeOnlyPackages(...prefixes) {
|
|
114
|
+
CURRENT.includeOnlyPrefixes = new Set(prefixes.filter((p) => p && p.trim()));
|
|
115
|
+
}
|
|
116
|
+
function suppressClassContains(...substrings) {
|
|
117
|
+
for (const s of substrings)
|
|
118
|
+
if (s && s.trim())
|
|
119
|
+
CURRENT.suppressContains.add(s);
|
|
120
|
+
}
|
|
121
|
+
function suppressMethodPrefix(...prefixes) {
|
|
122
|
+
for (const p of prefixes)
|
|
123
|
+
if (p && p.trim())
|
|
124
|
+
CURRENT.suppressMethodPrefixes.add(p);
|
|
125
|
+
}
|
|
126
|
+
const clearIncludes = () => CURRENT.includeOnlyPrefixes.clear();
|
|
127
|
+
exports.clearIncludes = clearIncludes;
|
|
128
|
+
// -- Line breaks (Java \R equivalent) ----------------------------------------
|
|
129
|
+
const EXTRA_BREAKS = String.fromCharCode(0x2028, 0x2029, 0x85, 0x0b, 0x0c);
|
|
130
|
+
const BREAK_SOURCE = `\\r\\n|[\\n\\r${EXTRA_BREAKS}]`;
|
|
131
|
+
exports.LINE_BREAKS = new RegExp(BREAK_SOURCE, 'g');
|
|
132
|
+
exports.LINE_BREAKS_NO_G = new RegExp(BREAK_SOURCE);
|
|
133
|
+
// -- Cell truncation ---------------------------------------------------------
|
|
134
|
+
function truncateCell(s) {
|
|
135
|
+
if (s == null)
|
|
136
|
+
return '';
|
|
137
|
+
const str = String(s).replace(exports.LINE_BREAKS, ' ');
|
|
138
|
+
const cfg = CURRENT;
|
|
139
|
+
if (!cfg.tableCellLimitEnabled || str.length <= cfg.tableCellLimit)
|
|
140
|
+
return str;
|
|
141
|
+
return str.slice(0, Math.max(1, cfg.tableCellLimit - 3)) + '...';
|
|
142
|
+
}
|
|
143
|
+
/** Set a table cell limit (min 4) and enable it. */
|
|
144
|
+
function setTableCellLimit(limit) {
|
|
145
|
+
CURRENT.tableCellLimit = Math.max(4, limit);
|
|
146
|
+
CURRENT.tableCellLimitEnabled = true;
|
|
147
|
+
}
|
|
148
|
+
const disableTableCellLimit = () => void (CURRENT.tableCellLimitEnabled = false);
|
|
149
|
+
exports.disableTableCellLimit = disableTableCellLimit;
|
|
150
|
+
// -- Timestamp formatting ----------------------------------------------------
|
|
151
|
+
const pad = (n, w = 2) => String(n).padStart(w, '0');
|
|
152
|
+
function formatTs(cfg, d) {
|
|
153
|
+
if (typeof cfg.tsFormat === 'function')
|
|
154
|
+
return cfg.tsFormat(d);
|
|
155
|
+
return cfg.tsFormat.replace(/yyyy|SSS|MM|dd|HH|mm|ss/g, (t) => {
|
|
156
|
+
switch (t) {
|
|
157
|
+
case 'yyyy': return String(d.getFullYear());
|
|
158
|
+
case 'MM': return pad(d.getMonth() + 1);
|
|
159
|
+
case 'dd': return pad(d.getDate());
|
|
160
|
+
case 'HH': return pad(d.getHours());
|
|
161
|
+
case 'mm': return pad(d.getMinutes());
|
|
162
|
+
case 'ss': return pad(d.getSeconds());
|
|
163
|
+
default: return pad(d.getMilliseconds(), 3);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
// -- Run identity ------------------------------------------------------------
|
|
168
|
+
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)}`;
|
|
169
|
+
/**
|
|
170
|
+
* Set VOID_RUN_ID / VOID_RUN_DATE if absent so every Playwright worker (which inherits the runner's env)
|
|
171
|
+
* shares one run id. Call from globalSetup. Idempotent.
|
|
172
|
+
*/
|
|
173
|
+
function initRun() {
|
|
174
|
+
const now = new Date();
|
|
175
|
+
process.env.VOID_RUN_DATE ||= `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`;
|
|
176
|
+
process.env.VOID_RUN_ID ||= `${stamp(now)}-pid${process.pid}`;
|
|
177
|
+
return getRun();
|
|
178
|
+
}
|
|
179
|
+
const FALLBACK_RUN = (() => {
|
|
180
|
+
const now = new Date();
|
|
181
|
+
return {
|
|
182
|
+
runId: `${stamp(now)}-pid${process.pid}`,
|
|
183
|
+
runDate: `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`,
|
|
184
|
+
};
|
|
185
|
+
})();
|
|
186
|
+
function getRun() {
|
|
187
|
+
return {
|
|
188
|
+
runId: process.env.VOID_RUN_ID || FALLBACK_RUN.runId,
|
|
189
|
+
runDate: process.env.VOID_RUN_DATE || FALLBACK_RUN.runDate,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
/** Worker label for the thread column: w<TEST_WORKER_INDEX> under Playwright, else "main". */
|
|
193
|
+
function workerLabel(env = process.env) {
|
|
194
|
+
return env.TEST_WORKER_INDEX != null ? `w${env.TEST_WORKER_INDEX}` : 'main';
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AA+DA,8CASC;AA2CD,8BAYC;AAGD,kCAGC;AAYD,kDAEC;AACD,sDAEC;AACD,oDAEC;AAYD,oCAMC;AAGD,8CAGC;AAOD,4BAaC;AAWD,0BAKC;AAUD,wBAKC;AAGD,kCAEC;AA3LD,MAAM,WAAW,GAA8B,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;AACrG,MAAM,UAAU,GAA8B,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;AAEpF,MAAM,YAAY,GAAG,CAAC,IAAe,EAAE,KAAgB,EAAW,EAAE,CACzE,UAAU,CAAC,KAAK,CAAC,I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package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type LevelName, type LogIntent } from './theme';
|
|
2
|
+
/** Tag subsequent events (jsonl records) with the running test. Set by the Playwright fixture. */
|
|
3
|
+
export declare const setTestContext: (title: string | undefined) => void;
|
|
4
|
+
export declare const getTestContext: () => string | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Single funnel for every log call. Sinks are asked first so no stack is captured
|
|
7
|
+
* when nothing would write the event.
|
|
8
|
+
*/
|
|
9
|
+
export declare function dispatch(level: LevelName, intent: LogIntent | null, color: string, label: string, message: string | null | undefined): void;
|
|
10
|
+
export declare function themed(level: LevelName, intent: LogIntent): string;
|
|
11
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAgB,MAAM,SAAS,CAAC;AAIvE,kGAAkG;AAClG,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,GAAG,SAAS,KAAG,IAAkC,CAAC;AAC9F,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,CA4BN;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM,CAElE"}
|
package/dist/core.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTestContext = exports.setTestContext = void 0;
|
|
4
|
+
exports.dispatch = dispatch;
|
|
5
|
+
exports.themed = themed;
|
|
6
|
+
const caller_1 = require("./caller");
|
|
7
|
+
const config_1 = require("./config");
|
|
8
|
+
const sinks_1 = require("./sinks");
|
|
9
|
+
const theme_1 = require("./theme");
|
|
10
|
+
let currentTest;
|
|
11
|
+
/** Tag subsequent events (jsonl records) with the running test. Set by the Playwright fixture. */
|
|
12
|
+
const setTestContext = (title) => void (currentTest = title);
|
|
13
|
+
exports.setTestContext = setTestContext;
|
|
14
|
+
const getTestContext = () => currentTest;
|
|
15
|
+
exports.getTestContext = getTestContext;
|
|
16
|
+
/**
|
|
17
|
+
* Single funnel for every log call. Sinks are asked first so no stack is captured
|
|
18
|
+
* when nothing would write the event.
|
|
19
|
+
*/
|
|
20
|
+
function dispatch(level, intent, color, label, message) {
|
|
21
|
+
const cfg = (0, config_1.config)();
|
|
22
|
+
const sinks = (0, sinks_1.activeSinks)().filter((s) => s.accepts(level, cfg));
|
|
23
|
+
if (sinks.length === 0)
|
|
24
|
+
return;
|
|
25
|
+
const time = new Date();
|
|
26
|
+
const { caller, chain } = (0, caller_1.resolveCaller)(cfg);
|
|
27
|
+
const ev = {
|
|
28
|
+
time,
|
|
29
|
+
ts: (0, config_1.formatTs)(cfg, time),
|
|
30
|
+
level,
|
|
31
|
+
intent,
|
|
32
|
+
label,
|
|
33
|
+
message: message ?? 'null',
|
|
34
|
+
color,
|
|
35
|
+
caller,
|
|
36
|
+
chain,
|
|
37
|
+
worker: (0, config_1.workerLabel)(),
|
|
38
|
+
test: currentTest,
|
|
39
|
+
};
|
|
40
|
+
for (const s of sinks) {
|
|
41
|
+
try {
|
|
42
|
+
s.write(ev, cfg);
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
// A logger must never fail a test. Report once to stderr and carry on.
|
|
46
|
+
process.stderr.write(`[advanced-logger] sink failed: ${err.message}\n`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function themed(level, intent) {
|
|
51
|
+
return (0, config_1.config)().ansi ? (0, theme_1.resolveStyle)(level, intent) : '';
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=core.js.map
|
package/dist/core.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;AAeA,4BAkCC;AAED,wBAEC;AArDD,qCAAyC;AACzC,qCAAyD;AACzD,mCAAqD;AACrD,mCAAuE;AAEvE,IAAI,WAA+B,CAAC;AAEpC,kGAAkG;AAC3F,MAAM,cAAc,GAAG,CAAC,KAAyB,EAAQ,EAAE,CAAC,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,CAAC;AAAjF,QAAA,cAAc,kBAAmE;AACvF,MAAM,cAAc,GAAG,GAAuB,EAAE,CAAC,WAAW,CAAC;AAAvD,QAAA,cAAc,kBAAyC;AAEpE;;;GAGG;AACH,SAAgB,QAAQ,CACtB,KAAgB,EAChB,MAAwB,EACxB,KAAa,EACb,KAAa,EACb,OAAkC;IAElC,MAAM,GAAG,GAAG,IAAA,eAAM,GAAE,CAAC;IACrB,MAAM,KAAK,GAAG,IAAA,mBAAW,GAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;IACjE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAE/B,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;IACxB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,sBAAa,EAAC,GAAG,CAAC,CAAC;IAC7C,MAAM,EAAE,GAAa;QACnB,IAAI;QACJ,EAAE,EAAE,IAAA,iBAAQ,EAAC,GAAG,EAAE,IAAI,CAAC;QACvB,KAAK;QACL,MAAM;QACN,KAAK;QACL,OAAO,EAAE,OAAO,IAAI,MAAM;QAC1B,KAAK;QACL,MAAM;QACN,KAAK;QACL,MAAM,EAAE,IAAA,oBAAW,GAAE;QACrB,IAAI,EAAE,WAAW;KAClB,CAAC;IACF,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC;YACH,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;QACnB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,uEAAuE;YACvE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,kCAAmC,GAAa,CAAC,OAAO,IAAI,CAAC,CAAC;QACrF,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAgB,MAAM,CAAC,KAAgB,EAAE,MAAiB;IACxD,OAAO,IAAA,eAAM,GAAE,CAAC,IAAI,CAAC,CAAC,CAAC,IAAA,oBAAY,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1D,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { debug, info, warn, error } from './logger';
|
|
2
|
+
export { LogActions, fields, formatValue } from './actions';
|
|
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';
|
|
5
|
+
export type { LogConfig, LogConfigPatch, RootLevel, AttachPolicy, FileToggles } from './config';
|
|
6
|
+
export { LogIntent } from './theme';
|
|
7
|
+
export type { LevelName } from './theme';
|
|
8
|
+
export { stripAnsi, fgFromStyle } from './ansi';
|
|
9
|
+
export { setTestContext, getTestContext } from './core';
|
|
10
|
+
export { addSink, removeSink, captureLogs, closeAllFiles, traceFilePath } from './sinks';
|
|
11
|
+
export type { Sink, LogEvent, Capture } from './sinks';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,mBAAmB,EACnB,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
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
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;
|
|
4
|
+
var logger_1 = require("./logger");
|
|
5
|
+
Object.defineProperty(exports, "debug", { enumerable: true, get: function () { return logger_1.debug; } });
|
|
6
|
+
Object.defineProperty(exports, "info", { enumerable: true, get: function () { return logger_1.info; } });
|
|
7
|
+
Object.defineProperty(exports, "warn", { enumerable: true, get: function () { return logger_1.warn; } });
|
|
8
|
+
Object.defineProperty(exports, "error", { enumerable: true, get: function () { return logger_1.error; } });
|
|
9
|
+
var actions_1 = require("./actions");
|
|
10
|
+
Object.defineProperty(exports, "LogActions", { enumerable: true, get: function () { return actions_1.LogActions; } });
|
|
11
|
+
Object.defineProperty(exports, "fields", { enumerable: true, get: function () { return actions_1.fields; } });
|
|
12
|
+
Object.defineProperty(exports, "formatValue", { enumerable: true, get: function () { return actions_1.formatValue; } });
|
|
13
|
+
var config_1 = require("./config");
|
|
14
|
+
Object.defineProperty(exports, "config", { enumerable: true, get: function () { return config_1.config; } });
|
|
15
|
+
Object.defineProperty(exports, "configure", { enumerable: true, get: function () { return config_1.configure; } });
|
|
16
|
+
Object.defineProperty(exports, "resetConfig", { enumerable: true, get: function () { return config_1.resetConfig; } });
|
|
17
|
+
Object.defineProperty(exports, "initRun", { enumerable: true, get: function () { return config_1.initRun; } });
|
|
18
|
+
Object.defineProperty(exports, "getRun", { enumerable: true, get: function () { return config_1.getRun; } });
|
|
19
|
+
Object.defineProperty(exports, "workerLabel", { enumerable: true, get: function () { return config_1.workerLabel; } });
|
|
20
|
+
Object.defineProperty(exports, "enableAnsi", { enumerable: true, get: function () { return config_1.enableAnsi; } });
|
|
21
|
+
Object.defineProperty(exports, "disableAnsi", { enumerable: true, get: function () { return config_1.disableAnsi; } });
|
|
22
|
+
Object.defineProperty(exports, "isAnsiEnabled", { enumerable: true, get: function () { return config_1.isAnsiEnabled; } });
|
|
23
|
+
Object.defineProperty(exports, "enableCallerColor", { enumerable: true, get: function () { return config_1.enableCallerColor; } });
|
|
24
|
+
Object.defineProperty(exports, "disableCallerColor", { enumerable: true, get: function () { return config_1.disableCallerColor; } });
|
|
25
|
+
Object.defineProperty(exports, "isCallerColorEnabled", { enumerable: true, get: function () { return config_1.isCallerColorEnabled; } });
|
|
26
|
+
Object.defineProperty(exports, "isDebugEnabled", { enumerable: true, get: function () { return config_1.isDebugEnabled; } });
|
|
27
|
+
Object.defineProperty(exports, "includeOnlyPackages", { enumerable: true, get: function () { return config_1.includeOnlyPackages; } });
|
|
28
|
+
Object.defineProperty(exports, "suppressClassContains", { enumerable: true, get: function () { return config_1.suppressClassContains; } });
|
|
29
|
+
Object.defineProperty(exports, "suppressMethodPrefix", { enumerable: true, get: function () { return config_1.suppressMethodPrefix; } });
|
|
30
|
+
Object.defineProperty(exports, "clearIncludes", { enumerable: true, get: function () { return config_1.clearIncludes; } });
|
|
31
|
+
Object.defineProperty(exports, "setTableCellLimit", { enumerable: true, get: function () { return config_1.setTableCellLimit; } });
|
|
32
|
+
Object.defineProperty(exports, "disableTableCellLimit", { enumerable: true, get: function () { return config_1.disableTableCellLimit; } });
|
|
33
|
+
Object.defineProperty(exports, "detectAnsiSupport", { enumerable: true, get: function () { return config_1.detectAnsiSupport; } });
|
|
34
|
+
var theme_1 = require("./theme");
|
|
35
|
+
Object.defineProperty(exports, "LogIntent", { enumerable: true, get: function () { return theme_1.LogIntent; } });
|
|
36
|
+
var ansi_1 = require("./ansi");
|
|
37
|
+
Object.defineProperty(exports, "stripAnsi", { enumerable: true, get: function () { return ansi_1.stripAnsi; } });
|
|
38
|
+
Object.defineProperty(exports, "fgFromStyle", { enumerable: true, get: function () { return ansi_1.fgFromStyle; } });
|
|
39
|
+
var core_1 = require("./core");
|
|
40
|
+
Object.defineProperty(exports, "setTestContext", { enumerable: true, get: function () { return core_1.setTestContext; } });
|
|
41
|
+
Object.defineProperty(exports, "getTestContext", { enumerable: true, get: function () { return core_1.getTestContext; } });
|
|
42
|
+
var sinks_1 = require("./sinks");
|
|
43
|
+
Object.defineProperty(exports, "addSink", { enumerable: true, get: function () { return sinks_1.addSink; } });
|
|
44
|
+
Object.defineProperty(exports, "removeSink", { enumerable: true, get: function () { return sinks_1.removeSink; } });
|
|
45
|
+
Object.defineProperty(exports, "captureLogs", { enumerable: true, get: function () { return sinks_1.captureLogs; } });
|
|
46
|
+
Object.defineProperty(exports, "closeAllFiles", { enumerable: true, get: function () { return sinks_1.closeAllFiles; } });
|
|
47
|
+
Object.defineProperty(exports, "traceFilePath", { enumerable: true, get: function () { return sinks_1.traceFilePath; } });
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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,mCAqBkB;AApBhB,gGAAA,MAAM,OAAA;AACN,mGAAA,SAAS,OAAA;AACT,qGAAA,WAAW,OAAA;AACX,iGAAA,OAAO,OAAA;AACP,gGAAA,MAAM,OAAA;AACN,qGAAA,WAAW,OAAA;AACX,oGAAA,UAAU,OAAA;AACV,qGAAA,WAAW,OAAA;AACX,uGAAA,aAAa,OAAA;AACb,2GAAA,iBAAiB,OAAA;AACjB,4GAAA,kBAAkB,OAAA;AAClB,8GAAA,oBAAoB,OAAA;AACpB,wGAAA,cAAc,OAAA;AACd,6GAAA,mBAAmB,OAAA;AACnB,+GAAA,qBAAqB,OAAA;AACrB,8GAAA,oBAAoB,OAAA;AACpB,uGAAA,aAAa,OAAA;AACb,2GAAA,iBAAiB,OAAA;AACjB,+GAAA,qBAAqB,OAAA;AACrB,2GAAA,iBAAiB,OAAA;AAGnB,iCAAoC;AAA3B,kGAAA,SAAS,OAAA;AAElB,+BAAgD;AAAvC,iGAAA,SAAS,OAAA;AAAE,mGAAA,WAAW,OAAA;AAC/B,+BAAwD;AAA/C,sGAAA,cAAc,OAAA;AAAE,sGAAA,cAAc,OAAA;AACvC,iCAAyF;AAAhF,gGAAA,OAAO,OAAA;AAAE,mGAAA,UAAU,OAAA;AAAE,oGAAA,WAAW,OAAA;AAAE,sGAAA,aAAa,OAAA;AAAE,sGAAA,aAAa,OAAA"}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LogActions } from './actions';
|
|
2
|
+
/** Level instances. `info.click("...")`, `warn.log("...")`, `error.failed("...")`. */
|
|
3
|
+
export declare const debug: LogActions;
|
|
4
|
+
export declare const info: LogActions;
|
|
5
|
+
export declare const warn: LogActions;
|
|
6
|
+
export declare const error: LogActions;
|
|
7
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,sFAAsF;AACtF,eAAO,MAAM,KAAK,YAA0B,CAAC;AAC7C,eAAO,MAAM,IAAI,YAAyB,CAAC;AAC3C,eAAO,MAAM,IAAI,YAAyB,CAAC;AAC3C,eAAO,MAAM,KAAK,YAA0B,CAAC"}
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.error = exports.warn = exports.info = exports.debug = void 0;
|
|
4
|
+
const actions_1 = require("./actions");
|
|
5
|
+
/** Level instances. `info.click("...")`, `warn.log("...")`, `error.failed("...")`. */
|
|
6
|
+
exports.debug = new actions_1.LogActions('DEBUG');
|
|
7
|
+
exports.info = new actions_1.LogActions('INFO');
|
|
8
|
+
exports.warn = new actions_1.LogActions('WARN');
|
|
9
|
+
exports.error = new actions_1.LogActions('ERROR');
|
|
10
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AAEvC,sFAAsF;AACzE,QAAA,KAAK,GAAG,IAAI,oBAAU,CAAC,OAAO,CAAC,CAAC;AAChC,QAAA,IAAI,GAAG,IAAI,oBAAU,CAAC,MAAM,CAAC,CAAC;AAC9B,QAAA,IAAI,GAAG,IAAI,oBAAU,CAAC,MAAM,CAAC,CAAC;AAC9B,QAAA,KAAK,GAAG,IAAI,oBAAU,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { expect } from '@playwright/test';
|
|
2
|
+
/**
|
|
3
|
+
* Drop-in replacement for Playwright's `test`. An auto fixture, active for every test, that:
|
|
4
|
+
* - tags log records with the test title,
|
|
5
|
+
* - logs a start/end banner,
|
|
6
|
+
* - attaches the test's log lines to the report (policy: config().attach, default on-failure).
|
|
7
|
+
*
|
|
8
|
+
* Import `test` and `expect` from here instead of '@playwright/test'.
|
|
9
|
+
*/
|
|
10
|
+
export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & {
|
|
11
|
+
voidLog: void;
|
|
12
|
+
}, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
|
|
13
|
+
export { expect };
|
|
14
|
+
export { initRun } from './config';
|
|
15
|
+
//# sourceMappingURL=playwright.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playwright.d.ts","sourceRoot":"","sources":["../src/playwright.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAMxD;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI;aAA0B,IAAI;wGAwB7C,CAAC;AAEH,OAAO,EAAE,MAAM,EAAE,CAAC;AAClB,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initRun = exports.expect = exports.test = void 0;
|
|
4
|
+
const test_1 = require("@playwright/test");
|
|
5
|
+
Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return test_1.expect; } });
|
|
6
|
+
const config_1 = require("./config");
|
|
7
|
+
const core_1 = require("./core");
|
|
8
|
+
const sinks_1 = require("./sinks");
|
|
9
|
+
const logger_1 = require("./logger");
|
|
10
|
+
/**
|
|
11
|
+
* Drop-in replacement for Playwright's `test`. An auto fixture, active for every test, that:
|
|
12
|
+
* - tags log records with the test title,
|
|
13
|
+
* - logs a start/end banner,
|
|
14
|
+
* - attaches the test's log lines to the report (policy: config().attach, default on-failure).
|
|
15
|
+
*
|
|
16
|
+
* Import `test` and `expect` from here instead of '@playwright/test'.
|
|
17
|
+
*/
|
|
18
|
+
exports.test = test_1.test.extend({
|
|
19
|
+
voidLog: [
|
|
20
|
+
async ({}, use, testInfo) => {
|
|
21
|
+
(0, core_1.setTestContext)(testInfo.titlePath.join(' > '));
|
|
22
|
+
const capture = (0, sinks_1.captureLogs)();
|
|
23
|
+
logger_1.info.log(`TEST START | ${testInfo.titlePath.join(' > ')}`);
|
|
24
|
+
try {
|
|
25
|
+
await use();
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
const failed = testInfo.status !== testInfo.expectedStatus;
|
|
29
|
+
const line = `TEST END | ${testInfo.status} | ${testInfo.duration}ms`;
|
|
30
|
+
if (failed)
|
|
31
|
+
logger_1.error.failed(line);
|
|
32
|
+
else
|
|
33
|
+
logger_1.info.success(line);
|
|
34
|
+
const text = capture.stop();
|
|
35
|
+
const policy = (0, config_1.config)().attach;
|
|
36
|
+
if (text && (policy === 'always' || (policy === 'on-failure' && failed))) {
|
|
37
|
+
await testInfo.attach('void-log', { body: text, contentType: 'text/plain' });
|
|
38
|
+
}
|
|
39
|
+
(0, core_1.setTestContext)(undefined);
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{ auto: true },
|
|
43
|
+
],
|
|
44
|
+
});
|
|
45
|
+
var config_2 = require("./config");
|
|
46
|
+
Object.defineProperty(exports, "initRun", { enumerable: true, get: function () { return config_2.initRun; } });
|
|
47
|
+
//# sourceMappingURL=playwright.js.map
|
|
@@ -0,0 +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/C,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
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type LogConfig } from './config';
|
|
2
|
+
import { type LevelName, type LogIntent } from './theme';
|
|
3
|
+
/** One log call. Sinks render it however they need. */
|
|
4
|
+
export interface LogEvent {
|
|
5
|
+
time: Date;
|
|
6
|
+
/** Pre-formatted timestamp. */
|
|
7
|
+
ts: string;
|
|
8
|
+
level: LevelName;
|
|
9
|
+
/** null for pre-colored calls such as table(). */
|
|
10
|
+
intent: LogIntent | null;
|
|
11
|
+
label: string;
|
|
12
|
+
/** Full message, may be multi-line. */
|
|
13
|
+
message: string;
|
|
14
|
+
/** Resolved theme style (intentFg + levelBg). Ignored when ANSI is off. */
|
|
15
|
+
color: string;
|
|
16
|
+
/** Plain "Callee <- Caller" text, empty when unresolved. */
|
|
17
|
+
caller: string;
|
|
18
|
+
/** Plain in-project chain, empty when unresolved. */
|
|
19
|
+
chain: string;
|
|
20
|
+
worker: string;
|
|
21
|
+
test?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface Sink {
|
|
24
|
+
/** Cheap check run before any stack capture; return false to skip the event entirely. */
|
|
25
|
+
accepts(level: LevelName, cfg: LogConfig): boolean;
|
|
26
|
+
write(ev: LogEvent, cfg: LogConfig): void;
|
|
27
|
+
}
|
|
28
|
+
export declare const splitLines: (m: string) => string[];
|
|
29
|
+
export declare const consoleSink: Sink;
|
|
30
|
+
type FileKind = 'debug-trace' | 'partial-trace' | 'full-trace';
|
|
31
|
+
export declare function closeAllFiles(): void;
|
|
32
|
+
export declare function traceFilePath(cfg: LogConfig, kind: FileKind | 'jsonl', ext?: string): string;
|
|
33
|
+
export declare const partialTraceSink: Sink;
|
|
34
|
+
export declare const debugTraceSink: Sink;
|
|
35
|
+
export declare const fullTraceSink: Sink;
|
|
36
|
+
export declare const jsonlSink: Sink;
|
|
37
|
+
export interface Capture {
|
|
38
|
+
/** Plain-text lines as they would appear in partial-trace. */
|
|
39
|
+
text(): string;
|
|
40
|
+
stop(): string;
|
|
41
|
+
}
|
|
42
|
+
export declare const captureSink: Sink;
|
|
43
|
+
export declare function captureLogs(): Capture;
|
|
44
|
+
export declare const addSink: (s: Sink) => void;
|
|
45
|
+
export declare const removeSink: (s: Sink) => void;
|
|
46
|
+
export declare function activeSinks(): Sink[];
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=sinks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
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