@visulima/pail 2.1.27 → 2.1.28
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 +11 -0
- package/dist/index.browser.cjs +1 -19
- package/dist/index.browser.mjs +1 -14
- package/dist/index.server.cjs +5 -442
- package/dist/index.server.mjs +5 -437
- package/dist/packem_shared/CallerProcessor-DJnmMPMj.cjs +1 -0
- package/dist/packem_shared/CallerProcessor-mNkBei3j.mjs +1 -0
- package/dist/packem_shared/JsonFileReporter-BnxuhH4o.cjs +2 -0
- package/dist/packem_shared/JsonFileReporter-Og8hyKfg.mjs +4 -0
- package/dist/packem_shared/JsonReporter-BdExg5gk.mjs +1 -0
- package/dist/packem_shared/JsonReporter-CjvkrXUp.cjs +1 -0
- package/dist/packem_shared/JsonReporter-DRGJgjAO.mjs +2 -0
- package/dist/packem_shared/JsonReporter-DuF0Ho5i.cjs +2 -0
- package/dist/packem_shared/MessageFormatterProcessor-BjBZzL2D.mjs +1 -0
- package/dist/packem_shared/MessageFormatterProcessor-CCRIUIdT.cjs +1 -0
- package/dist/packem_shared/PrettyReporter-BRFlkORc.mjs +5 -0
- package/dist/packem_shared/PrettyReporter-BuKPqA5T.cjs +5 -0
- package/dist/packem_shared/PrettyReporter-DDsX0vlT.mjs +13 -0
- package/dist/packem_shared/PrettyReporter-Dx1OfdGj.cjs +13 -0
- package/dist/packem_shared/RedactProcessor-BBJysXaX.cjs +1 -0
- package/dist/packem_shared/RedactProcessor-CxKTN42V.mjs +3 -0
- package/dist/packem_shared/SimpleReporter-BV0taliz.mjs +11 -0
- package/dist/packem_shared/SimpleReporter-YuzZZabX.cjs +11 -0
- package/dist/packem_shared/abstract-json-reporter-Z6bVrpPK.cjs +1 -0
- package/dist/packem_shared/abstract-json-reporter-tFmKAzRZ.mjs +1 -0
- package/dist/packem_shared/abstract-pretty-reporter-C2vDqWAQ.cjs +1 -0
- package/dist/packem_shared/abstract-pretty-reporter-CRcf4WZd.mjs +1 -0
- package/dist/packem_shared/constants-BFrKdBPm.cjs +1 -0
- package/dist/packem_shared/constants-BMS51p6Y.mjs +1 -0
- package/dist/packem_shared/format-label-CKRxcWAQ.cjs +8 -0
- package/dist/packem_shared/format-label-D2xt_3df.mjs +8 -0
- package/dist/packem_shared/get-longest-label-7LkwzzHo.cjs +1 -0
- package/dist/packem_shared/get-longest-label-B0NrI-o2.mjs +1 -0
- package/dist/packem_shared/pail.browser-DC6QwLTj.cjs +1 -0
- package/dist/packem_shared/pail.browser-DkNIDzgk.mjs +1 -0
- package/dist/packem_shared/write-console-log-3G15muTS.cjs +1 -0
- package/dist/packem_shared/write-console-log-BP95fgQZ.mjs +1 -0
- package/dist/packem_shared/write-stream-CD8XFv1L.mjs +1 -0
- package/dist/packem_shared/write-stream-Dl-usQqh.cjs +1 -0
- package/dist/processor.browser.cjs +1 -11
- package/dist/processor.browser.mjs +1 -2
- package/dist/processor.server.cjs +1 -13
- package/dist/processor.server.mjs +1 -3
- package/dist/reporter.browser.cjs +1 -11
- package/dist/reporter.browser.mjs +1 -2
- package/dist/reporter.server.cjs +1 -15
- package/dist/reporter.server.mjs +1 -4
- package/package.json +2 -2
- package/dist/packem_shared/CallerProcessor-CNhuyGAa.mjs +0 -58
- package/dist/packem_shared/CallerProcessor-DJ5euiUK.cjs +0 -60
- package/dist/packem_shared/JsonFileReporter-BazAMbEI.mjs +0 -133
- package/dist/packem_shared/JsonFileReporter-PNmBNTr1.cjs +0 -135
- package/dist/packem_shared/JsonReporter-CKWF4Ibl.mjs +0 -20
- package/dist/packem_shared/JsonReporter-CcOVaf3A.cjs +0 -34
- package/dist/packem_shared/JsonReporter-Cg5R1FXn.cjs +0 -22
- package/dist/packem_shared/JsonReporter-DFFyVZyh.mjs +0 -32
- package/dist/packem_shared/MessageFormatterProcessor-Cd4HntPG.mjs +0 -53
- package/dist/packem_shared/MessageFormatterProcessor-t4t6CpzV.cjs +0 -55
- package/dist/packem_shared/PrettyReporter-3oMWkX6j.cjs +0 -200
- package/dist/packem_shared/PrettyReporter-Bx3QLZrW.mjs +0 -162
- package/dist/packem_shared/PrettyReporter-C2hjNe-y.mjs +0 -192
- package/dist/packem_shared/PrettyReporter-mFCjMb0i.cjs +0 -168
- package/dist/packem_shared/RedactProcessor-CfNkF2lC.mjs +0 -26
- package/dist/packem_shared/RedactProcessor-DWE5iqAQ.cjs +0 -26
- package/dist/packem_shared/SimpleReporter-CXXqr1h3.cjs +0 -186
- package/dist/packem_shared/SimpleReporter-TOcMSqJb.mjs +0 -178
- package/dist/packem_shared/abstract-json-reporter-okwLqT9k.cjs +0 -57
- package/dist/packem_shared/abstract-json-reporter-sxnmNIlg.mjs +0 -55
- package/dist/packem_shared/abstract-pretty-reporter-BR_6_JVa.cjs +0 -49
- package/dist/packem_shared/abstract-pretty-reporter-izJgxoMv.mjs +0 -46
- package/dist/packem_shared/constants-BYYZ5WNW.mjs +0 -114
- package/dist/packem_shared/constants-DHfYGxxG.cjs +0 -118
- package/dist/packem_shared/format-label-DYEhjrTZ.cjs +0 -621
- package/dist/packem_shared/format-label-Uj-cxY3j.mjs +0 -609
- package/dist/packem_shared/get-longest-label-CM8kLFWH.mjs +0 -11
- package/dist/packem_shared/get-longest-label-CQ7lRhgD.cjs +0 -13
- package/dist/packem_shared/pail.browser-Bp1fz428.mjs +0 -384
- package/dist/packem_shared/pail.browser-O53Q_cus.cjs +0 -387
- package/dist/packem_shared/write-console-log-Cu0-IDN-.cjs +0 -18
- package/dist/packem_shared/write-console-log-Tptfzg9D.mjs +0 -16
- package/dist/packem_shared/write-stream-BBAF33Zm.mjs +0 -8
- package/dist/packem_shared/write-stream-CkNf2Ju8.cjs +0 -10
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import colorize, { grey, white, underline, bold } from '@visulima/colorize/browser';
|
|
2
|
-
import { format } from '@visulima/fmt';
|
|
3
|
-
import { E as EMPTY_SYMBOL } from './constants-BYYZ5WNW.mjs';
|
|
4
|
-
import { A as AbstractPrettyReporter, g as getLongestBadge } from './abstract-pretty-reporter-izJgxoMv.mjs';
|
|
5
|
-
import { g as getLongestLabel } from './get-longest-label-CM8kLFWH.mjs';
|
|
6
|
-
import { w as writeConsoleLogBasedOnLevel } from './write-console-log-Tptfzg9D.mjs';
|
|
7
|
-
|
|
8
|
-
var __defProp = Object.defineProperty;
|
|
9
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
-
class PrettyReporter extends AbstractPrettyReporter {
|
|
11
|
-
static {
|
|
12
|
-
__name(this, "PrettyReporter");
|
|
13
|
-
}
|
|
14
|
-
constructor(options = {}) {
|
|
15
|
-
super({
|
|
16
|
-
uppercase: {
|
|
17
|
-
label: true,
|
|
18
|
-
...options.uppercase
|
|
19
|
-
},
|
|
20
|
-
...options
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
24
|
-
log(meta) {
|
|
25
|
-
const isNotBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
26
|
-
const consoleLogFunction = writeConsoleLogBasedOnLevel(meta.type.level);
|
|
27
|
-
const { badge, context, date, error, groups, label, message, prefix, repeated, scope, suffix, type } = meta;
|
|
28
|
-
const { color } = this._loggerTypes[type.name];
|
|
29
|
-
const colorized = color ? colorize[color] : white;
|
|
30
|
-
const items = [];
|
|
31
|
-
if (isNotBrowser && groups.length > 0) {
|
|
32
|
-
const groupSpaces = groups.map(() => " ").join("");
|
|
33
|
-
const cGroup = grey("[" + groups.at(-1) + "]");
|
|
34
|
-
items.push(format(groupSpaces + cGroup[0], cGroup.slice(1)));
|
|
35
|
-
}
|
|
36
|
-
if (date) {
|
|
37
|
-
const cDate = grey(this._styles.dateFormatter(typeof date === "string" ? new Date(date) : date));
|
|
38
|
-
if (isNotBrowser) {
|
|
39
|
-
items.push(format(cDate[0], cDate.slice(1)));
|
|
40
|
-
} else {
|
|
41
|
-
items.push([cDate[0] + " ", ...cDate.slice(1)]);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (badge) {
|
|
45
|
-
const cBadge = colorized(badge);
|
|
46
|
-
if (isNotBrowser) {
|
|
47
|
-
items.push(format(cBadge[0], cBadge.slice(1)));
|
|
48
|
-
} else {
|
|
49
|
-
items.push([cBadge[0] + " ", ...cBadge.slice(1)]);
|
|
50
|
-
}
|
|
51
|
-
} else {
|
|
52
|
-
const longestBadge = getLongestBadge(this._loggerTypes);
|
|
53
|
-
if (longestBadge.length > 0) {
|
|
54
|
-
const cBadgePlaceholder = grey(".".repeat(longestBadge.length));
|
|
55
|
-
if (isNotBrowser) {
|
|
56
|
-
items.push(format(cBadgePlaceholder[0] + " ", cBadgePlaceholder.slice(1)));
|
|
57
|
-
} else {
|
|
58
|
-
items.push([cBadgePlaceholder[0] + " ", ...cBadgePlaceholder.slice(1)]);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
const longestLabel = getLongestLabel(this._loggerTypes);
|
|
63
|
-
let repeatedMessage;
|
|
64
|
-
if (repeated) {
|
|
65
|
-
const cRepeated = white("[" + repeated + "x]");
|
|
66
|
-
repeatedMessage = isNotBrowser ? format(cRepeated[0], cRepeated.slice(1)) : [cRepeated[0], ...cRepeated.slice(1)];
|
|
67
|
-
}
|
|
68
|
-
if (label) {
|
|
69
|
-
const cLabel = colorized(this._formatLabel(label));
|
|
70
|
-
if (isNotBrowser) {
|
|
71
|
-
items.push(format(cLabel[0], cLabel.slice(1)));
|
|
72
|
-
} else {
|
|
73
|
-
items.push([cLabel[0], ...cLabel.slice(1)]);
|
|
74
|
-
}
|
|
75
|
-
if (repeatedMessage) {
|
|
76
|
-
items.push(repeatedMessage);
|
|
77
|
-
}
|
|
78
|
-
let lengthDiff = longestLabel.length - label.length;
|
|
79
|
-
if (repeated) {
|
|
80
|
-
lengthDiff -= String(repeated).length + 3;
|
|
81
|
-
} else {
|
|
82
|
-
lengthDiff += 1;
|
|
83
|
-
}
|
|
84
|
-
if (lengthDiff > 0) {
|
|
85
|
-
const cLabelSpacer = grey(".".repeat(lengthDiff));
|
|
86
|
-
if (isNotBrowser) {
|
|
87
|
-
items.push(format(cLabelSpacer[0], cLabelSpacer.slice(1)));
|
|
88
|
-
} else {
|
|
89
|
-
items.push([" " + cLabelSpacer[0], ...cLabelSpacer.slice(1)]);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
} else {
|
|
93
|
-
const cSpacer = grey(".".repeat(longestLabel.length + 1));
|
|
94
|
-
if (isNotBrowser) {
|
|
95
|
-
items.push(format(cSpacer[0], cSpacer.slice(1)));
|
|
96
|
-
} else {
|
|
97
|
-
items.push([cSpacer[0], ...cSpacer.slice(1)]);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
if (Array.isArray(scope) && scope.length > 0) {
|
|
101
|
-
const cScope = grey("[" + scope.join(" > ") + "]");
|
|
102
|
-
if (isNotBrowser) {
|
|
103
|
-
items.push(format(cScope[0], cScope.slice(1)));
|
|
104
|
-
} else {
|
|
105
|
-
items.push([cScope[0], ...cScope.slice(1)]);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
if (prefix) {
|
|
109
|
-
const cPrefix = grey(
|
|
110
|
-
(Array.isArray(scope) && scope.length > 0 ? ". " : " ") + "[" + (this._styles.underline.prefix ? underline(prefix) : prefix) + "] "
|
|
111
|
-
);
|
|
112
|
-
if (isNotBrowser) {
|
|
113
|
-
items.push(format(cPrefix[0], cPrefix.slice(1)));
|
|
114
|
-
} else {
|
|
115
|
-
items.push([cPrefix[0], ...cPrefix.slice(1)]);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
if (message !== EMPTY_SYMBOL) {
|
|
119
|
-
items.push(message);
|
|
120
|
-
}
|
|
121
|
-
if (context) {
|
|
122
|
-
items.push(...context);
|
|
123
|
-
}
|
|
124
|
-
if (error) {
|
|
125
|
-
items.push(error, "\n\n");
|
|
126
|
-
}
|
|
127
|
-
if (suffix) {
|
|
128
|
-
const cSuffix = grey(this._styles.underline.suffix ? underline(suffix) : suffix);
|
|
129
|
-
if (isNotBrowser) {
|
|
130
|
-
items.push(format("\n" + cSuffix[0], cSuffix.slice(1)));
|
|
131
|
-
} else {
|
|
132
|
-
items.push(["\n" + cSuffix[0], ...cSuffix.slice(1)]);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
if (isNotBrowser) {
|
|
136
|
-
consoleLogFunction(...items);
|
|
137
|
-
} else {
|
|
138
|
-
let logMessage = "";
|
|
139
|
-
const css = [];
|
|
140
|
-
const arguments_ = [];
|
|
141
|
-
for (const value of items) {
|
|
142
|
-
if (Array.isArray(value) && value.length > 1 && value[0].includes("%c")) {
|
|
143
|
-
logMessage += value[0];
|
|
144
|
-
css.push(...value.slice(1));
|
|
145
|
-
} else {
|
|
146
|
-
arguments_.push(value);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
consoleLogFunction(logMessage + "%c", ...css, "", ...arguments_);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
_formatLabel(label) {
|
|
153
|
-
let formattedLabel = this._styles.uppercase.label ? label.toUpperCase() : label;
|
|
154
|
-
formattedLabel = this._styles.underline.label ? underline(formattedLabel) : formattedLabel;
|
|
155
|
-
if (this._styles.bold.label) {
|
|
156
|
-
formattedLabel = bold(formattedLabel);
|
|
157
|
-
}
|
|
158
|
-
return formattedLabel;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export { PrettyReporter as default };
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { stdout, stderr } from 'node:process';
|
|
2
|
-
import colorize, { red, greenBright, cyan, green, grey, white, bgGrey, underline } from '@visulima/colorize';
|
|
3
|
-
import { renderError } from '@visulima/error/error';
|
|
4
|
-
import { inspect } from '@visulima/inspector';
|
|
5
|
-
import { d as defaultInspectorConfig, t as terminalSize, f as formatLabel, s as stringLength, w as wrapAnsi } from './format-label-Uj-cxY3j.mjs';
|
|
6
|
-
import { E as EMPTY_SYMBOL } from './constants-BYYZ5WNW.mjs';
|
|
7
|
-
import { A as AbstractPrettyReporter, g as getLongestBadge } from './abstract-pretty-reporter-izJgxoMv.mjs';
|
|
8
|
-
import { g as getLongestLabel } from './get-longest-label-CM8kLFWH.mjs';
|
|
9
|
-
import { w as writeStream } from './write-stream-BBAF33Zm.mjs';
|
|
10
|
-
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
13
|
-
const pailFileFilter = /* @__PURE__ */ __name((line) => !/[\\/]pail[\\/]dist/.test(line), "pailFileFilter");
|
|
14
|
-
class PrettyReporter extends AbstractPrettyReporter {
|
|
15
|
-
static {
|
|
16
|
-
__name(this, "PrettyReporter");
|
|
17
|
-
}
|
|
18
|
-
#stdout;
|
|
19
|
-
#stderr;
|
|
20
|
-
#interactiveManager;
|
|
21
|
-
#interactive = false;
|
|
22
|
-
#inspectOptions;
|
|
23
|
-
#errorOptions;
|
|
24
|
-
constructor(options = {}) {
|
|
25
|
-
const { error: errorOptions, inspect: inspectOptions, ...rest } = options;
|
|
26
|
-
super({
|
|
27
|
-
uppercase: {
|
|
28
|
-
label: true,
|
|
29
|
-
...rest.uppercase
|
|
30
|
-
},
|
|
31
|
-
...rest
|
|
32
|
-
});
|
|
33
|
-
this.#inspectOptions = { ...defaultInspectorConfig, ...inspectOptions };
|
|
34
|
-
this.#errorOptions = {
|
|
35
|
-
...errorOptions,
|
|
36
|
-
color: {
|
|
37
|
-
fileLine: green,
|
|
38
|
-
hint: cyan,
|
|
39
|
-
marker: red,
|
|
40
|
-
message: red,
|
|
41
|
-
method: greenBright,
|
|
42
|
-
title: red
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
this.#stdout = stdout;
|
|
46
|
-
this.#stderr = stderr;
|
|
47
|
-
}
|
|
48
|
-
setStdout(stdout_) {
|
|
49
|
-
this.#stdout = stdout_;
|
|
50
|
-
}
|
|
51
|
-
setStderr(stderr_) {
|
|
52
|
-
this.#stderr = stderr_;
|
|
53
|
-
}
|
|
54
|
-
setInteractiveManager(manager) {
|
|
55
|
-
this.#interactiveManager = manager;
|
|
56
|
-
}
|
|
57
|
-
setIsInteractive(interactive) {
|
|
58
|
-
this.#interactive = interactive;
|
|
59
|
-
}
|
|
60
|
-
log(meta) {
|
|
61
|
-
this._log(this._formatMessage(meta), meta.type.level);
|
|
62
|
-
}
|
|
63
|
-
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
64
|
-
_formatMessage(data) {
|
|
65
|
-
const { columns } = terminalSize();
|
|
66
|
-
let size = columns;
|
|
67
|
-
if (typeof this._styles.messageLength === "number") {
|
|
68
|
-
size = this._styles.messageLength;
|
|
69
|
-
}
|
|
70
|
-
const { badge, context, date, error, file, groups, label, message, prefix, repeated, scope, suffix, traceError, type } = data;
|
|
71
|
-
const { color } = this._loggerTypes[type.name];
|
|
72
|
-
const colorized = color ? colorize[color] : white;
|
|
73
|
-
const groupSpaces = groups.map(() => " ").join("");
|
|
74
|
-
const items = [];
|
|
75
|
-
if (groups.length > 0) {
|
|
76
|
-
items.push(groupSpaces + grey("[" + groups.at(-1) + "]") + " ");
|
|
77
|
-
}
|
|
78
|
-
if (date) {
|
|
79
|
-
items.push(grey(this._styles.dateFormatter(typeof date === "string" ? new Date(date) : date)) + " ");
|
|
80
|
-
}
|
|
81
|
-
if (badge) {
|
|
82
|
-
items.push(colorized(badge));
|
|
83
|
-
} else {
|
|
84
|
-
const longestBadge = getLongestBadge(this._loggerTypes);
|
|
85
|
-
if (longestBadge.length > 0) {
|
|
86
|
-
items.push(grey(".".repeat(longestBadge.length)) + " ");
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
const longestLabel = getLongestLabel(this._loggerTypes);
|
|
90
|
-
if (label) {
|
|
91
|
-
items.push(colorized(formatLabel(label, this._styles)) + " ", grey(".".repeat(longestLabel.length - stringLength(label))));
|
|
92
|
-
} else {
|
|
93
|
-
items.push(grey(".".repeat(longestLabel.length + 2)));
|
|
94
|
-
}
|
|
95
|
-
if (repeated) {
|
|
96
|
-
items.push(bgGrey.white("[" + repeated + "x]") + " ");
|
|
97
|
-
}
|
|
98
|
-
if (Array.isArray(scope) && scope.length > 0) {
|
|
99
|
-
items.push(" " + grey("[" + scope.join(" > ") + "]") + " ");
|
|
100
|
-
}
|
|
101
|
-
if (prefix) {
|
|
102
|
-
items.push(
|
|
103
|
-
grey(
|
|
104
|
-
(Array.isArray(scope) && scope.length > 0 ? ". " : " ") + "[" + (this._styles.underline.prefix ? underline(prefix) : prefix) + "]"
|
|
105
|
-
) + " "
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
const titleSize = stringLength(items.join(" "));
|
|
109
|
-
if (file) {
|
|
110
|
-
const fileMessage = file.name + (file.line ? ":" + file.line : "");
|
|
111
|
-
const fileMessageSize = stringLength(fileMessage);
|
|
112
|
-
if (fileMessageSize + titleSize + 2 > size) {
|
|
113
|
-
items.push(grey(" " + fileMessage));
|
|
114
|
-
} else {
|
|
115
|
-
items.push(grey(".".repeat(size - titleSize - fileMessageSize - 2) + " " + fileMessage));
|
|
116
|
-
}
|
|
117
|
-
} else {
|
|
118
|
-
items.push(grey(".".repeat(size - titleSize - 1)));
|
|
119
|
-
}
|
|
120
|
-
if (items.length > 0) {
|
|
121
|
-
items.push("\n\n");
|
|
122
|
-
}
|
|
123
|
-
if (message !== EMPTY_SYMBOL) {
|
|
124
|
-
const formattedMessage = typeof message === "string" ? message : inspect(message, this.#inspectOptions);
|
|
125
|
-
items.push(
|
|
126
|
-
groupSpaces + wrapAnsi(formattedMessage, size - 3, {
|
|
127
|
-
hard: true,
|
|
128
|
-
trim: false,
|
|
129
|
-
wordWrap: true
|
|
130
|
-
})
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
if (context) {
|
|
134
|
-
let hasError = false;
|
|
135
|
-
items.push(
|
|
136
|
-
...context.map((value) => {
|
|
137
|
-
if (value instanceof Error) {
|
|
138
|
-
hasError = true;
|
|
139
|
-
return "\n\n" + renderError(value, {
|
|
140
|
-
...this.#errorOptions,
|
|
141
|
-
filterStacktrace: pailFileFilter,
|
|
142
|
-
prefix: groupSpaces
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
if (typeof value === "object") {
|
|
146
|
-
return " " + inspect(value, this.#inspectOptions);
|
|
147
|
-
}
|
|
148
|
-
const newValue = (hasError ? "\n\n" : " ") + value;
|
|
149
|
-
hasError = false;
|
|
150
|
-
return newValue;
|
|
151
|
-
})
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
if (error) {
|
|
155
|
-
items.push(
|
|
156
|
-
renderError(error, {
|
|
157
|
-
...this.#errorOptions,
|
|
158
|
-
filterStacktrace: pailFileFilter,
|
|
159
|
-
prefix: groupSpaces
|
|
160
|
-
})
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
if (traceError) {
|
|
164
|
-
items.push(
|
|
165
|
-
"\n\n" + renderError(traceError, {
|
|
166
|
-
...this.#errorOptions,
|
|
167
|
-
filterStacktrace: pailFileFilter,
|
|
168
|
-
hideErrorCauseCodeView: true,
|
|
169
|
-
hideErrorCodeView: true,
|
|
170
|
-
hideErrorErrorsCodeView: true,
|
|
171
|
-
hideMessage: true,
|
|
172
|
-
prefix: groupSpaces
|
|
173
|
-
})
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
if (suffix) {
|
|
177
|
-
items.push("\n", groupSpaces + grey(this._styles.underline.suffix ? underline(suffix) : suffix));
|
|
178
|
-
}
|
|
179
|
-
return items.join("") + "\n";
|
|
180
|
-
}
|
|
181
|
-
_log(message, logLevel) {
|
|
182
|
-
const streamType = ["error", "trace", "warn"].includes(logLevel) ? "stderr" : "stdout";
|
|
183
|
-
const stream = streamType === "stderr" ? this.#stderr : this.#stdout;
|
|
184
|
-
if (this.#interactive && this.#interactiveManager !== void 0 && stream.isTTY) {
|
|
185
|
-
this.#interactiveManager.update(streamType, message.split("\n"), 0);
|
|
186
|
-
} else {
|
|
187
|
-
writeStream(message + "\n", stream);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export { PrettyReporter };
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const colorize = require('@visulima/colorize/browser');
|
|
4
|
-
const fmt = require('@visulima/fmt');
|
|
5
|
-
const constants = require('./constants-DHfYGxxG.cjs');
|
|
6
|
-
const abstractPrettyReporter = require('./abstract-pretty-reporter-BR_6_JVa.cjs');
|
|
7
|
-
const getLongestLabel = require('./get-longest-label-CQ7lRhgD.cjs');
|
|
8
|
-
const writeConsoleLog = require('./write-console-log-Cu0-IDN-.cjs');
|
|
9
|
-
|
|
10
|
-
const _interopDefaultCompat = e => e && typeof e === 'object' && 'default' in e ? e.default : e;
|
|
11
|
-
|
|
12
|
-
const colorize__default = /*#__PURE__*/_interopDefaultCompat(colorize);
|
|
13
|
-
|
|
14
|
-
var __defProp = Object.defineProperty;
|
|
15
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
16
|
-
class PrettyReporter extends abstractPrettyReporter.AbstractPrettyReporter {
|
|
17
|
-
static {
|
|
18
|
-
__name(this, "PrettyReporter");
|
|
19
|
-
}
|
|
20
|
-
constructor(options = {}) {
|
|
21
|
-
super({
|
|
22
|
-
uppercase: {
|
|
23
|
-
label: true,
|
|
24
|
-
...options.uppercase
|
|
25
|
-
},
|
|
26
|
-
...options
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
30
|
-
log(meta) {
|
|
31
|
-
const isNotBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
32
|
-
const consoleLogFunction = writeConsoleLog.writeConsoleLogBasedOnLevel(meta.type.level);
|
|
33
|
-
const { badge, context, date, error, groups, label, message, prefix, repeated, scope, suffix, type } = meta;
|
|
34
|
-
const { color } = this._loggerTypes[type.name];
|
|
35
|
-
const colorized = color ? colorize__default[color] : colorize.white;
|
|
36
|
-
const items = [];
|
|
37
|
-
if (isNotBrowser && groups.length > 0) {
|
|
38
|
-
const groupSpaces = groups.map(() => " ").join("");
|
|
39
|
-
const cGroup = colorize.grey("[" + groups.at(-1) + "]");
|
|
40
|
-
items.push(fmt.format(groupSpaces + cGroup[0], cGroup.slice(1)));
|
|
41
|
-
}
|
|
42
|
-
if (date) {
|
|
43
|
-
const cDate = colorize.grey(this._styles.dateFormatter(typeof date === "string" ? new Date(date) : date));
|
|
44
|
-
if (isNotBrowser) {
|
|
45
|
-
items.push(fmt.format(cDate[0], cDate.slice(1)));
|
|
46
|
-
} else {
|
|
47
|
-
items.push([cDate[0] + " ", ...cDate.slice(1)]);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
if (badge) {
|
|
51
|
-
const cBadge = colorized(badge);
|
|
52
|
-
if (isNotBrowser) {
|
|
53
|
-
items.push(fmt.format(cBadge[0], cBadge.slice(1)));
|
|
54
|
-
} else {
|
|
55
|
-
items.push([cBadge[0] + " ", ...cBadge.slice(1)]);
|
|
56
|
-
}
|
|
57
|
-
} else {
|
|
58
|
-
const longestBadge = abstractPrettyReporter.getLongestBadge(this._loggerTypes);
|
|
59
|
-
if (longestBadge.length > 0) {
|
|
60
|
-
const cBadgePlaceholder = colorize.grey(".".repeat(longestBadge.length));
|
|
61
|
-
if (isNotBrowser) {
|
|
62
|
-
items.push(fmt.format(cBadgePlaceholder[0] + " ", cBadgePlaceholder.slice(1)));
|
|
63
|
-
} else {
|
|
64
|
-
items.push([cBadgePlaceholder[0] + " ", ...cBadgePlaceholder.slice(1)]);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
const longestLabel = getLongestLabel.getLongestLabel(this._loggerTypes);
|
|
69
|
-
let repeatedMessage;
|
|
70
|
-
if (repeated) {
|
|
71
|
-
const cRepeated = colorize.white("[" + repeated + "x]");
|
|
72
|
-
repeatedMessage = isNotBrowser ? fmt.format(cRepeated[0], cRepeated.slice(1)) : [cRepeated[0], ...cRepeated.slice(1)];
|
|
73
|
-
}
|
|
74
|
-
if (label) {
|
|
75
|
-
const cLabel = colorized(this._formatLabel(label));
|
|
76
|
-
if (isNotBrowser) {
|
|
77
|
-
items.push(fmt.format(cLabel[0], cLabel.slice(1)));
|
|
78
|
-
} else {
|
|
79
|
-
items.push([cLabel[0], ...cLabel.slice(1)]);
|
|
80
|
-
}
|
|
81
|
-
if (repeatedMessage) {
|
|
82
|
-
items.push(repeatedMessage);
|
|
83
|
-
}
|
|
84
|
-
let lengthDiff = longestLabel.length - label.length;
|
|
85
|
-
if (repeated) {
|
|
86
|
-
lengthDiff -= String(repeated).length + 3;
|
|
87
|
-
} else {
|
|
88
|
-
lengthDiff += 1;
|
|
89
|
-
}
|
|
90
|
-
if (lengthDiff > 0) {
|
|
91
|
-
const cLabelSpacer = colorize.grey(".".repeat(lengthDiff));
|
|
92
|
-
if (isNotBrowser) {
|
|
93
|
-
items.push(fmt.format(cLabelSpacer[0], cLabelSpacer.slice(1)));
|
|
94
|
-
} else {
|
|
95
|
-
items.push([" " + cLabelSpacer[0], ...cLabelSpacer.slice(1)]);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
} else {
|
|
99
|
-
const cSpacer = colorize.grey(".".repeat(longestLabel.length + 1));
|
|
100
|
-
if (isNotBrowser) {
|
|
101
|
-
items.push(fmt.format(cSpacer[0], cSpacer.slice(1)));
|
|
102
|
-
} else {
|
|
103
|
-
items.push([cSpacer[0], ...cSpacer.slice(1)]);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
if (Array.isArray(scope) && scope.length > 0) {
|
|
107
|
-
const cScope = colorize.grey("[" + scope.join(" > ") + "]");
|
|
108
|
-
if (isNotBrowser) {
|
|
109
|
-
items.push(fmt.format(cScope[0], cScope.slice(1)));
|
|
110
|
-
} else {
|
|
111
|
-
items.push([cScope[0], ...cScope.slice(1)]);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
if (prefix) {
|
|
115
|
-
const cPrefix = colorize.grey(
|
|
116
|
-
(Array.isArray(scope) && scope.length > 0 ? ". " : " ") + "[" + (this._styles.underline.prefix ? colorize.underline(prefix) : prefix) + "] "
|
|
117
|
-
);
|
|
118
|
-
if (isNotBrowser) {
|
|
119
|
-
items.push(fmt.format(cPrefix[0], cPrefix.slice(1)));
|
|
120
|
-
} else {
|
|
121
|
-
items.push([cPrefix[0], ...cPrefix.slice(1)]);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
if (message !== constants.EMPTY_SYMBOL) {
|
|
125
|
-
items.push(message);
|
|
126
|
-
}
|
|
127
|
-
if (context) {
|
|
128
|
-
items.push(...context);
|
|
129
|
-
}
|
|
130
|
-
if (error) {
|
|
131
|
-
items.push(error, "\n\n");
|
|
132
|
-
}
|
|
133
|
-
if (suffix) {
|
|
134
|
-
const cSuffix = colorize.grey(this._styles.underline.suffix ? colorize.underline(suffix) : suffix);
|
|
135
|
-
if (isNotBrowser) {
|
|
136
|
-
items.push(fmt.format("\n" + cSuffix[0], cSuffix.slice(1)));
|
|
137
|
-
} else {
|
|
138
|
-
items.push(["\n" + cSuffix[0], ...cSuffix.slice(1)]);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
if (isNotBrowser) {
|
|
142
|
-
consoleLogFunction(...items);
|
|
143
|
-
} else {
|
|
144
|
-
let logMessage = "";
|
|
145
|
-
const css = [];
|
|
146
|
-
const arguments_ = [];
|
|
147
|
-
for (const value of items) {
|
|
148
|
-
if (Array.isArray(value) && value.length > 1 && value[0].includes("%c")) {
|
|
149
|
-
logMessage += value[0];
|
|
150
|
-
css.push(...value.slice(1));
|
|
151
|
-
} else {
|
|
152
|
-
arguments_.push(value);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
consoleLogFunction(logMessage + "%c", ...css, "", ...arguments_);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
_formatLabel(label) {
|
|
159
|
-
let formattedLabel = this._styles.uppercase.label ? label.toUpperCase() : label;
|
|
160
|
-
formattedLabel = this._styles.underline.label ? colorize.underline(formattedLabel) : formattedLabel;
|
|
161
|
-
if (this._styles.bold.label) {
|
|
162
|
-
formattedLabel = colorize.bold(formattedLabel);
|
|
163
|
-
}
|
|
164
|
-
return formattedLabel;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
module.exports = PrettyReporter;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
2
|
-
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
-
class RedactProcessor {
|
|
6
|
-
static {
|
|
7
|
-
__name(this, "RedactProcessor");
|
|
8
|
-
}
|
|
9
|
-
#redact;
|
|
10
|
-
constructor(rules, options) {
|
|
11
|
-
try {
|
|
12
|
-
const { redact, standardRules } = require("@visulima/redact");
|
|
13
|
-
this.#redact = (input) => redact(input, rules || standardRules, options);
|
|
14
|
-
} catch {
|
|
15
|
-
throw new Error("The '@visulima/redact' package is missing. Make sure to install the '@visulima/redact' package.");
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
process(meta) {
|
|
19
|
-
meta.message = this.#redact(meta.message);
|
|
20
|
-
meta.context = this.#redact(meta.context);
|
|
21
|
-
meta.error = this.#redact(meta.error);
|
|
22
|
-
return meta;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { RedactProcessor as default };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
-
class RedactProcessor {
|
|
6
|
-
static {
|
|
7
|
-
__name(this, "RedactProcessor");
|
|
8
|
-
}
|
|
9
|
-
#redact;
|
|
10
|
-
constructor(rules, options) {
|
|
11
|
-
try {
|
|
12
|
-
const { redact, standardRules } = require("@visulima/redact");
|
|
13
|
-
this.#redact = (input) => redact(input, rules || standardRules, options);
|
|
14
|
-
} catch {
|
|
15
|
-
throw new Error("The '@visulima/redact' package is missing. Make sure to install the '@visulima/redact' package.");
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
process(meta) {
|
|
19
|
-
meta.message = this.#redact(meta.message);
|
|
20
|
-
meta.context = this.#redact(meta.context);
|
|
21
|
-
meta.error = this.#redact(meta.error);
|
|
22
|
-
return meta;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
module.exports = RedactProcessor;
|