@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,135 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4
|
-
|
|
5
|
-
const abstractJsonReporter = require('./abstract-json-reporter-okwLqT9k.cjs');
|
|
6
|
-
|
|
7
|
-
var __defProp$2 = Object.defineProperty;
|
|
8
|
-
var __name$2 = (target, value) => __defProp$2(target, "name", { value, configurable: true });
|
|
9
|
-
class SafeStreamHandler {
|
|
10
|
-
static {
|
|
11
|
-
__name$2(this, "SafeStreamHandler");
|
|
12
|
-
}
|
|
13
|
-
#ready = true;
|
|
14
|
-
#stream;
|
|
15
|
-
#name;
|
|
16
|
-
constructor(stream, name) {
|
|
17
|
-
this.#stream = stream;
|
|
18
|
-
this.#name = name;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Writes `message` to the instance's internal stream
|
|
22
|
-
* @param message Message to write
|
|
23
|
-
*/
|
|
24
|
-
write(message) {
|
|
25
|
-
this.writeStream(message);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Calls `end` on this instance's internal stream
|
|
29
|
-
*/
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
-
end(...arguments_) {
|
|
32
|
-
this.#stream.end(...arguments_);
|
|
33
|
-
}
|
|
34
|
-
get isReady() {
|
|
35
|
-
return this.#ready;
|
|
36
|
-
}
|
|
37
|
-
writeStream(message) {
|
|
38
|
-
if (!this.#ready) {
|
|
39
|
-
console.warn("Stream busy: " + this.#name + '. Write will be dropped: "' + message + '"');
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
this.#ready = false;
|
|
43
|
-
this.#stream.on("error", (error) => {
|
|
44
|
-
throw error;
|
|
45
|
-
});
|
|
46
|
-
this.#stream.on("drain", () => {
|
|
47
|
-
this.#ready = true;
|
|
48
|
-
});
|
|
49
|
-
this.#stream.on("finish", () => {
|
|
50
|
-
this.#ready = true;
|
|
51
|
-
});
|
|
52
|
-
this.#ready = this.#stream.write(message, () => {
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
var __defProp$1 = Object.defineProperty;
|
|
58
|
-
var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
|
|
59
|
-
class RotatingFileStream {
|
|
60
|
-
static {
|
|
61
|
-
__name$1(this, "RotatingFileStream");
|
|
62
|
-
}
|
|
63
|
-
#filePath;
|
|
64
|
-
#immediate;
|
|
65
|
-
#stream;
|
|
66
|
-
#options;
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
68
|
-
#createRfsStream;
|
|
69
|
-
constructor(filePath, writeImmediately = false, options = {}) {
|
|
70
|
-
this.#filePath = filePath;
|
|
71
|
-
this.#immediate = writeImmediately;
|
|
72
|
-
this.#options = options;
|
|
73
|
-
if (!this.#immediate) {
|
|
74
|
-
try {
|
|
75
|
-
this.#createRfsStream = require("rotating-file-stream").createStream;
|
|
76
|
-
} catch {
|
|
77
|
-
throw new Error("The 'rotating-file-stream' package is missing. Make sure to install the 'rotating-file-stream' package.");
|
|
78
|
-
}
|
|
79
|
-
this.#stream = this.#createRfsStream(this.#filePath, options);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Writes `message` to the instance's internal #stream
|
|
84
|
-
* @param message Message to write
|
|
85
|
-
*/
|
|
86
|
-
write(message) {
|
|
87
|
-
let fileStream = this.#stream;
|
|
88
|
-
if (this.#immediate) {
|
|
89
|
-
fileStream = this.#createRfsStream(this.#filePath, this.#options);
|
|
90
|
-
}
|
|
91
|
-
const stream = new SafeStreamHandler(fileStream, this.#filePath);
|
|
92
|
-
stream.write(message);
|
|
93
|
-
if (this.#immediate) {
|
|
94
|
-
stream.end();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Ends the instance's internal #stream
|
|
99
|
-
*
|
|
100
|
-
* When `immediate` is not `true`, a call to `write` after calling this method
|
|
101
|
-
* will throw an error.
|
|
102
|
-
*/
|
|
103
|
-
end() {
|
|
104
|
-
if (this.#stream !== void 0) {
|
|
105
|
-
this.#stream.end();
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
var __defProp = Object.defineProperty;
|
|
111
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
112
|
-
class JsonFileReporter extends abstractJsonReporter.AbstractJsonReporter {
|
|
113
|
-
static {
|
|
114
|
-
__name(this, "JsonFileReporter");
|
|
115
|
-
}
|
|
116
|
-
stream;
|
|
117
|
-
constructor(options) {
|
|
118
|
-
super();
|
|
119
|
-
const { filePath, writeImmediately = false, ...rfsOptions } = options;
|
|
120
|
-
this.stream = new RotatingFileStream(filePath, writeImmediately, {
|
|
121
|
-
compress: "gzip",
|
|
122
|
-
// compress rotated files
|
|
123
|
-
interval: "1d",
|
|
124
|
-
// rotate daily
|
|
125
|
-
size: "10M",
|
|
126
|
-
// rotate every 10 MegaBytes written,
|
|
127
|
-
...rfsOptions
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
_log(message) {
|
|
131
|
-
this.stream.write(message + "\n");
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
exports.JsonFileReporter = JsonFileReporter;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { w as writeConsoleLogBasedOnLevel } from './write-console-log-Tptfzg9D.mjs';
|
|
2
|
-
import { A as AbstractJsonReporter } from './abstract-json-reporter-sxnmNIlg.mjs';
|
|
3
|
-
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
-
class JsonReporter extends AbstractJsonReporter {
|
|
7
|
-
static {
|
|
8
|
-
__name(this, "JsonReporter");
|
|
9
|
-
}
|
|
10
|
-
constructor(options = {}) {
|
|
11
|
-
super(options);
|
|
12
|
-
}
|
|
13
|
-
// eslint-disable-next-line class-methods-use-this
|
|
14
|
-
_log(message, logLevel) {
|
|
15
|
-
const consoleLogFunction = writeConsoleLogBasedOnLevel(logLevel);
|
|
16
|
-
consoleLogFunction(message);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export { JsonReporter as default };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const process = require('node:process');
|
|
4
|
-
const writeStream = require('./write-stream-CkNf2Ju8.cjs');
|
|
5
|
-
const abstractJsonReporter = require('./abstract-json-reporter-okwLqT9k.cjs');
|
|
6
|
-
|
|
7
|
-
var __defProp = Object.defineProperty;
|
|
8
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
-
class JsonReporter extends abstractJsonReporter.AbstractJsonReporter {
|
|
10
|
-
static {
|
|
11
|
-
__name(this, "JsonReporter");
|
|
12
|
-
}
|
|
13
|
-
#stdout;
|
|
14
|
-
#stderr;
|
|
15
|
-
constructor(options = {}) {
|
|
16
|
-
super(options);
|
|
17
|
-
this.#stdout = process.stdout;
|
|
18
|
-
this.#stderr = process.stderr;
|
|
19
|
-
}
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
21
|
-
setStdout(stdout_) {
|
|
22
|
-
this.#stdout = stdout_;
|
|
23
|
-
}
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
25
|
-
setStderr(stderr_) {
|
|
26
|
-
this.#stderr = stderr_;
|
|
27
|
-
}
|
|
28
|
-
_log(message, logLevel) {
|
|
29
|
-
const stream = ["error", "warn"].includes(logLevel) ? this.#stderr : this.#stdout;
|
|
30
|
-
writeStream.writeStream(message + "\n", stream);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
module.exports = JsonReporter;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const writeConsoleLog = require('./write-console-log-Cu0-IDN-.cjs');
|
|
4
|
-
const abstractJsonReporter = require('./abstract-json-reporter-okwLqT9k.cjs');
|
|
5
|
-
|
|
6
|
-
var __defProp = Object.defineProperty;
|
|
7
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
-
class JsonReporter extends abstractJsonReporter.AbstractJsonReporter {
|
|
9
|
-
static {
|
|
10
|
-
__name(this, "JsonReporter");
|
|
11
|
-
}
|
|
12
|
-
constructor(options = {}) {
|
|
13
|
-
super(options);
|
|
14
|
-
}
|
|
15
|
-
// eslint-disable-next-line class-methods-use-this
|
|
16
|
-
_log(message, logLevel) {
|
|
17
|
-
const consoleLogFunction = writeConsoleLog.writeConsoleLogBasedOnLevel(logLevel);
|
|
18
|
-
consoleLogFunction(message);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
module.exports = JsonReporter;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { stdout, stderr } from 'node:process';
|
|
2
|
-
import { w as writeStream } from './write-stream-BBAF33Zm.mjs';
|
|
3
|
-
import { A as AbstractJsonReporter } from './abstract-json-reporter-sxnmNIlg.mjs';
|
|
4
|
-
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
-
class JsonReporter extends AbstractJsonReporter {
|
|
8
|
-
static {
|
|
9
|
-
__name(this, "JsonReporter");
|
|
10
|
-
}
|
|
11
|
-
#stdout;
|
|
12
|
-
#stderr;
|
|
13
|
-
constructor(options = {}) {
|
|
14
|
-
super(options);
|
|
15
|
-
this.#stdout = stdout;
|
|
16
|
-
this.#stderr = stderr;
|
|
17
|
-
}
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
19
|
-
setStdout(stdout_) {
|
|
20
|
-
this.#stdout = stdout_;
|
|
21
|
-
}
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
23
|
-
setStderr(stderr_) {
|
|
24
|
-
this.#stderr = stderr_;
|
|
25
|
-
}
|
|
26
|
-
_log(message, logLevel) {
|
|
27
|
-
const stream = ["error", "warn"].includes(logLevel) ? this.#stderr : this.#stdout;
|
|
28
|
-
writeStream(message + "\n", stream);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { JsonReporter as default };
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { build } from '@visulima/fmt';
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
-
class MessageFormatterProcessor {
|
|
6
|
-
static {
|
|
7
|
-
__name(this, "MessageFormatterProcessor");
|
|
8
|
-
}
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
10
|
-
#stringify;
|
|
11
|
-
#formatters;
|
|
12
|
-
constructor(options = {}) {
|
|
13
|
-
this.#formatters = options.formatters;
|
|
14
|
-
}
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
16
|
-
setStringify(function_) {
|
|
17
|
-
this.#stringify = function_;
|
|
18
|
-
}
|
|
19
|
-
process(meta) {
|
|
20
|
-
const formatter = build({
|
|
21
|
-
formatters: this.#formatters,
|
|
22
|
-
stringify: /* @__PURE__ */ __name((value) => {
|
|
23
|
-
const stringified = this.#stringify(value);
|
|
24
|
-
if (stringified === void 0) {
|
|
25
|
-
console.warn("Unable to stringify value of type " + typeof value, value);
|
|
26
|
-
return "undefined";
|
|
27
|
-
}
|
|
28
|
-
return stringified;
|
|
29
|
-
}, "stringify")
|
|
30
|
-
});
|
|
31
|
-
if (meta.message !== void 0) {
|
|
32
|
-
meta.message = this._format(formatter, meta.message, meta.context ?? []);
|
|
33
|
-
}
|
|
34
|
-
return meta;
|
|
35
|
-
}
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
-
_format(formatter, data, arguments_ = []) {
|
|
38
|
-
if (typeof data === "string") {
|
|
39
|
-
return formatter(data, arguments_);
|
|
40
|
-
}
|
|
41
|
-
if (typeof data === "object" && data !== null) {
|
|
42
|
-
for (const index in data) {
|
|
43
|
-
const value = data[index];
|
|
44
|
-
if (typeof value === "string" || Array.isArray(value) || typeof value === "object") {
|
|
45
|
-
data[index] = this._format(formatter, value, arguments_);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return data;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export { MessageFormatterProcessor as default };
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const fmt = require('@visulima/fmt');
|
|
4
|
-
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
-
class MessageFormatterProcessor {
|
|
8
|
-
static {
|
|
9
|
-
__name(this, "MessageFormatterProcessor");
|
|
10
|
-
}
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
12
|
-
#stringify;
|
|
13
|
-
#formatters;
|
|
14
|
-
constructor(options = {}) {
|
|
15
|
-
this.#formatters = options.formatters;
|
|
16
|
-
}
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
18
|
-
setStringify(function_) {
|
|
19
|
-
this.#stringify = function_;
|
|
20
|
-
}
|
|
21
|
-
process(meta) {
|
|
22
|
-
const formatter = fmt.build({
|
|
23
|
-
formatters: this.#formatters,
|
|
24
|
-
stringify: /* @__PURE__ */ __name((value) => {
|
|
25
|
-
const stringified = this.#stringify(value);
|
|
26
|
-
if (stringified === void 0) {
|
|
27
|
-
console.warn("Unable to stringify value of type " + typeof value, value);
|
|
28
|
-
return "undefined";
|
|
29
|
-
}
|
|
30
|
-
return stringified;
|
|
31
|
-
}, "stringify")
|
|
32
|
-
});
|
|
33
|
-
if (meta.message !== void 0) {
|
|
34
|
-
meta.message = this._format(formatter, meta.message, meta.context ?? []);
|
|
35
|
-
}
|
|
36
|
-
return meta;
|
|
37
|
-
}
|
|
38
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
-
_format(formatter, data, arguments_ = []) {
|
|
40
|
-
if (typeof data === "string") {
|
|
41
|
-
return formatter(data, arguments_);
|
|
42
|
-
}
|
|
43
|
-
if (typeof data === "object" && data !== null) {
|
|
44
|
-
for (const index in data) {
|
|
45
|
-
const value = data[index];
|
|
46
|
-
if (typeof value === "string" || Array.isArray(value) || typeof value === "object") {
|
|
47
|
-
data[index] = this._format(formatter, value, arguments_);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return data;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
module.exports = MessageFormatterProcessor;
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4
|
-
|
|
5
|
-
const process = require('node:process');
|
|
6
|
-
const colorize = require('@visulima/colorize');
|
|
7
|
-
const error = require('@visulima/error/error');
|
|
8
|
-
const inspector = require('@visulima/inspector');
|
|
9
|
-
const formatLabel = require('./format-label-DYEhjrTZ.cjs');
|
|
10
|
-
const constants = require('./constants-DHfYGxxG.cjs');
|
|
11
|
-
const abstractPrettyReporter = require('./abstract-pretty-reporter-BR_6_JVa.cjs');
|
|
12
|
-
const getLongestLabel = require('./get-longest-label-CQ7lRhgD.cjs');
|
|
13
|
-
const writeStream = require('./write-stream-CkNf2Ju8.cjs');
|
|
14
|
-
|
|
15
|
-
const _interopDefaultCompat = e => e && typeof e === 'object' && 'default' in e ? e.default : e;
|
|
16
|
-
|
|
17
|
-
const colorize__default = /*#__PURE__*/_interopDefaultCompat(colorize);
|
|
18
|
-
|
|
19
|
-
var __defProp = Object.defineProperty;
|
|
20
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
21
|
-
const pailFileFilter = /* @__PURE__ */ __name((line) => !/[\\/]pail[\\/]dist/.test(line), "pailFileFilter");
|
|
22
|
-
class PrettyReporter extends abstractPrettyReporter.AbstractPrettyReporter {
|
|
23
|
-
static {
|
|
24
|
-
__name(this, "PrettyReporter");
|
|
25
|
-
}
|
|
26
|
-
#stdout;
|
|
27
|
-
#stderr;
|
|
28
|
-
#interactiveManager;
|
|
29
|
-
#interactive = false;
|
|
30
|
-
#inspectOptions;
|
|
31
|
-
#errorOptions;
|
|
32
|
-
constructor(options = {}) {
|
|
33
|
-
const { error: errorOptions, inspect: inspectOptions, ...rest } = options;
|
|
34
|
-
super({
|
|
35
|
-
uppercase: {
|
|
36
|
-
label: true,
|
|
37
|
-
...rest.uppercase
|
|
38
|
-
},
|
|
39
|
-
...rest
|
|
40
|
-
});
|
|
41
|
-
this.#inspectOptions = { ...formatLabel.defaultInspectorConfig, ...inspectOptions };
|
|
42
|
-
this.#errorOptions = {
|
|
43
|
-
...errorOptions,
|
|
44
|
-
color: {
|
|
45
|
-
fileLine: colorize.green,
|
|
46
|
-
hint: colorize.cyan,
|
|
47
|
-
marker: colorize.red,
|
|
48
|
-
message: colorize.red,
|
|
49
|
-
method: colorize.greenBright,
|
|
50
|
-
title: colorize.red
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
this.#stdout = process.stdout;
|
|
54
|
-
this.#stderr = process.stderr;
|
|
55
|
-
}
|
|
56
|
-
setStdout(stdout_) {
|
|
57
|
-
this.#stdout = stdout_;
|
|
58
|
-
}
|
|
59
|
-
setStderr(stderr_) {
|
|
60
|
-
this.#stderr = stderr_;
|
|
61
|
-
}
|
|
62
|
-
setInteractiveManager(manager) {
|
|
63
|
-
this.#interactiveManager = manager;
|
|
64
|
-
}
|
|
65
|
-
setIsInteractive(interactive) {
|
|
66
|
-
this.#interactive = interactive;
|
|
67
|
-
}
|
|
68
|
-
log(meta) {
|
|
69
|
-
this._log(this._formatMessage(meta), meta.type.level);
|
|
70
|
-
}
|
|
71
|
-
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
72
|
-
_formatMessage(data) {
|
|
73
|
-
const { columns } = formatLabel.terminalSize();
|
|
74
|
-
let size = columns;
|
|
75
|
-
if (typeof this._styles.messageLength === "number") {
|
|
76
|
-
size = this._styles.messageLength;
|
|
77
|
-
}
|
|
78
|
-
const { badge, context, date, error: error$1, file, groups, label, message, prefix, repeated, scope, suffix, traceError, type } = data;
|
|
79
|
-
const { color } = this._loggerTypes[type.name];
|
|
80
|
-
const colorized = color ? colorize__default[color] : colorize.white;
|
|
81
|
-
const groupSpaces = groups.map(() => " ").join("");
|
|
82
|
-
const items = [];
|
|
83
|
-
if (groups.length > 0) {
|
|
84
|
-
items.push(groupSpaces + colorize.grey("[" + groups.at(-1) + "]") + " ");
|
|
85
|
-
}
|
|
86
|
-
if (date) {
|
|
87
|
-
items.push(colorize.grey(this._styles.dateFormatter(typeof date === "string" ? new Date(date) : date)) + " ");
|
|
88
|
-
}
|
|
89
|
-
if (badge) {
|
|
90
|
-
items.push(colorized(badge));
|
|
91
|
-
} else {
|
|
92
|
-
const longestBadge = abstractPrettyReporter.getLongestBadge(this._loggerTypes);
|
|
93
|
-
if (longestBadge.length > 0) {
|
|
94
|
-
items.push(colorize.grey(".".repeat(longestBadge.length)) + " ");
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
const longestLabel = getLongestLabel.getLongestLabel(this._loggerTypes);
|
|
98
|
-
if (label) {
|
|
99
|
-
items.push(colorized(formatLabel.formatLabel(label, this._styles)) + " ", colorize.grey(".".repeat(longestLabel.length - formatLabel.stringLength(label))));
|
|
100
|
-
} else {
|
|
101
|
-
items.push(colorize.grey(".".repeat(longestLabel.length + 2)));
|
|
102
|
-
}
|
|
103
|
-
if (repeated) {
|
|
104
|
-
items.push(colorize.bgGrey.white("[" + repeated + "x]") + " ");
|
|
105
|
-
}
|
|
106
|
-
if (Array.isArray(scope) && scope.length > 0) {
|
|
107
|
-
items.push(" " + colorize.grey("[" + scope.join(" > ") + "]") + " ");
|
|
108
|
-
}
|
|
109
|
-
if (prefix) {
|
|
110
|
-
items.push(
|
|
111
|
-
colorize.grey(
|
|
112
|
-
(Array.isArray(scope) && scope.length > 0 ? ". " : " ") + "[" + (this._styles.underline.prefix ? colorize.underline(prefix) : prefix) + "]"
|
|
113
|
-
) + " "
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
const titleSize = formatLabel.stringLength(items.join(" "));
|
|
117
|
-
if (file) {
|
|
118
|
-
const fileMessage = file.name + (file.line ? ":" + file.line : "");
|
|
119
|
-
const fileMessageSize = formatLabel.stringLength(fileMessage);
|
|
120
|
-
if (fileMessageSize + titleSize + 2 > size) {
|
|
121
|
-
items.push(colorize.grey(" " + fileMessage));
|
|
122
|
-
} else {
|
|
123
|
-
items.push(colorize.grey(".".repeat(size - titleSize - fileMessageSize - 2) + " " + fileMessage));
|
|
124
|
-
}
|
|
125
|
-
} else {
|
|
126
|
-
items.push(colorize.grey(".".repeat(size - titleSize - 1)));
|
|
127
|
-
}
|
|
128
|
-
if (items.length > 0) {
|
|
129
|
-
items.push("\n\n");
|
|
130
|
-
}
|
|
131
|
-
if (message !== constants.EMPTY_SYMBOL) {
|
|
132
|
-
const formattedMessage = typeof message === "string" ? message : inspector.inspect(message, this.#inspectOptions);
|
|
133
|
-
items.push(
|
|
134
|
-
groupSpaces + formatLabel.wrapAnsi(formattedMessage, size - 3, {
|
|
135
|
-
hard: true,
|
|
136
|
-
trim: false,
|
|
137
|
-
wordWrap: true
|
|
138
|
-
})
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
if (context) {
|
|
142
|
-
let hasError = false;
|
|
143
|
-
items.push(
|
|
144
|
-
...context.map((value) => {
|
|
145
|
-
if (value instanceof Error) {
|
|
146
|
-
hasError = true;
|
|
147
|
-
return "\n\n" + error.renderError(value, {
|
|
148
|
-
...this.#errorOptions,
|
|
149
|
-
filterStacktrace: pailFileFilter,
|
|
150
|
-
prefix: groupSpaces
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
if (typeof value === "object") {
|
|
154
|
-
return " " + inspector.inspect(value, this.#inspectOptions);
|
|
155
|
-
}
|
|
156
|
-
const newValue = (hasError ? "\n\n" : " ") + value;
|
|
157
|
-
hasError = false;
|
|
158
|
-
return newValue;
|
|
159
|
-
})
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
if (error$1) {
|
|
163
|
-
items.push(
|
|
164
|
-
error.renderError(error$1, {
|
|
165
|
-
...this.#errorOptions,
|
|
166
|
-
filterStacktrace: pailFileFilter,
|
|
167
|
-
prefix: groupSpaces
|
|
168
|
-
})
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
if (traceError) {
|
|
172
|
-
items.push(
|
|
173
|
-
"\n\n" + error.renderError(traceError, {
|
|
174
|
-
...this.#errorOptions,
|
|
175
|
-
filterStacktrace: pailFileFilter,
|
|
176
|
-
hideErrorCauseCodeView: true,
|
|
177
|
-
hideErrorCodeView: true,
|
|
178
|
-
hideErrorErrorsCodeView: true,
|
|
179
|
-
hideMessage: true,
|
|
180
|
-
prefix: groupSpaces
|
|
181
|
-
})
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
if (suffix) {
|
|
185
|
-
items.push("\n", groupSpaces + colorize.grey(this._styles.underline.suffix ? colorize.underline(suffix) : suffix));
|
|
186
|
-
}
|
|
187
|
-
return items.join("") + "\n";
|
|
188
|
-
}
|
|
189
|
-
_log(message, logLevel) {
|
|
190
|
-
const streamType = ["error", "trace", "warn"].includes(logLevel) ? "stderr" : "stdout";
|
|
191
|
-
const stream = streamType === "stderr" ? this.#stderr : this.#stdout;
|
|
192
|
-
if (this.#interactive && this.#interactiveManager !== void 0 && stream.isTTY) {
|
|
193
|
-
this.#interactiveManager.update(streamType, message.split("\n"), 0);
|
|
194
|
-
} else {
|
|
195
|
-
writeStream.writeStream(message + "\n", stream);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
exports.PrettyReporter = PrettyReporter;
|