@visulima/pail 2.1.26 → 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.
Files changed (82) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/index.browser.cjs +1 -19
  3. package/dist/index.browser.mjs +1 -14
  4. package/dist/index.server.cjs +5 -442
  5. package/dist/index.server.mjs +5 -437
  6. package/dist/packem_shared/CallerProcessor-DJnmMPMj.cjs +1 -0
  7. package/dist/packem_shared/CallerProcessor-mNkBei3j.mjs +1 -0
  8. package/dist/packem_shared/JsonFileReporter-BnxuhH4o.cjs +2 -0
  9. package/dist/packem_shared/JsonFileReporter-Og8hyKfg.mjs +4 -0
  10. package/dist/packem_shared/JsonReporter-BdExg5gk.mjs +1 -0
  11. package/dist/packem_shared/JsonReporter-CjvkrXUp.cjs +1 -0
  12. package/dist/packem_shared/JsonReporter-DRGJgjAO.mjs +2 -0
  13. package/dist/packem_shared/JsonReporter-DuF0Ho5i.cjs +2 -0
  14. package/dist/packem_shared/MessageFormatterProcessor-BjBZzL2D.mjs +1 -0
  15. package/dist/packem_shared/MessageFormatterProcessor-CCRIUIdT.cjs +1 -0
  16. package/dist/packem_shared/PrettyReporter-BRFlkORc.mjs +5 -0
  17. package/dist/packem_shared/PrettyReporter-BuKPqA5T.cjs +5 -0
  18. package/dist/packem_shared/PrettyReporter-DDsX0vlT.mjs +13 -0
  19. package/dist/packem_shared/PrettyReporter-Dx1OfdGj.cjs +13 -0
  20. package/dist/packem_shared/RedactProcessor-BBJysXaX.cjs +1 -0
  21. package/dist/packem_shared/RedactProcessor-CxKTN42V.mjs +3 -0
  22. package/dist/packem_shared/SimpleReporter-BV0taliz.mjs +11 -0
  23. package/dist/packem_shared/SimpleReporter-YuzZZabX.cjs +11 -0
  24. package/dist/packem_shared/abstract-json-reporter-Z6bVrpPK.cjs +1 -0
  25. package/dist/packem_shared/abstract-json-reporter-tFmKAzRZ.mjs +1 -0
  26. package/dist/packem_shared/abstract-pretty-reporter-C2vDqWAQ.cjs +1 -0
  27. package/dist/packem_shared/abstract-pretty-reporter-CRcf4WZd.mjs +1 -0
  28. package/dist/packem_shared/constants-BFrKdBPm.cjs +1 -0
  29. package/dist/packem_shared/constants-BMS51p6Y.mjs +1 -0
  30. package/dist/packem_shared/format-label-CKRxcWAQ.cjs +8 -0
  31. package/dist/packem_shared/format-label-D2xt_3df.mjs +8 -0
  32. package/dist/packem_shared/get-longest-label-7LkwzzHo.cjs +1 -0
  33. package/dist/packem_shared/get-longest-label-B0NrI-o2.mjs +1 -0
  34. package/dist/packem_shared/pail.browser-DC6QwLTj.cjs +1 -0
  35. package/dist/packem_shared/pail.browser-DkNIDzgk.mjs +1 -0
  36. package/dist/packem_shared/write-console-log-3G15muTS.cjs +1 -0
  37. package/dist/packem_shared/write-console-log-BP95fgQZ.mjs +1 -0
  38. package/dist/packem_shared/write-stream-CD8XFv1L.mjs +1 -0
  39. package/dist/packem_shared/write-stream-Dl-usQqh.cjs +1 -0
  40. package/dist/processor.browser.cjs +1 -11
  41. package/dist/processor.browser.mjs +1 -2
  42. package/dist/processor.server.cjs +1 -13
  43. package/dist/processor.server.mjs +1 -3
  44. package/dist/reporter.browser.cjs +1 -11
  45. package/dist/reporter.browser.mjs +1 -2
  46. package/dist/reporter.server.cjs +1 -15
  47. package/dist/reporter.server.mjs +1 -4
  48. package/package.json +2 -2
  49. package/dist/packem_shared/CallerProcessor-CNhuyGAa.mjs +0 -58
  50. package/dist/packem_shared/CallerProcessor-DJ5euiUK.cjs +0 -60
  51. package/dist/packem_shared/JsonFileReporter-BazAMbEI.mjs +0 -133
  52. package/dist/packem_shared/JsonFileReporter-PNmBNTr1.cjs +0 -135
  53. package/dist/packem_shared/JsonReporter-CKWF4Ibl.mjs +0 -20
  54. package/dist/packem_shared/JsonReporter-CcOVaf3A.cjs +0 -34
  55. package/dist/packem_shared/JsonReporter-Cg5R1FXn.cjs +0 -22
  56. package/dist/packem_shared/JsonReporter-DFFyVZyh.mjs +0 -32
  57. package/dist/packem_shared/MessageFormatterProcessor-Cd4HntPG.mjs +0 -53
  58. package/dist/packem_shared/MessageFormatterProcessor-t4t6CpzV.cjs +0 -55
  59. package/dist/packem_shared/PrettyReporter-3oMWkX6j.cjs +0 -200
  60. package/dist/packem_shared/PrettyReporter-Bx3QLZrW.mjs +0 -162
  61. package/dist/packem_shared/PrettyReporter-C2hjNe-y.mjs +0 -192
  62. package/dist/packem_shared/PrettyReporter-mFCjMb0i.cjs +0 -168
  63. package/dist/packem_shared/RedactProcessor-CfNkF2lC.mjs +0 -26
  64. package/dist/packem_shared/RedactProcessor-DWE5iqAQ.cjs +0 -26
  65. package/dist/packem_shared/SimpleReporter-CXXqr1h3.cjs +0 -186
  66. package/dist/packem_shared/SimpleReporter-TOcMSqJb.mjs +0 -178
  67. package/dist/packem_shared/abstract-json-reporter-okwLqT9k.cjs +0 -57
  68. package/dist/packem_shared/abstract-json-reporter-sxnmNIlg.mjs +0 -55
  69. package/dist/packem_shared/abstract-pretty-reporter-BR_6_JVa.cjs +0 -49
  70. package/dist/packem_shared/abstract-pretty-reporter-izJgxoMv.mjs +0 -46
  71. package/dist/packem_shared/constants-BYYZ5WNW.mjs +0 -114
  72. package/dist/packem_shared/constants-DHfYGxxG.cjs +0 -118
  73. package/dist/packem_shared/format-label-DYEhjrTZ.cjs +0 -621
  74. package/dist/packem_shared/format-label-Uj-cxY3j.mjs +0 -609
  75. package/dist/packem_shared/get-longest-label-CM8kLFWH.mjs +0 -11
  76. package/dist/packem_shared/get-longest-label-CQ7lRhgD.cjs +0 -13
  77. package/dist/packem_shared/pail.browser-Bp1fz428.mjs +0 -384
  78. package/dist/packem_shared/pail.browser-O53Q_cus.cjs +0 -387
  79. package/dist/packem_shared/write-console-log-Cu0-IDN-.cjs +0 -18
  80. package/dist/packem_shared/write-console-log-Tptfzg9D.mjs +0 -16
  81. package/dist/packem_shared/write-stream-BBAF33Zm.mjs +0 -8
  82. package/dist/packem_shared/write-stream-CkNf2Ju8.cjs +0 -10
@@ -1,186 +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');
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 SimpleReporter extends abstractPrettyReporter.AbstractPrettyReporter {
23
- static {
24
- __name(this, "SimpleReporter");
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, indent: void 0, ...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(colorize.bold(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(colorize.bold(colorized(formatLabel.formatLabel(label, this._styles))) + " ", " ".repeat(longestLabel.length - formatLabel.stringLength(label)));
100
- } else {
101
- items.push(" ".repeat(longestLabel.length + 1));
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(colorize.grey("[" + (this._styles.underline.prefix ? colorize.underline(prefix) : prefix) + "]") + " ");
111
- }
112
- const titleSize = formatLabel.stringLength(items.join(""));
113
- if (message !== constants.EMPTY_SYMBOL) {
114
- const formattedMessage = typeof message === "string" ? message : inspector.inspect(message, this.#inspectOptions);
115
- items.push(
116
- groupSpaces + formatLabel.wrapAnsi(formattedMessage, size - 3, {
117
- hard: true,
118
- trim: false,
119
- wordWrap: true
120
- })
121
- );
122
- }
123
- if (context) {
124
- let hasError = false;
125
- items.push(
126
- ...context.map((value) => {
127
- if (value instanceof Error) {
128
- hasError = true;
129
- return "\n\n" + error.renderError(value, {
130
- ...this.#errorOptions,
131
- filterStacktrace: pailFileFilter,
132
- prefix: groupSpaces
133
- });
134
- }
135
- if (typeof value === "object") {
136
- return " " + inspector.inspect(value, this.#inspectOptions);
137
- }
138
- const newValue = (hasError ? "\n\n" : " ") + value;
139
- hasError = false;
140
- return newValue;
141
- })
142
- );
143
- }
144
- if (error$1) {
145
- items.push(
146
- error.renderError(error$1, {
147
- ...this.#errorOptions,
148
- filterStacktrace: pailFileFilter,
149
- prefix: groupSpaces
150
- })
151
- );
152
- }
153
- if (traceError) {
154
- items.push(
155
- "\n\n" + error.renderError(traceError, {
156
- ...this.#errorOptions,
157
- filterStacktrace: pailFileFilter,
158
- hideErrorCauseCodeView: true,
159
- hideErrorCodeView: true,
160
- hideErrorErrorsCodeView: true,
161
- hideMessage: true,
162
- prefix: groupSpaces
163
- })
164
- );
165
- }
166
- if (suffix) {
167
- items.push(" " + groupSpaces + colorize.grey(this._styles.underline.suffix ? colorize.underline(suffix) : suffix));
168
- }
169
- if (file) {
170
- const fileMessage = file.name + (file.line ? ":" + file.line : "");
171
- items.push("\n", colorize.grey("Caller: "), " ".repeat(titleSize - 8), fileMessage, "\n");
172
- }
173
- return items.join("");
174
- }
175
- _log(message, logLevel) {
176
- const streamType = ["error", "trace", "warn"].includes(logLevel) ? "stderr" : "stdout";
177
- const stream = streamType === "stderr" ? this.#stderr : this.#stdout;
178
- if (this.#interactive && this.#interactiveManager !== void 0 && stream.isTTY) {
179
- this.#interactiveManager.update(streamType, message.split("\n"), 0);
180
- } else {
181
- writeStream.writeStream(message + "\n", stream);
182
- }
183
- }
184
- }
185
-
186
- exports.SimpleReporter = SimpleReporter;
@@ -1,178 +0,0 @@
1
- import { stdout, stderr } from 'node:process';
2
- import colorize, { red, greenBright, cyan, green, grey, bold, white, bgGrey, underline } from '@visulima/colorize';
3
- import { renderError } from '@visulima/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 SimpleReporter extends AbstractPrettyReporter {
15
- static {
16
- __name(this, "SimpleReporter");
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, indent: void 0, ...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(bold(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(bold(colorized(formatLabel(label, this._styles))) + " ", " ".repeat(longestLabel.length - stringLength(label)));
92
- } else {
93
- items.push(" ".repeat(longestLabel.length + 1));
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(grey("[" + (this._styles.underline.prefix ? underline(prefix) : prefix) + "]") + " ");
103
- }
104
- const titleSize = stringLength(items.join(""));
105
- if (message !== EMPTY_SYMBOL) {
106
- const formattedMessage = typeof message === "string" ? message : inspect(message, this.#inspectOptions);
107
- items.push(
108
- groupSpaces + wrapAnsi(formattedMessage, size - 3, {
109
- hard: true,
110
- trim: false,
111
- wordWrap: true
112
- })
113
- );
114
- }
115
- if (context) {
116
- let hasError = false;
117
- items.push(
118
- ...context.map((value) => {
119
- if (value instanceof Error) {
120
- hasError = true;
121
- return "\n\n" + renderError(value, {
122
- ...this.#errorOptions,
123
- filterStacktrace: pailFileFilter,
124
- prefix: groupSpaces
125
- });
126
- }
127
- if (typeof value === "object") {
128
- return " " + inspect(value, this.#inspectOptions);
129
- }
130
- const newValue = (hasError ? "\n\n" : " ") + value;
131
- hasError = false;
132
- return newValue;
133
- })
134
- );
135
- }
136
- if (error) {
137
- items.push(
138
- renderError(error, {
139
- ...this.#errorOptions,
140
- filterStacktrace: pailFileFilter,
141
- prefix: groupSpaces
142
- })
143
- );
144
- }
145
- if (traceError) {
146
- items.push(
147
- "\n\n" + renderError(traceError, {
148
- ...this.#errorOptions,
149
- filterStacktrace: pailFileFilter,
150
- hideErrorCauseCodeView: true,
151
- hideErrorCodeView: true,
152
- hideErrorErrorsCodeView: true,
153
- hideMessage: true,
154
- prefix: groupSpaces
155
- })
156
- );
157
- }
158
- if (suffix) {
159
- items.push(" " + groupSpaces + grey(this._styles.underline.suffix ? underline(suffix) : suffix));
160
- }
161
- if (file) {
162
- const fileMessage = file.name + (file.line ? ":" + file.line : "");
163
- items.push("\n", grey("Caller: "), " ".repeat(titleSize - 8), fileMessage, "\n");
164
- }
165
- return items.join("");
166
- }
167
- _log(message, logLevel) {
168
- const streamType = ["error", "trace", "warn"].includes(logLevel) ? "stderr" : "stdout";
169
- const stream = streamType === "stderr" ? this.#stderr : this.#stdout;
170
- if (this.#interactive && this.#interactiveManager !== void 0 && stream.isTTY) {
171
- this.#interactiveManager.update(streamType, message.split("\n"), 0);
172
- } else {
173
- writeStream(message + "\n", stream);
174
- }
175
- }
176
- }
177
-
178
- export { SimpleReporter };
@@ -1,57 +0,0 @@
1
- 'use strict';
2
-
3
- const error = require('@visulima/error/error');
4
- const constants = require('./constants-DHfYGxxG.cjs');
5
-
6
- var __defProp = Object.defineProperty;
7
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
- class AbstractJsonReporter {
9
- static {
10
- __name(this, "AbstractJsonReporter");
11
- }
12
- // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
13
- stringify;
14
- errorOptions;
15
- constructor(options = {}) {
16
- this.errorOptions = options.error ?? {};
17
- }
18
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
19
- setStringify(function_) {
20
- this.stringify = function_;
21
- }
22
- // eslint-disable-next-line sonarjs/cognitive-complexity
23
- log(meta) {
24
- const { context, error: error$1, file, message, type, ...rest } = meta;
25
- if (rest.label) {
26
- rest.label = rest.label.trim();
27
- }
28
- if (file) {
29
- rest.file = file.name + ":" + file.line + (file.column ? ":" + file.column : "");
30
- }
31
- if (message === constants.EMPTY_SYMBOL) {
32
- rest.message = void 0;
33
- } else {
34
- rest.message = message;
35
- }
36
- if (error$1) {
37
- rest.error = error.serializeError(error$1, this.errorOptions);
38
- }
39
- if (context) {
40
- const newContext = [];
41
- for (const item of context) {
42
- if (item === constants.EMPTY_SYMBOL) {
43
- continue;
44
- }
45
- if (item instanceof Error) {
46
- newContext.push(error.serializeError(item, this.errorOptions));
47
- } else {
48
- newContext.push(item);
49
- }
50
- }
51
- rest.context = newContext;
52
- }
53
- this._log(this.stringify(rest), type.level);
54
- }
55
- }
56
-
57
- exports.AbstractJsonReporter = AbstractJsonReporter;
@@ -1,55 +0,0 @@
1
- import { serializeError } from '@visulima/error/error';
2
- import { E as EMPTY_SYMBOL } from './constants-BYYZ5WNW.mjs';
3
-
4
- var __defProp = Object.defineProperty;
5
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
- class AbstractJsonReporter {
7
- static {
8
- __name(this, "AbstractJsonReporter");
9
- }
10
- // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
11
- stringify;
12
- errorOptions;
13
- constructor(options = {}) {
14
- this.errorOptions = options.error ?? {};
15
- }
16
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
17
- setStringify(function_) {
18
- this.stringify = function_;
19
- }
20
- // eslint-disable-next-line sonarjs/cognitive-complexity
21
- log(meta) {
22
- const { context, error, file, message, type, ...rest } = meta;
23
- if (rest.label) {
24
- rest.label = rest.label.trim();
25
- }
26
- if (file) {
27
- rest.file = file.name + ":" + file.line + (file.column ? ":" + file.column : "");
28
- }
29
- if (message === EMPTY_SYMBOL) {
30
- rest.message = void 0;
31
- } else {
32
- rest.message = message;
33
- }
34
- if (error) {
35
- rest.error = serializeError(error, this.errorOptions);
36
- }
37
- if (context) {
38
- const newContext = [];
39
- for (const item of context) {
40
- if (item === EMPTY_SYMBOL) {
41
- continue;
42
- }
43
- if (item instanceof Error) {
44
- newContext.push(serializeError(item, this.errorOptions));
45
- } else {
46
- newContext.push(item);
47
- }
48
- }
49
- rest.context = newContext;
50
- }
51
- this._log(this.stringify(rest), type.level);
52
- }
53
- }
54
-
55
- export { AbstractJsonReporter as A };
@@ -1,49 +0,0 @@
1
- 'use strict';
2
-
3
- const constants = require('./constants-DHfYGxxG.cjs');
4
-
5
- var __defProp$1 = Object.defineProperty;
6
- var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
7
- const getLongestBadge = /* @__PURE__ */ __name$1((types) => {
8
- const badges = Object.keys(types).map((x) => types[x].badge ?? "");
9
- if (badges.length === 0) {
10
- return "";
11
- }
12
- return badges.reduce((x, y) => x.length > y.length ? x : y);
13
- }, "getLongestBadge");
14
-
15
- var __defProp = Object.defineProperty;
16
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
17
- const dateFormatter = /* @__PURE__ */ __name((date) => [date.getHours(), date.getMinutes(), date.getSeconds()].map((n) => String(n).padStart(2, "0")).join(":"), "dateFormatter");
18
- class AbstractPrettyReporter {
19
- static {
20
- __name(this, "AbstractPrettyReporter");
21
- }
22
- _styles;
23
- _loggerTypes;
24
- constructor(options) {
25
- this._styles = {
26
- bold: {
27
- label: false
28
- },
29
- dateFormatter,
30
- underline: {
31
- label: false,
32
- message: false,
33
- prefix: false,
34
- suffix: false
35
- },
36
- uppercase: {
37
- label: false
38
- },
39
- ...options
40
- };
41
- this._loggerTypes = constants.LOG_TYPES;
42
- }
43
- setLoggerTypes(types) {
44
- this._loggerTypes = types;
45
- }
46
- }
47
-
48
- exports.AbstractPrettyReporter = AbstractPrettyReporter;
49
- exports.getLongestBadge = getLongestBadge;
@@ -1,46 +0,0 @@
1
- import { L as LOG_TYPES } from './constants-BYYZ5WNW.mjs';
2
-
3
- var __defProp$1 = Object.defineProperty;
4
- var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
5
- const getLongestBadge = /* @__PURE__ */ __name$1((types) => {
6
- const badges = Object.keys(types).map((x) => types[x].badge ?? "");
7
- if (badges.length === 0) {
8
- return "";
9
- }
10
- return badges.reduce((x, y) => x.length > y.length ? x : y);
11
- }, "getLongestBadge");
12
-
13
- var __defProp = Object.defineProperty;
14
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
15
- const dateFormatter = /* @__PURE__ */ __name((date) => [date.getHours(), date.getMinutes(), date.getSeconds()].map((n) => String(n).padStart(2, "0")).join(":"), "dateFormatter");
16
- class AbstractPrettyReporter {
17
- static {
18
- __name(this, "AbstractPrettyReporter");
19
- }
20
- _styles;
21
- _loggerTypes;
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
- setLoggerTypes(types) {
42
- this._loggerTypes = types;
43
- }
44
- }
45
-
46
- export { AbstractPrettyReporter as A, getLongestBadge as g };
@@ -1,114 +0,0 @@
1
- const EXTENDED_RFC_5424_LOG_LEVELS = {
2
- alert: 7,
3
- // Action must be taken immediately. Example: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up.
4
- critical: 6,
5
- // Critical conditions. Example: Application component unavailable, unexpected exception.
6
- debug: 1,
7
- // Detailed debug information.
8
- emergency: 8,
9
- // Emergency: system is unusable.
10
- error: 5,
11
- // Runtime errors that do not require immediate action but should typically be logged and monitored.
12
- informational: 2,
13
- // Interesting events. Examples: User logs in, SQL logs.
14
- notice: 3,
15
- // Normal but significant events.
16
- trace: 2,
17
- // Trace information.
18
- warning: 4
19
- // Exceptional occurrences that are not errors. Examples: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.
20
- };
21
- const LOG_TYPES = {
22
- alert: {
23
- color: "red",
24
- label: "alert",
25
- logLevel: "alert"
26
- },
27
- await: {
28
- color: "blue",
29
- label: "awaiting",
30
- logLevel: "informational"
31
- },
32
- complete: {
33
- color: "cyan",
34
- label: "complete",
35
- logLevel: "informational"
36
- },
37
- critical: {
38
- color: "redBright",
39
- label: "critical",
40
- logLevel: "critical"
41
- },
42
- debug: {
43
- color: "gray",
44
- label: "debug",
45
- logLevel: "debug"
46
- },
47
- emergency: {
48
- color: "redBright",
49
- label: "emergency",
50
- logLevel: "emergency"
51
- },
52
- error: {
53
- color: "red",
54
- label: "error",
55
- logLevel: "error"
56
- },
57
- info: {
58
- color: "blueBright",
59
- label: "info",
60
- logLevel: "informational"
61
- },
62
- log: {
63
- label: "",
64
- logLevel: "informational"
65
- },
66
- notice: {
67
- color: "magentaBright",
68
- label: "notice",
69
- logLevel: "notice"
70
- },
71
- pending: {
72
- color: "magenta",
73
- label: "pending",
74
- logLevel: "informational"
75
- },
76
- start: {
77
- color: "greenBright",
78
- label: "start",
79
- logLevel: "informational"
80
- },
81
- stop: {
82
- color: "red",
83
- label: "stop",
84
- logLevel: "informational"
85
- },
86
- success: {
87
- color: "green",
88
- label: "success",
89
- logLevel: "informational"
90
- },
91
- trace: {
92
- color: "cyanBright",
93
- label: "trace",
94
- logLevel: "trace"
95
- },
96
- wait: {
97
- color: "blue",
98
- label: "waiting",
99
- logLevel: "informational"
100
- },
101
- warn: {
102
- color: "yellow",
103
- label: "warning",
104
- logLevel: "warning"
105
- },
106
- watch: {
107
- color: "yellowBright",
108
- label: "watching",
109
- logLevel: "informational"
110
- }
111
- };
112
- const EMPTY_SYMBOL = Symbol("EMPTY");
113
-
114
- export { EMPTY_SYMBOL as E, LOG_TYPES as L, EXTENDED_RFC_5424_LOG_LEVELS as a };