@visulima/pail 3.1.0 → 3.2.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/CHANGELOG.md +34 -0
- package/LICENSE.md +1 -408
- package/README.md +298 -0
- package/dist/index.browser.d.ts +3 -3
- package/dist/index.browser.js +12 -1
- package/dist/index.server.d.ts +8 -5
- package/dist/index.server.js +535 -2
- package/dist/interactive/index.js +2 -1
- package/dist/object-tree.js +89 -2
- package/dist/packem_shared/AbstractJsonReporter-intFdT_A.js +204 -0
- package/dist/packem_shared/InteractiveManager-CZ85hGNW.js +172 -0
- package/dist/packem_shared/InteractiveStreamHook-DiSubbJ1.js +21 -0
- package/dist/packem_shared/JsonReporter-BqWsVkHP.js +60 -0
- package/dist/packem_shared/JsonReporter-DcM2LBX9.js +28 -0
- package/dist/packem_shared/PrettyReporter-BFWaYP_J.js +222 -0
- package/dist/packem_shared/PrettyReporter-CuLLKr6-.js +169 -0
- package/dist/packem_shared/{abstract-json-reporter-CPsNkpz8.d.ts → abstract-json-reporter-DiyVyU0j.d.ts} +1 -1
- package/dist/packem_shared/{abstract-pretty-reporter-DB2G-qlI.d.ts → abstract-pretty-reporter-BbOWXMCs.d.ts} +1 -1
- package/dist/packem_shared/abstract-pretty-reporter-DMPDCslJ.js +50 -0
- package/dist/packem_shared/constants-DfDr4MHC.js +119 -0
- package/dist/packem_shared/format-label-Btft2KGP.js +1194 -0
- package/dist/packem_shared/get-longest-label-C9PWeyKq.js +9 -0
- package/dist/packem_shared/index-BomQ3E6J.js +650 -0
- package/dist/packem_shared/index-DqKWykfa.js +1146 -0
- package/dist/packem_shared/interactive-stream-hook-DG4BtN12.js +141 -0
- package/dist/packem_shared/{pail.browser-CmWcqnn9.d.ts → pail.browser-By9KjOH7.d.ts} +8 -3
- package/dist/packem_shared/pail.browser-CPDOE_d1.js +1427 -0
- package/dist/packem_shared/{types-DVzG8TWL.d.ts → types-D3ycu8-x.d.ts} +1 -1
- package/dist/packem_shared/write-console-log-based-on-level-DBmRYXpj.js +14 -0
- package/dist/packem_shared/write-stream-BG8fhcs3.js +6 -0
- package/dist/processor/caller/caller-processor.d.ts +1 -1
- package/dist/processor/caller/caller-processor.js +59 -1
- package/dist/processor/message-formatter-processor.d.ts +1 -1
- package/dist/processor/message-formatter-processor.js +67 -1
- package/dist/processor/opentelemetry-processor.d.ts +19 -0
- package/dist/processor/opentelemetry-processor.js +52 -0
- package/dist/processor/redact-processor.d.ts +1 -1
- package/dist/processor/redact-processor.js +30 -1
- package/dist/progress-bar.js +404 -1
- package/dist/reporter/file/json-file-reporter.d.ts +2 -2
- package/dist/reporter/file/json-file-reporter.js +136 -4
- package/dist/reporter/http/abstract-http-reporter.d.ts +102 -0
- package/dist/reporter/http/abstract-http-reporter.js +435 -0
- package/dist/reporter/http/http-reporter.d.ts +13 -0
- package/dist/reporter/http/http-reporter.edge-light.d.ts +168 -0
- package/dist/reporter/http/http-reporter.edge-light.js +651 -0
- package/dist/reporter/http/http-reporter.js +13 -0
- package/dist/reporter/json/index.browser.d.ts +2 -2
- package/dist/reporter/json/index.browser.js +2 -1
- package/dist/reporter/json/index.d.ts +2 -2
- package/dist/reporter/json/index.js +2 -1
- package/dist/reporter/pretty/index.browser.d.ts +2 -2
- package/dist/reporter/pretty/index.browser.js +1 -1
- package/dist/reporter/pretty/index.d.ts +2 -2
- package/dist/reporter/pretty/index.js +1 -1
- package/dist/reporter/simple/simple-reporter.server.d.ts +2 -2
- package/dist/reporter/simple/simple-reporter.server.js +186 -8
- package/dist/spinner.js +2150 -1
- package/package.json +53 -3
- package/dist/packem_shared/AbstractJsonReporter-UftN6CIL.js +0 -1
- package/dist/packem_shared/InteractiveManager-CgmJyW9x.js +0 -3
- package/dist/packem_shared/InteractiveStreamHook-NtJu71aN.js +0 -1
- package/dist/packem_shared/JsonReporter-DTBtHNaD.js +0 -2
- package/dist/packem_shared/JsonReporter-Dl4m0xZe.js +0 -1
- package/dist/packem_shared/PrettyReporter-Bns0ZWLy.js +0 -12
- package/dist/packem_shared/PrettyReporter-CGKSTI7X.js +0 -5
- package/dist/packem_shared/abstract-pretty-reporter-CUtSm20r.js +0 -1
- package/dist/packem_shared/constants-DKfCaSUR.js +0 -1
- package/dist/packem_shared/format-label-CpyyTBom.js +0 -26
- package/dist/packem_shared/get-longest-label-B0NrI-o2.js +0 -1
- package/dist/packem_shared/index-CysYvHXs.js +0 -8
- package/dist/packem_shared/index-D9hWq9ka.js +0 -1
- package/dist/packem_shared/interactive-stream-hook-CeVo4Kth.js +0 -2
- package/dist/packem_shared/pail.browser-BmHoDvEA.js +0 -19
- package/dist/packem_shared/write-console-log-based-on-level-BP95fgQZ.js +0 -1
- package/dist/packem_shared/write-stream-CD8XFv1L.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export { default as PrettyReporter } from '../../packem_shared/PrettyReporter-CuLLKr6-.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { O as Options$1, a as Options } from '../../packem_shared/index.d-BR1GjZri.js';
|
|
2
2
|
import { LiteralUnion } from 'type-fest';
|
|
3
3
|
import { InteractiveManager } from '../../interactive/index.js';
|
|
4
|
-
import { I as InteractiveStreamReporter,
|
|
5
|
-
import { P as PrettyStyleOptions, A as AbstractPrettyReporter } from '../../packem_shared/abstract-pretty-reporter-
|
|
4
|
+
import { I as InteractiveStreamReporter, e as ReadonlyMeta, E as ExtendedRfc5424LogLevels } from '../../packem_shared/types-D3ycu8-x.js';
|
|
5
|
+
import { P as PrettyStyleOptions, A as AbstractPrettyReporter } from '../../packem_shared/abstract-pretty-reporter-BbOWXMCs.js';
|
|
6
6
|
import '@visulima/colorize';
|
|
7
7
|
|
|
8
8
|
type PrettyReporterOptions = PrettyStyleOptions & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export { PrettyReporter } from '../../packem_shared/PrettyReporter-BFWaYP_J.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { O as Options$1, a as Options } from '../../packem_shared/index.d-BR1GjZri.js';
|
|
2
2
|
import { InteractiveManager } from '../../interactive/index.js';
|
|
3
|
-
import { I as InteractiveStreamReporter,
|
|
4
|
-
import { P as PrettyStyleOptions, A as AbstractPrettyReporter } from '../../packem_shared/abstract-pretty-reporter-
|
|
3
|
+
import { I as InteractiveStreamReporter, e as ReadonlyMeta } from '../../packem_shared/types-D3ycu8-x.js';
|
|
4
|
+
import { P as PrettyStyleOptions, A as AbstractPrettyReporter } from '../../packem_shared/abstract-pretty-reporter-BbOWXMCs.js';
|
|
5
5
|
import 'type-fest';
|
|
6
6
|
import '@visulima/colorize';
|
|
7
7
|
|
|
@@ -1,11 +1,189 @@
|
|
|
1
|
-
|
|
2
|
-
`),0):ie(`${n}
|
|
3
|
-
`,h)}formatMessage(e){const{columns:n}=U();let p=n;typeof this.styles.messageLength=="number"&&(p=this.styles.messageLength);const{badge:i,context:h,date:c,error:S,file:u,groups:m,label:g,message:f,prefix:y,repeated:v,scope:$,suffix:b,traceError:w,type:L}=e,{color:E}=this.loggerTypes[L.name],M=E?G[E]:J,l=m.map(()=>" ").join(""),t=[];if(m.length>0&&t.push(`${l+o(`[${m.at(-1)}]`)} `),c&&t.push(`${o(this.styles.dateFormatter(typeof c=="string"?new Date(c):c))} `),i)t.push(R(M(i)));else{const r=re(this.loggerTypes);r.length>0&&t.push(o(" ".repeat(r.length)))}const A=se(this.loggerTypes),C=d(A);if(g){const r=d(g),s=Math.max(0,C-r);t.push(`${R(M(Q(g,this.styles)))} `," ".repeat(s))}else t.push(" ".repeat(C+1));v&&t.push(`${K.white(`[${v}x]`)} `),Array.isArray($)&&$.length>0&&t.push(`${o(`[${$.join(" > ")}]`)} `),y&&t.push(`${o(`[${this.styles.underline.prefix?I(y):y}]`)} `);const O=d(t.join(""));if(f!==ee){const r=typeof f=="string"?f:k(f,this.#i);t.push(l+X(r,{trim:!1,width:p-3,wrapMode:Z.STRICT_WIDTH}))}if(h){let r=!1;t.push(...h.map(s=>{if(s instanceof Error)return r=!0,`
|
|
1
|
+
import { createRequire as __cjs_createRequire } from "node:module";
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
const {
|
|
8
|
+
stdout,
|
|
9
|
+
stderr
|
|
10
|
+
} = __cjs_getProcess;
|
|
11
|
+
import colorize, { red, greenBright, cyan, green, grey, bold, white, bgGrey, underline } from '@visulima/colorize';
|
|
12
|
+
import { d as defaultInspectorConfig, f as formatLabel, i as inspect, r as renderError } from '../../packem_shared/format-label-Btft2KGP.js';
|
|
13
|
+
import { t as terminalSize, g as getStringWidth, w as wordWrap, W as WrapMode } from '../../packem_shared/index-DqKWykfa.js';
|
|
14
|
+
import { E as EMPTY_SYMBOL } from '../../packem_shared/constants-DfDr4MHC.js';
|
|
15
|
+
import { A as AbstractPrettyReporter, g as getLongestBadge } from '../../packem_shared/abstract-pretty-reporter-DMPDCslJ.js';
|
|
16
|
+
import { g as getLongestLabel } from '../../packem_shared/get-longest-label-C9PWeyKq.js';
|
|
17
|
+
import { w as writeStream } from '../../packem_shared/write-stream-BG8fhcs3.js';
|
|
18
|
+
|
|
19
|
+
const pailFileFilter = (line) => !/[\\/]pail[\\/]dist/.test(line);
|
|
20
|
+
class SimpleReporter extends AbstractPrettyReporter {
|
|
21
|
+
#stdout;
|
|
22
|
+
#stderr;
|
|
23
|
+
#interactiveManager;
|
|
24
|
+
#interactive = false;
|
|
25
|
+
#inspectOptions;
|
|
26
|
+
#errorOptions;
|
|
27
|
+
constructor(options = {}) {
|
|
28
|
+
const { error: errorOptions, inspect: inspectOptions, ...rest } = options;
|
|
29
|
+
super({
|
|
30
|
+
uppercase: {
|
|
31
|
+
label: true,
|
|
32
|
+
...rest.uppercase
|
|
33
|
+
},
|
|
34
|
+
...rest
|
|
35
|
+
});
|
|
36
|
+
this.#inspectOptions = { ...defaultInspectorConfig, indent: void 0, ...inspectOptions };
|
|
37
|
+
this.#errorOptions = {
|
|
38
|
+
...errorOptions,
|
|
39
|
+
color: {
|
|
40
|
+
fileLine: green,
|
|
41
|
+
hint: cyan,
|
|
42
|
+
marker: red,
|
|
43
|
+
message: red,
|
|
44
|
+
method: greenBright,
|
|
45
|
+
title: red
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
this.#stdout = stdout;
|
|
49
|
+
this.#stderr = stderr;
|
|
50
|
+
}
|
|
51
|
+
setStdout(stdout_) {
|
|
52
|
+
this.#stdout = stdout_;
|
|
53
|
+
}
|
|
54
|
+
setStderr(stderr_) {
|
|
55
|
+
this.#stderr = stderr_;
|
|
56
|
+
}
|
|
57
|
+
setInteractiveManager(manager) {
|
|
58
|
+
this.#interactiveManager = manager;
|
|
59
|
+
}
|
|
60
|
+
setIsInteractive(interactive) {
|
|
61
|
+
this.#interactive = interactive;
|
|
62
|
+
}
|
|
63
|
+
log(meta) {
|
|
64
|
+
const message = this.formatMessage(meta);
|
|
65
|
+
const logLevel = meta.type.level;
|
|
66
|
+
const streamType = ["error", "trace", "warn"].includes(logLevel) ? "stderr" : "stdout";
|
|
67
|
+
const stream = streamType === "stderr" ? this.#stderr : this.#stdout;
|
|
68
|
+
if (this.#interactive && this.#interactiveManager !== void 0 && stream.isTTY) {
|
|
69
|
+
this.#interactiveManager.update(streamType, message.split("\n"), 0);
|
|
70
|
+
} else {
|
|
71
|
+
writeStream(`${message}
|
|
72
|
+
`, stream);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
76
|
+
formatMessage(data) {
|
|
77
|
+
const { columns } = terminalSize();
|
|
78
|
+
let size = columns;
|
|
79
|
+
if (typeof this.styles.messageLength === "number") {
|
|
80
|
+
size = this.styles.messageLength;
|
|
81
|
+
}
|
|
82
|
+
const { badge, context, date, error, file, groups, label, message, prefix, repeated, scope, suffix, traceError, type } = data;
|
|
83
|
+
const { color } = this.loggerTypes[type.name];
|
|
84
|
+
const colorized = color ? colorize[color] : white;
|
|
85
|
+
const groupSpaces = groups.map(() => " ").join("");
|
|
86
|
+
const items = [];
|
|
87
|
+
if (groups.length > 0) {
|
|
88
|
+
items.push(`${groupSpaces + grey(`[${groups.at(-1)}]`)} `);
|
|
89
|
+
}
|
|
90
|
+
if (date) {
|
|
91
|
+
items.push(`${grey(this.styles.dateFormatter(typeof date === "string" ? new Date(date) : date))} `);
|
|
92
|
+
}
|
|
93
|
+
if (badge) {
|
|
94
|
+
items.push(bold(colorized(badge)));
|
|
95
|
+
} else {
|
|
96
|
+
const longestBadge = getLongestBadge(this.loggerTypes);
|
|
97
|
+
if (longestBadge.length > 0) {
|
|
98
|
+
items.push(grey(" ".repeat(longestBadge.length)));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const longestLabel = getLongestLabel(this.loggerTypes);
|
|
102
|
+
const longestWidth = getStringWidth(longestLabel);
|
|
103
|
+
if (label) {
|
|
104
|
+
const labelWidth = getStringWidth(label);
|
|
105
|
+
const pad = Math.max(0, longestWidth - labelWidth);
|
|
106
|
+
items.push(`${bold(colorized(formatLabel(label, this.styles)))} `, " ".repeat(pad));
|
|
107
|
+
} else {
|
|
108
|
+
items.push(" ".repeat(longestWidth + 1));
|
|
109
|
+
}
|
|
110
|
+
if (repeated) {
|
|
111
|
+
items.push(`${bgGrey.white(`[${repeated}x]`)} `);
|
|
112
|
+
}
|
|
113
|
+
if (Array.isArray(scope) && scope.length > 0) {
|
|
114
|
+
items.push(`${grey(`[${scope.join(" > ")}]`)} `);
|
|
115
|
+
}
|
|
116
|
+
if (prefix) {
|
|
117
|
+
items.push(`${grey(`[${this.styles.underline.prefix ? underline(prefix) : prefix}]`)} `);
|
|
118
|
+
}
|
|
119
|
+
const titleSize = getStringWidth(items.join(""));
|
|
120
|
+
if (message !== EMPTY_SYMBOL) {
|
|
121
|
+
const formattedMessage = typeof message === "string" ? message : inspect(message, this.#inspectOptions);
|
|
122
|
+
items.push(
|
|
123
|
+
groupSpaces + wordWrap(formattedMessage, {
|
|
124
|
+
trim: false,
|
|
125
|
+
width: size - 3,
|
|
126
|
+
wrapMode: WrapMode.STRICT_WIDTH
|
|
127
|
+
})
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
if (context) {
|
|
131
|
+
let hasError = false;
|
|
132
|
+
items.push(
|
|
133
|
+
...context.map((value) => {
|
|
134
|
+
if (value instanceof Error) {
|
|
135
|
+
hasError = true;
|
|
136
|
+
return `
|
|
137
|
+
|
|
138
|
+
${renderError(value, {
|
|
139
|
+
...this.#errorOptions,
|
|
140
|
+
filterStacktrace: pailFileFilter,
|
|
141
|
+
prefix: groupSpaces
|
|
142
|
+
})}`;
|
|
143
|
+
}
|
|
144
|
+
if (typeof value === "object") {
|
|
145
|
+
return ` ${inspect(value, this.#inspectOptions)}`;
|
|
146
|
+
}
|
|
147
|
+
const newValue = (hasError ? "\n\n" : " ") + value;
|
|
148
|
+
hasError = false;
|
|
149
|
+
return newValue;
|
|
150
|
+
})
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
if (error) {
|
|
154
|
+
items.push(
|
|
155
|
+
renderError(error, {
|
|
156
|
+
...this.#errorOptions,
|
|
157
|
+
filterStacktrace: pailFileFilter,
|
|
158
|
+
prefix: groupSpaces
|
|
159
|
+
})
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
if (traceError) {
|
|
163
|
+
items.push(
|
|
164
|
+
`
|
|
165
|
+
|
|
166
|
+
${renderError(traceError, {
|
|
167
|
+
...this.#errorOptions,
|
|
168
|
+
filterStacktrace: pailFileFilter,
|
|
169
|
+
hideErrorCauseCodeView: true,
|
|
170
|
+
hideErrorCodeView: true,
|
|
171
|
+
hideErrorErrorsCodeView: true,
|
|
172
|
+
hideMessage: true,
|
|
173
|
+
prefix: groupSpaces
|
|
174
|
+
})}`
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
if (suffix) {
|
|
178
|
+
items.push(` ${groupSpaces}${grey(this.styles.underline.suffix ? underline(suffix) : suffix)}`);
|
|
179
|
+
}
|
|
180
|
+
if (file) {
|
|
181
|
+
const fileMessage = file.name + (file.line ? `:${file.line}` : "");
|
|
182
|
+
const callerPad = Math.max(0, titleSize - getStringWidth("Caller: "));
|
|
183
|
+
items.push("\n", grey("Caller: "), " ".repeat(callerPad), fileMessage, "\n");
|
|
184
|
+
}
|
|
185
|
+
return items.join("");
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export { SimpleReporter };
|