@visulima/pail 4.0.0-alpha.3 → 4.0.0-alpha.5

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.
Files changed (27) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/index.browser.js +1488 -2
  3. package/dist/index.server.js +2656 -12
  4. package/dist/interactive/index.js +1 -1
  5. package/dist/packem_shared/AbstractJsonReporter-DWRpTtGw.js +204 -0
  6. package/dist/packem_shared/{interactive-stream-hook-DG4BtN12.js → InteractiveStreamHook-ePIURL_U.js} +1 -9
  7. package/dist/packem_shared/{JsonReporter-VzgyLEYz.js → JsonReporter-BV5lMnJX.js} +1 -1
  8. package/dist/packem_shared/{PrettyReporter-DySIXBjQ.js → PrettyReporter-BYL3NrdA.js} +49 -4
  9. package/dist/packem_shared/{format-label-De49vNPd.js → PrettyReporter-DLQtmATi.js} +267 -2
  10. package/dist/packem_shared/Spinner-B9JUdsbY.js +2150 -0
  11. package/dist/packem_shared/abstract-pretty-reporter-DckLMlGF.js +2496 -0
  12. package/dist/packem_shared/constants-B1RjD_ps.js +99 -0
  13. package/dist/packem_shared/getBarChar-BWj1UrH3.js +404 -0
  14. package/dist/packem_shared/{index-BomQ3E6J.js → index-DnkF86LQ.js} +9 -1
  15. package/dist/processor/message-formatter-processor.js +648 -1
  16. package/dist/reporter/file/json-file-reporter.js +1 -1
  17. package/dist/reporter/http/abstract-http-reporter.js +1 -1
  18. package/dist/reporter/json/index.js +2 -2
  19. package/dist/reporter/pretty/index.browser.js +1 -1
  20. package/dist/reporter/pretty/index.js +1 -1
  21. package/dist/reporter/simple/simple-reporter.server.js +1 -6
  22. package/package.json +4 -4
  23. package/dist/packem_shared/InteractiveStreamHook-DiSubbJ1.js +0 -21
  24. package/dist/packem_shared/PrettyReporter-C2wVB7yu.js +0 -222
  25. package/dist/packem_shared/abstract-pretty-reporter-Di_sdm2r.js +0 -50
  26. package/dist/packem_shared/get-longest-label-C9PWeyKq.js +0 -9
  27. package/dist/packem_shared/pail.browser-u2CSR_af.js +0 -1427
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/pail",
3
- "version": "4.0.0-alpha.3",
3
+ "version": "4.0.0-alpha.5",
4
4
  "description": "Highly configurable Logger for Node.js, Edge and Browser.",
5
5
  "keywords": [
6
6
  "ansi",
@@ -203,12 +203,12 @@
203
203
  "LICENSE.md"
204
204
  ],
205
205
  "dependencies": {
206
- "@visulima/colorize": "2.0.0-alpha.3",
207
- "type-fest": "^5.3.0"
206
+ "@visulima/colorize": "2.0.0-alpha.4",
207
+ "type-fest": "^5.3.1"
208
208
  },
209
209
  "peerDependencies": {
210
210
  "@opentelemetry/api": "^1.9",
211
- "@visulima/redact": "3.0.0-alpha.3",
211
+ "@visulima/redact": "3.0.0-alpha.4",
212
212
  "rotating-file-stream": "^3.2.7"
213
213
  },
214
214
  "peerDependenciesMeta": {
@@ -1,21 +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 __cjs_getBuiltinModule = (module) => {
8
- // Check if we're in Node.js and version supports getBuiltinModule
9
- if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
10
- const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
11
- // Node.js 20.16.0+ and 22.3.0+
12
- if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
13
- return __cjs_getProcess.getBuiltinModule(module);
14
- }
15
- }
16
- // Fallback to createRequire
17
- return __cjs_require(module);
18
- };
19
-
20
-
21
- export { I as default } from './interactive-stream-hook-DG4BtN12.js';
@@ -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-EZ_WSQZS.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 };
@@ -1,9 +0,0 @@
1
- const getLongestLabel = (types) => {
2
- const labels = Object.keys(types).map((x) => types[x].label ?? "");
3
- if (labels.length === 0) {
4
- return "";
5
- }
6
- return labels.reduce((x, y) => x.length > y.length ? x : y);
7
- };
8
-
9
- export { getLongestLabel as g };