@visulima/pail 4.0.0-alpha.1 → 4.0.0-alpha.11
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/CHANGELOG.md +204 -0
- package/LICENSE.md +434 -52
- package/README.md +323 -0
- package/dist/error.d.ts +104 -0
- package/dist/error.js +76 -0
- package/dist/index.browser.d.ts +3 -1
- package/dist/index.browser.js +1490 -3
- package/dist/index.server.d.ts +3 -5
- package/dist/index.server.js +2380 -110
- package/dist/middleware/elysia.d.ts +71 -0
- package/dist/middleware/elysia.js +70 -0
- package/dist/middleware/express.d.ts +86 -0
- package/dist/middleware/express.js +29 -0
- package/dist/middleware/fastify.d.ts +81 -0
- package/dist/middleware/fastify.js +46 -0
- package/dist/middleware/hono.d.ts +85 -0
- package/dist/middleware/hono.js +33 -0
- package/dist/middleware/next/handler.d.ts +36 -0
- package/dist/middleware/next/handler.js +53 -0
- package/dist/middleware/next/middleware.d.ts +59 -0
- package/dist/middleware/next/storage.d.ts +14 -0
- package/dist/middleware/shared/create-middleware-logger.d.ts +82 -0
- package/dist/middleware/shared/headers.d.ts +14 -0
- package/dist/middleware/shared/routes.d.ts +30 -0
- package/dist/middleware/shared/storage.d.ts +29 -0
- package/dist/middleware/sveltekit.d.ts +123 -0
- package/dist/middleware/sveltekit.js +43 -0
- package/dist/object-tree.d.ts +2 -2
- package/dist/object-tree.js +7 -7
- package/dist/packem_shared/{AbstractJsonReporter-BaZ33PlE.js → AbstractJsonReporter-BO8Calb4.js} +112 -32
- package/dist/packem_shared/AbstractJsonReporter-nOj0Ft1F.js +284 -0
- package/dist/packem_shared/{JsonReporter-BRw4skd5.js → JsonReporter-CCmj7oYL.js} +2 -2
- package/dist/packem_shared/{JsonReporter-VzgyLEYz.js → JsonReporter-Ck2PIAEw.js} +2 -2
- package/dist/packem_shared/PrettyReporter-BCvyNzXO.js +2720 -0
- package/dist/packem_shared/{PrettyReporter-DySIXBjQ.js → PrettyReporter-BtTr13Ha.js} +55 -11
- package/dist/packem_shared/abstract-pretty-reporter-CXAKYCb8.js +2635 -0
- package/dist/packem_shared/constants-B1RjD_ps.js +99 -0
- package/dist/packem_shared/createPailError-B_sgL0nF.js +76 -0
- package/dist/packem_shared/headers-BxHWM6KI.js +127 -0
- package/dist/packem_shared/{index-BomQ3E6J.js → index-Bx3-C0j9.js} +29 -21
- package/dist/packem_shared/pailMiddleware-Ci88geIF.js +24 -0
- package/dist/packem_shared/storage-D0vqz8OX.js +36 -0
- package/dist/packem_shared/{InteractiveStreamHook-DiSubbJ1.js → useLogger-D0rU3lcX.js} +13 -1
- package/dist/packem_shared/{write-console-log-based-on-level-DBmRYXpj.js → write-console-log-based-on-level-ree2lDPw.js} +5 -4
- package/dist/packem_shared/{write-stream-BG8fhcs3.js → write-stream-MDqyXmc_.js} +1 -1
- package/dist/pail.browser.d.ts +1 -1
- package/dist/pail.server.d.ts +1 -76
- package/dist/processor/caller/caller-processor.js +1 -1
- package/dist/processor/environment-processor.d.ts +124 -0
- package/dist/processor/environment-processor.js +89 -0
- package/dist/processor/message-formatter-processor.d.ts +2 -3
- package/dist/processor/message-formatter-processor.js +654 -5
- package/dist/processor/opentelemetry-processor.js +4 -4
- package/dist/processor/redact-processor.d.ts +1 -1
- package/dist/processor/redact-processor.js +2 -1
- package/dist/processor/sampling-processor.d.ts +111 -0
- package/dist/processor/sampling-processor.js +59 -0
- package/dist/reporter/file/json-file-reporter.js +1 -1
- package/dist/reporter/http/abstract-http-reporter.js +23 -26
- package/dist/reporter/http/http-reporter.edge-light.js +134 -57
- package/dist/reporter/json/abstract-json-reporter.d.ts +1 -1
- package/dist/reporter/json/index.browser.js +2 -2
- package/dist/reporter/json/index.js +2 -2
- package/dist/reporter/pretty/index.browser.js +1 -1
- package/dist/reporter/pretty/index.js +1 -1
- package/dist/reporter/pretty/pretty-reporter.server.d.ts +1 -1
- package/dist/reporter/raw/raw-reporter.server.d.ts +1 -1
- package/dist/reporter/simple/simple-reporter.server.d.ts +1 -1
- package/dist/reporter/simple/simple-reporter.server.js +8 -12
- package/dist/types.d.ts +4 -4
- package/dist/utils/write-console-log-based-on-level.d.ts +1 -1
- package/dist/wide-event.d.ts +300 -0
- package/dist/wide-event.js +284 -0
- package/package.json +73 -20
- package/dist/interactive/index.d.ts +0 -2
- package/dist/interactive/index.js +0 -2
- package/dist/interactive/interactive-manager.d.ts +0 -108
- package/dist/interactive/interactive-stream-hook.d.ts +0 -68
- package/dist/packem_shared/InteractiveManager-CZ85hGNW.js +0 -172
- package/dist/packem_shared/PrettyReporter-DgZB2eBG.js +0 -222
- package/dist/packem_shared/abstract-pretty-reporter-Di_sdm2r.js +0 -50
- package/dist/packem_shared/format-label-De49vNPd.js +0 -1193
- package/dist/packem_shared/get-longest-label-C9PWeyKq.js +0 -9
- package/dist/packem_shared/index-DqKWykfa.js +0 -1146
- package/dist/packem_shared/interactive-stream-hook-DG4BtN12.js +0 -141
- package/dist/packem_shared/pail.browser-u2CSR_af.js +0 -1427
- package/dist/progress-bar.d.ts +0 -136
- package/dist/progress-bar.js +0 -404
- package/dist/spinner.d.ts +0 -220
- package/dist/spinner.js +0 -2150
- package/dist/utils/ansi-escapes.d.ts +0 -4
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { t as terminalSize, w as wordWrap, W as WrapMode } from './index-DqKWykfa.js';
|
|
2
|
-
|
|
3
|
-
class InteractiveManager {
|
|
4
|
-
#stream;
|
|
5
|
-
#isActive = false;
|
|
6
|
-
#isSuspended = false;
|
|
7
|
-
#lastLength = 0;
|
|
8
|
-
#outside = 0;
|
|
9
|
-
/**
|
|
10
|
-
* Creates a new InteractiveManager with the given stream hooks.
|
|
11
|
-
* @param stdout Hook for stdout stream
|
|
12
|
-
* @param stderr Hook for stderr stream
|
|
13
|
-
*/
|
|
14
|
-
constructor(stdout, stderr) {
|
|
15
|
-
this.#stream = {
|
|
16
|
-
stderr,
|
|
17
|
-
stdout
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Last printed rows count.
|
|
22
|
-
*
|
|
23
|
-
* Tracks the number of rows that were last written to the terminal.
|
|
24
|
-
* Used internally for managing cursor positioning and output updates.
|
|
25
|
-
*/
|
|
26
|
-
get lastLength() {
|
|
27
|
-
return this.#lastLength;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Rows count outside editable area.
|
|
31
|
-
*
|
|
32
|
-
* Tracks the number of rows that extend beyond the current terminal height.
|
|
33
|
-
* Used for managing scrolling and ensuring all output remains visible.
|
|
34
|
-
*/
|
|
35
|
-
get outside() {
|
|
36
|
-
return this.#outside;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Hook activity status.
|
|
40
|
-
*
|
|
41
|
-
* Indicates whether the interactive hooks are currently active.
|
|
42
|
-
* When true, streams are being intercepted for interactive output.
|
|
43
|
-
*/
|
|
44
|
-
get isHooked() {
|
|
45
|
-
return this.#isActive;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Suspend status for active hooks.
|
|
49
|
-
*
|
|
50
|
-
* Indicates whether interactive mode is temporarily suspended.
|
|
51
|
-
* When suspended, external output can be written without interference.
|
|
52
|
-
*/
|
|
53
|
-
get isSuspended() {
|
|
54
|
-
return this.#isSuspended;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Removes lines from the terminal output.
|
|
58
|
-
*
|
|
59
|
-
* Erases the specified number of lines from the bottom of the output,
|
|
60
|
-
* moving the cursor up and clearing the lines. Useful for removing
|
|
61
|
-
* previous interactive output before displaying new content.
|
|
62
|
-
* @param stream The stream to erase lines from ("stdout" or "stderr")
|
|
63
|
-
* @param count Number of lines to remove (defaults to lastLength)
|
|
64
|
-
* @throws {TypeError} If the specified stream is not available
|
|
65
|
-
*/
|
|
66
|
-
erase(stream, count = this.#lastLength) {
|
|
67
|
-
if (this.#stream[stream] === void 0) {
|
|
68
|
-
throw new TypeError(`Stream "${stream}" is not available`);
|
|
69
|
-
}
|
|
70
|
-
this.#stream[stream].erase(count);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Hook stdout and stderr streams.
|
|
74
|
-
* @returns Success status
|
|
75
|
-
*/
|
|
76
|
-
hook() {
|
|
77
|
-
if (!this.#isActive) {
|
|
78
|
-
Object.values(this.#stream).forEach((hook) => hook.active());
|
|
79
|
-
this.#clear(true);
|
|
80
|
-
}
|
|
81
|
-
return this.#isActive;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Resume suspend hooks.
|
|
85
|
-
* @param stream Stream to resume
|
|
86
|
-
* @param eraseRowCount erase output rows count
|
|
87
|
-
*/
|
|
88
|
-
resume(stream, eraseRowCount) {
|
|
89
|
-
if (this.#isSuspended) {
|
|
90
|
-
this.#isSuspended = false;
|
|
91
|
-
if (eraseRowCount) {
|
|
92
|
-
this.erase(stream, eraseRowCount);
|
|
93
|
-
}
|
|
94
|
-
this.#lastLength = 0;
|
|
95
|
-
Object.values(this.#stream).forEach((hook) => hook.active());
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Suspend active hooks for external output.
|
|
100
|
-
* @param stream Stream to suspend
|
|
101
|
-
* @param erase erase output
|
|
102
|
-
*/
|
|
103
|
-
suspend(stream, erase = true) {
|
|
104
|
-
if (!this.#isSuspended) {
|
|
105
|
-
this.#isSuspended = true;
|
|
106
|
-
if (erase) {
|
|
107
|
-
this.erase(stream);
|
|
108
|
-
}
|
|
109
|
-
Object.values(this.#stream).forEach((hook) => hook.renew());
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Unhooks both stdout and stderr streams and print their story of logs.
|
|
114
|
-
* @param separateHistory If `true`, will add an empty line to the history output for individual recorded lines and console logs
|
|
115
|
-
* @returns Success status
|
|
116
|
-
*/
|
|
117
|
-
unhook(separateHistory = true) {
|
|
118
|
-
if (this.#isActive) {
|
|
119
|
-
Object.values(this.#stream).forEach((hook) => hook.inactive(separateHistory));
|
|
120
|
-
this.#clear();
|
|
121
|
-
}
|
|
122
|
-
return !this.#isActive;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Update output.
|
|
126
|
-
* @param stream Stream to write to
|
|
127
|
-
* @param rows Text lines to write to standard output
|
|
128
|
-
* @param from Index of the line starting from which the contents of the terminal are being overwritten
|
|
129
|
-
*/
|
|
130
|
-
update(stream, rows, from = 0) {
|
|
131
|
-
if (rows.length > 0) {
|
|
132
|
-
if (this.#stream[stream] === void 0) {
|
|
133
|
-
throw new TypeError(`Stream "${stream}" is not available`);
|
|
134
|
-
}
|
|
135
|
-
const hook = this.#stream[stream];
|
|
136
|
-
const { columns: width, rows: height } = terminalSize();
|
|
137
|
-
const position = from > height ? height - 1 : Math.max(0, Math.min(height - 1, from));
|
|
138
|
-
const actualLength = this.lastLength - position;
|
|
139
|
-
const outside = Math.max(actualLength - height, this.outside);
|
|
140
|
-
let output = rows.reduce(
|
|
141
|
-
(accumulator, row) => [
|
|
142
|
-
...accumulator,
|
|
143
|
-
wordWrap(row, {
|
|
144
|
-
trim: false,
|
|
145
|
-
width,
|
|
146
|
-
wrapMode: WrapMode.STRICT_WIDTH
|
|
147
|
-
})
|
|
148
|
-
],
|
|
149
|
-
[]
|
|
150
|
-
);
|
|
151
|
-
if (height <= actualLength) {
|
|
152
|
-
hook.erase(height);
|
|
153
|
-
if (position < outside) {
|
|
154
|
-
output = output.slice(outside - position + 1);
|
|
155
|
-
}
|
|
156
|
-
} else if (actualLength) {
|
|
157
|
-
hook.erase(actualLength);
|
|
158
|
-
}
|
|
159
|
-
hook.write(`${output.join("\n")}
|
|
160
|
-
`);
|
|
161
|
-
this.#lastLength = outside ? outside + output.length + 1 : output.length;
|
|
162
|
-
this.#outside = Math.max(this.lastLength - height, this.outside);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
#clear(status = false) {
|
|
166
|
-
this.#isActive = status;
|
|
167
|
-
this.#lastLength = 0;
|
|
168
|
-
this.#outside = 0;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export { InteractiveManager as default };
|
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
import { createRequire as __cjs_createRequire } from "node:module";
|
|
2
|
-
|
|
3
|
-
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
|
-
|
|
5
|
-
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
6
|
-
|
|
7
|
-
const {
|
|
8
|
-
stdout,
|
|
9
|
-
stderr
|
|
10
|
-
} = __cjs_getProcess;
|
|
11
|
-
import colorize, { red, greenBright, cyan, green, grey, white, bgGrey, underline } from '@visulima/colorize';
|
|
12
|
-
import { d as defaultInspectorConfig, f as formatLabel, i as inspect, r as renderError } from './format-label-De49vNPd.js';
|
|
13
|
-
import { t as terminalSize, g as getStringWidth, w as wordWrap, W as WrapMode } from './index-DqKWykfa.js';
|
|
14
|
-
import { E as EMPTY_SYMBOL } from './constants-omsTHUWB.js';
|
|
15
|
-
import { A as AbstractPrettyReporter, g as getLongestBadge } from './abstract-pretty-reporter-Di_sdm2r.js';
|
|
16
|
-
import { g as getLongestLabel } from './get-longest-label-C9PWeyKq.js';
|
|
17
|
-
import { w as writeStream } from './write-stream-BG8fhcs3.js';
|
|
18
|
-
|
|
19
|
-
const pailFileFilter = (line) => !/[\\/]pail[\\/]dist/.test(line);
|
|
20
|
-
class PrettyReporter extends AbstractPrettyReporter {
|
|
21
|
-
#stdout;
|
|
22
|
-
#stderr;
|
|
23
|
-
#interactiveManager;
|
|
24
|
-
#interactive = false;
|
|
25
|
-
#inspectOptions;
|
|
26
|
-
#errorOptions;
|
|
27
|
-
/**
|
|
28
|
-
* Creates a new Server Pretty Reporter instance.
|
|
29
|
-
* @param options Configuration options for styling, error rendering, and object inspection
|
|
30
|
-
*/
|
|
31
|
-
constructor(options = {}) {
|
|
32
|
-
const { error: errorOptions, inspect: inspectOptions, ...rest } = options;
|
|
33
|
-
super({
|
|
34
|
-
uppercase: {
|
|
35
|
-
label: true,
|
|
36
|
-
...rest.uppercase
|
|
37
|
-
},
|
|
38
|
-
...rest
|
|
39
|
-
});
|
|
40
|
-
this.#inspectOptions = { ...defaultInspectorConfig, ...inspectOptions };
|
|
41
|
-
this.#errorOptions = {
|
|
42
|
-
...errorOptions,
|
|
43
|
-
color: {
|
|
44
|
-
fileLine: green,
|
|
45
|
-
hint: cyan,
|
|
46
|
-
marker: red,
|
|
47
|
-
message: red,
|
|
48
|
-
method: greenBright,
|
|
49
|
-
title: red
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
this.#stdout = stdout;
|
|
53
|
-
this.#stderr = stderr;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Sets the stdout stream for the reporter.
|
|
57
|
-
* @param stdout_ The writable stream to use for standard output
|
|
58
|
-
*/
|
|
59
|
-
setStdout(stdout_) {
|
|
60
|
-
this.#stdout = stdout_;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Sets the stderr stream for the reporter.
|
|
64
|
-
* @param stderr_ The writable stream to use for error output
|
|
65
|
-
*/
|
|
66
|
-
setStderr(stderr_) {
|
|
67
|
-
this.#stderr = stderr_;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Sets the interactive manager for handling interactive output.
|
|
71
|
-
* @param manager The interactive manager instance, or undefined to disable
|
|
72
|
-
*/
|
|
73
|
-
setInteractiveManager(manager) {
|
|
74
|
-
this.#interactiveManager = manager;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Enables or disables interactive mode.
|
|
78
|
-
* @param interactive Whether to enable interactive terminal features
|
|
79
|
-
*/
|
|
80
|
-
setIsInteractive(interactive) {
|
|
81
|
-
this.#interactive = interactive;
|
|
82
|
-
}
|
|
83
|
-
log(meta) {
|
|
84
|
-
this._log(this._formatMessage(meta), meta.type.level);
|
|
85
|
-
}
|
|
86
|
-
// eslint-disable-next-line sonarjs/cognitive-complexity, no-underscore-dangle
|
|
87
|
-
_formatMessage(data) {
|
|
88
|
-
const { columns } = terminalSize();
|
|
89
|
-
let size = columns;
|
|
90
|
-
if (typeof this.styles.messageLength === "number") {
|
|
91
|
-
size = this.styles.messageLength;
|
|
92
|
-
}
|
|
93
|
-
const { badge, context, date, error, file, groups, label, message, prefix, repeated, scope, suffix, traceError, type } = data;
|
|
94
|
-
const { color } = this.loggerTypes[type.name];
|
|
95
|
-
const colorized = color ? colorize[color] : white;
|
|
96
|
-
const groupSpaces = groups.map(() => " ").join("");
|
|
97
|
-
const items = [];
|
|
98
|
-
if (groups.length > 0) {
|
|
99
|
-
items.push(`${groupSpaces + grey(`[${groups.at(-1)}]`)} `);
|
|
100
|
-
}
|
|
101
|
-
if (date) {
|
|
102
|
-
items.push(`${grey(this.styles.dateFormatter(typeof date === "string" ? new Date(date) : date))} `);
|
|
103
|
-
}
|
|
104
|
-
if (badge) {
|
|
105
|
-
items.push(colorized(badge));
|
|
106
|
-
} else {
|
|
107
|
-
const longestBadge = getLongestBadge(this.loggerTypes);
|
|
108
|
-
if (longestBadge.length > 0) {
|
|
109
|
-
items.push(`${grey(".".repeat(longestBadge.length))} `);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
const longestLabel = getLongestLabel(this.loggerTypes);
|
|
113
|
-
if (label) {
|
|
114
|
-
const longestLabelWidth = getStringWidth(longestLabel);
|
|
115
|
-
const labelWidth = getStringWidth(label);
|
|
116
|
-
items.push(`${colorized(formatLabel(label, this.styles))} `, grey(".".repeat(Math.max(0, longestLabelWidth - labelWidth))));
|
|
117
|
-
} else {
|
|
118
|
-
items.push(grey(".".repeat(longestLabel.length + 2)));
|
|
119
|
-
}
|
|
120
|
-
if (repeated) {
|
|
121
|
-
items.push(`${bgGrey.white(`[${repeated}x]`)} `);
|
|
122
|
-
}
|
|
123
|
-
if (Array.isArray(scope) && scope.length > 0) {
|
|
124
|
-
items.push(` ${grey(`[${scope.join(" > ")}]`)} `);
|
|
125
|
-
}
|
|
126
|
-
if (prefix) {
|
|
127
|
-
items.push(
|
|
128
|
-
`${grey(`${Array.isArray(scope) && scope.length > 0 ? ". " : " "}[${this.styles.underline.prefix ? underline(prefix) : prefix}]`)} `
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
const titleSize = getStringWidth(items.join(" "));
|
|
132
|
-
if (file) {
|
|
133
|
-
const fileMessage = file.name + (file.line ? `:${file.line}` : "");
|
|
134
|
-
const fileMessageSize = getStringWidth(fileMessage);
|
|
135
|
-
if (fileMessageSize + titleSize + 2 > size) {
|
|
136
|
-
items.push(grey(` ${fileMessage}`));
|
|
137
|
-
} else {
|
|
138
|
-
const dots = Math.max(0, size - titleSize - fileMessageSize - 2);
|
|
139
|
-
items.push(grey(`${".".repeat(dots)} ${fileMessage}`));
|
|
140
|
-
}
|
|
141
|
-
} else {
|
|
142
|
-
items.push(grey(".".repeat(Math.max(0, size - titleSize - 1))));
|
|
143
|
-
}
|
|
144
|
-
if (items.length > 0) {
|
|
145
|
-
items.push("\n\n");
|
|
146
|
-
}
|
|
147
|
-
if (message !== EMPTY_SYMBOL) {
|
|
148
|
-
const formattedMessage = typeof message === "string" ? message : inspect(message, this.#inspectOptions);
|
|
149
|
-
items.push(
|
|
150
|
-
groupSpaces + wordWrap(formattedMessage, {
|
|
151
|
-
trim: false,
|
|
152
|
-
width: size - 3,
|
|
153
|
-
wrapMode: WrapMode.STRICT_WIDTH
|
|
154
|
-
})
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
if (context) {
|
|
158
|
-
let hasError = false;
|
|
159
|
-
items.push(
|
|
160
|
-
...context.map((value) => {
|
|
161
|
-
if (value instanceof Error) {
|
|
162
|
-
hasError = true;
|
|
163
|
-
return `
|
|
164
|
-
|
|
165
|
-
${renderError(value, {
|
|
166
|
-
...this.#errorOptions,
|
|
167
|
-
filterStacktrace: pailFileFilter,
|
|
168
|
-
prefix: groupSpaces
|
|
169
|
-
})}`;
|
|
170
|
-
}
|
|
171
|
-
if (typeof value === "object") {
|
|
172
|
-
return ` ${inspect(value, this.#inspectOptions)}`;
|
|
173
|
-
}
|
|
174
|
-
const newValue = (hasError ? "\n\n" : " ") + value;
|
|
175
|
-
hasError = false;
|
|
176
|
-
return newValue;
|
|
177
|
-
})
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
if (error) {
|
|
181
|
-
items.push(
|
|
182
|
-
renderError(error, {
|
|
183
|
-
...this.#errorOptions,
|
|
184
|
-
filterStacktrace: pailFileFilter,
|
|
185
|
-
prefix: groupSpaces
|
|
186
|
-
})
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
if (traceError) {
|
|
190
|
-
items.push(
|
|
191
|
-
`
|
|
192
|
-
|
|
193
|
-
${renderError(traceError, {
|
|
194
|
-
...this.#errorOptions,
|
|
195
|
-
filterStacktrace: pailFileFilter,
|
|
196
|
-
hideErrorCauseCodeView: true,
|
|
197
|
-
hideErrorCodeView: true,
|
|
198
|
-
hideErrorErrorsCodeView: true,
|
|
199
|
-
hideMessage: true,
|
|
200
|
-
prefix: groupSpaces
|
|
201
|
-
})}`
|
|
202
|
-
);
|
|
203
|
-
}
|
|
204
|
-
if (suffix) {
|
|
205
|
-
items.push("\n", groupSpaces + grey(this.styles.underline.suffix ? underline(suffix) : suffix));
|
|
206
|
-
}
|
|
207
|
-
return items.join("");
|
|
208
|
-
}
|
|
209
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
210
|
-
_log(message, logLevel) {
|
|
211
|
-
const streamType = ["error", "trace", "warn"].includes(logLevel) ? "stderr" : "stdout";
|
|
212
|
-
const stream = streamType === "stderr" ? this.#stderr : this.#stdout;
|
|
213
|
-
if (this.#interactive && this.#interactiveManager !== void 0 && stream.isTTY) {
|
|
214
|
-
this.#interactiveManager.update(streamType, message.split("\n"), 0);
|
|
215
|
-
} else {
|
|
216
|
-
writeStream(`${message}
|
|
217
|
-
`, stream);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export { PrettyReporter };
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { L as LOG_TYPES } from './constants-omsTHUWB.js';
|
|
2
|
-
|
|
3
|
-
const getLongestBadge = (types) => {
|
|
4
|
-
const badges = Object.keys(types).map((x) => types[x].badge ?? "");
|
|
5
|
-
if (badges.length === 0) {
|
|
6
|
-
return "";
|
|
7
|
-
}
|
|
8
|
-
return badges.reduce((x, y) => x.length > y.length ? x : y);
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const dateFormatter = (date) => [date.getHours(), date.getMinutes(), date.getSeconds()].map((n) => String(n).padStart(2, "0")).join(":");
|
|
12
|
-
class AbstractPrettyReporter {
|
|
13
|
-
/** Styling options for pretty formatting */
|
|
14
|
-
styles;
|
|
15
|
-
/** Logger type configurations for styling */
|
|
16
|
-
loggerTypes;
|
|
17
|
-
/**
|
|
18
|
-
* Creates a new AbstractPrettyReporter instance.
|
|
19
|
-
* @param options Styling options for pretty formatting
|
|
20
|
-
* @protected
|
|
21
|
-
*/
|
|
22
|
-
constructor(options) {
|
|
23
|
-
this.styles = {
|
|
24
|
-
bold: {
|
|
25
|
-
label: false
|
|
26
|
-
},
|
|
27
|
-
dateFormatter,
|
|
28
|
-
underline: {
|
|
29
|
-
label: false,
|
|
30
|
-
message: false,
|
|
31
|
-
prefix: false,
|
|
32
|
-
suffix: false
|
|
33
|
-
},
|
|
34
|
-
uppercase: {
|
|
35
|
-
label: false
|
|
36
|
-
},
|
|
37
|
-
...options
|
|
38
|
-
};
|
|
39
|
-
this.loggerTypes = LOG_TYPES;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Sets the logger types configuration for styling.
|
|
43
|
-
* @param types Logger type configurations with colors and labels
|
|
44
|
-
*/
|
|
45
|
-
setLoggerTypes(types) {
|
|
46
|
-
this.loggerTypes = types;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export { AbstractPrettyReporter as A, getLongestBadge as g };
|