@likec4/log 1.48.0 → 1.49.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/dist/THIRD-PARTY-LICENSES.md +76 -0
- package/dist/_chunks/libs/is-error-instance.mjs +1 -5
- package/dist/_chunks/libs/is-plain-obj.mjs +1 -4
- package/dist/_chunks/libs/merge-error-cause.mjs +13 -117
- package/dist/_chunks/libs/safe-stringify.mjs +17 -19
- package/dist/index.mjs +6 -67
- package/package.json +6 -7
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Licenses of Bundled Dependencies
|
|
2
|
+
|
|
3
|
+
The published artifact additionally contains code with the following licenses:
|
|
4
|
+
MIT
|
|
5
|
+
|
|
6
|
+
# Bundled Dependencies
|
|
7
|
+
|
|
8
|
+
## is-error-instance
|
|
9
|
+
|
|
10
|
+
License: MIT
|
|
11
|
+
By: ehmicky
|
|
12
|
+
Repository: https://github.com/ehmicky/is-error-instance
|
|
13
|
+
|
|
14
|
+
> Copyright © 2024 ehmicky
|
|
15
|
+
>
|
|
16
|
+
> Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
17
|
+
> this software and associated documentation files (the “Software”), to deal in
|
|
18
|
+
> the Software without restriction, including without limitation the rights to
|
|
19
|
+
> use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
20
|
+
> the Software, and to permit persons to whom the Software is furnished to do so,
|
|
21
|
+
> subject to the following conditions:
|
|
22
|
+
>
|
|
23
|
+
> The above copyright notice and this permission notice shall be included in all
|
|
24
|
+
> copies or substantial portions of the Software.
|
|
25
|
+
>
|
|
26
|
+
> THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
27
|
+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
28
|
+
> FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
29
|
+
> COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
30
|
+
> IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
31
|
+
> CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
32
|
+
|
|
33
|
+
---------------------------------------
|
|
34
|
+
|
|
35
|
+
## is-plain-obj, safe-stringify
|
|
36
|
+
|
|
37
|
+
License: MIT
|
|
38
|
+
By: Sindre Sorhus
|
|
39
|
+
Repositories: https://github.com/sindresorhus/is-plain-obj, https://github.com/sindresorhus/safe-stringify
|
|
40
|
+
|
|
41
|
+
> MIT License
|
|
42
|
+
>
|
|
43
|
+
> Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
44
|
+
>
|
|
45
|
+
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
46
|
+
>
|
|
47
|
+
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
48
|
+
>
|
|
49
|
+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
50
|
+
|
|
51
|
+
---------------------------------------
|
|
52
|
+
|
|
53
|
+
## merge-error-cause, normalize-exception, redefine-property, set-error-class, set-error-message, set-error-props, wrap-error-message
|
|
54
|
+
|
|
55
|
+
License: MIT
|
|
56
|
+
By: ehmicky
|
|
57
|
+
Repositories: https://github.com/ehmicky/merge-error-cause, https://github.com/ehmicky/normalize-exception, https://github.com/ehmicky/redefine-property, https://github.com/ehmicky/set-error-class, https://github.com/ehmicky/set-error-message, https://github.com/ehmicky/set-error-props, https://github.com/ehmicky/wrap-error-message
|
|
58
|
+
|
|
59
|
+
> Copyright © 2025 ehmicky
|
|
60
|
+
>
|
|
61
|
+
> Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
62
|
+
> this software and associated documentation files (the “Software”), to deal in
|
|
63
|
+
> the Software without restriction, including without limitation the rights to
|
|
64
|
+
> use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
65
|
+
> the Software, and to permit persons to whom the Software is furnished to do so,
|
|
66
|
+
> subject to the following conditions:
|
|
67
|
+
>
|
|
68
|
+
> The above copyright notice and this permission notice shall be included in all
|
|
69
|
+
> copies or substantial portions of the Software.
|
|
70
|
+
>
|
|
71
|
+
> THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
72
|
+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
73
|
+
> FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
74
|
+
> COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
75
|
+
> IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
76
|
+
> CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/is-error-instance@3.0.1/node_modules/is-error-instance/build/src/main.js
|
|
2
1
|
const isErrorInstance = (value) => isInstanceOfError(value) || hasErrorTag(value);
|
|
3
|
-
var main_default = isErrorInstance;
|
|
4
2
|
const isInstanceOfError = (value) => {
|
|
5
3
|
try {
|
|
6
4
|
return value instanceof Error;
|
|
@@ -21,6 +19,4 @@ const ERROR_TAGS = new Set([
|
|
|
21
19
|
"[object DOMError]",
|
|
22
20
|
"[object Exception]"
|
|
23
21
|
]);
|
|
24
|
-
|
|
25
|
-
//#endregion
|
|
26
|
-
export { main_default as t };
|
|
22
|
+
export { isErrorInstance as t };
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/is-plain-obj@4.1.0/node_modules/is-plain-obj/index.js
|
|
2
1
|
function isPlainObject(value) {
|
|
3
2
|
if (typeof value !== "object" || value === null) return false;
|
|
4
3
|
const prototype = Object.getPrototypeOf(value);
|
|
5
4
|
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
|
|
6
5
|
}
|
|
7
|
-
|
|
8
|
-
//#endregion
|
|
9
|
-
export { isPlainObject as t };
|
|
6
|
+
export { isPlainObject as t };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { t as
|
|
1
|
+
import { t as isErrorInstance } from "./is-error-instance.mjs";
|
|
2
2
|
import { t as isPlainObject } from "./is-plain-obj.mjs";
|
|
3
|
-
|
|
4
|
-
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/descriptors.js
|
|
5
3
|
const normalizeDescriptors = (error) => {
|
|
6
4
|
CORE_ERROR_PROPS.forEach((propName) => {
|
|
7
5
|
normalizeDescriptor$1(error, propName);
|
|
@@ -42,9 +40,6 @@ const setErrorDescriptor = (error, propName, descriptor) => {
|
|
|
42
40
|
configurable: true
|
|
43
41
|
});
|
|
44
42
|
};
|
|
45
|
-
|
|
46
|
-
//#endregion
|
|
47
|
-
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/aggregate.js
|
|
48
43
|
const normalizeAggregate = (error, recurse) => {
|
|
49
44
|
if (Array.isArray(error.errors)) setErrorProperty$1(error, "errors", error.errors.filter(isDefined).map(recurse).filter(Boolean));
|
|
50
45
|
else if (isAggregateError(error)) setErrorProperty$1(error, "errors", []);
|
|
@@ -56,18 +51,12 @@ const deleteAggregateErrors = (error) => {
|
|
|
56
51
|
delete error.errors;
|
|
57
52
|
if (error.errors !== void 0) setErrorProperty$1(error, "errors", []);
|
|
58
53
|
};
|
|
59
|
-
|
|
60
|
-
//#endregion
|
|
61
|
-
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/cause.js
|
|
62
54
|
const normalizeCause = (error, recurse) => {
|
|
63
55
|
if (!("cause" in error)) return;
|
|
64
56
|
const cause = error.cause === void 0 ? error.cause : recurse(error.cause);
|
|
65
57
|
if (cause === void 0) delete error.cause;
|
|
66
58
|
else setErrorProperty$1(error, "cause", cause);
|
|
67
59
|
};
|
|
68
|
-
|
|
69
|
-
//#endregion
|
|
70
|
-
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/modifiable.js
|
|
71
60
|
const isNonModifiableError = (error) => !Object.isExtensible(error) || CORE_ERROR_PROPS.some((propName) => isNonConfigurableProp(error, propName) || isThrowingProp(error, propName));
|
|
72
61
|
const isNonConfigurableProp = (error, propName) => {
|
|
73
62
|
const descriptor = Object.getOwnPropertyDescriptor(error, propName);
|
|
@@ -81,9 +70,6 @@ const isThrowingProp = (error, propName) => {
|
|
|
81
70
|
return true;
|
|
82
71
|
}
|
|
83
72
|
};
|
|
84
|
-
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/stack.js
|
|
87
73
|
const setStack = (error) => {
|
|
88
74
|
setErrorProperty$1(error, "stack", getStack$3(error.message, error.name));
|
|
89
75
|
};
|
|
@@ -102,9 +88,6 @@ const getErrorClass = (name) => {
|
|
|
102
88
|
Object.defineProperty(StackError.prototype, "name", descriptor);
|
|
103
89
|
return StackError;
|
|
104
90
|
};
|
|
105
|
-
|
|
106
|
-
//#endregion
|
|
107
|
-
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/copy.js
|
|
108
91
|
const copyObject = (object) => {
|
|
109
92
|
const objectCopy = {};
|
|
110
93
|
for (const propName of getPropsToCopy(object)) try {
|
|
@@ -138,9 +121,6 @@ const isInheritedProp = (object, propName) => {
|
|
|
138
121
|
return false;
|
|
139
122
|
}
|
|
140
123
|
};
|
|
141
|
-
|
|
142
|
-
//#endregion
|
|
143
|
-
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/object.js
|
|
144
124
|
const objectifyError = (object) => {
|
|
145
125
|
const { name, message, stack, cause, errors, ...objectA } = copyObject(object);
|
|
146
126
|
const messageA = getMessage$1(message, objectA);
|
|
@@ -194,9 +174,6 @@ const assignObjectProps = (error, object) => {
|
|
|
194
174
|
const setNewErrorProperty = (error, propName, propValue) => {
|
|
195
175
|
if (propValue !== void 0) setErrorProperty$1(error, propName, propValue);
|
|
196
176
|
};
|
|
197
|
-
|
|
198
|
-
//#endregion
|
|
199
|
-
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/string.js
|
|
200
177
|
const stringifyError = (value) => {
|
|
201
178
|
try {
|
|
202
179
|
const error = new Error(String(value));
|
|
@@ -206,13 +183,10 @@ const stringifyError = (value) => {
|
|
|
206
183
|
return error_;
|
|
207
184
|
}
|
|
208
185
|
};
|
|
209
|
-
|
|
210
|
-
//#endregion
|
|
211
|
-
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/main.js
|
|
212
186
|
const { toString: objectToString } = Object.prototype;
|
|
213
187
|
const createError = (value) => {
|
|
214
188
|
if (isErrorPlainObj(value)) return objectifyError(value);
|
|
215
|
-
if (!
|
|
189
|
+
if (!isErrorInstance(value)) return stringifyError(value);
|
|
216
190
|
if (isInvalidError(value)) return objectifyError(value);
|
|
217
191
|
return value;
|
|
218
192
|
};
|
|
@@ -232,11 +206,7 @@ const isProxy = (value) => {
|
|
|
232
206
|
}
|
|
233
207
|
};
|
|
234
208
|
const hasInvalidConstructor = (error) => typeof error.constructor !== "function" || typeof error.constructor.name !== "string" || error.constructor.name === "" || error.constructor.prototype !== Object.getPrototypeOf(error);
|
|
235
|
-
|
|
236
|
-
//#endregion
|
|
237
|
-
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/main.js
|
|
238
209
|
const normalizeException = (error, { shallow = false } = {}) => recurseException(error, [], shallow);
|
|
239
|
-
var main_default$6 = normalizeException;
|
|
240
210
|
const recurseException = (error, parents, shallow) => {
|
|
241
211
|
if (parents.includes(error)) return;
|
|
242
212
|
const recurse = shallow ? identity : (innerError) => recurseException(innerError, [...parents, error], shallow);
|
|
@@ -265,9 +235,6 @@ const normalizeStack = (error) => {
|
|
|
265
235
|
if (!isDefinedString$1(error.stack)) setStack(error);
|
|
266
236
|
};
|
|
267
237
|
const isDefinedString$1 = (value) => typeof value === "string" && value !== "";
|
|
268
|
-
|
|
269
|
-
//#endregion
|
|
270
|
-
//#region ../../node_modules/.pnpm/set-error-class@3.0.1/node_modules/set-error-class/build/src/args.js
|
|
271
238
|
const normalizeArgs$1 = (error, ErrorClass, currentName = error.name) => {
|
|
272
239
|
validateErrorClass(ErrorClass);
|
|
273
240
|
if (typeof currentName !== "string") throw new TypeError(`currentName must be a string: ${currentName}`);
|
|
@@ -281,9 +248,6 @@ const validateErrorClass = (ErrorClass) => {
|
|
|
281
248
|
const isClass = (ErrorClass) => typeof ErrorClass === "function" && typeof ErrorClass.prototype === "object" && ErrorClass.prototype !== null;
|
|
282
249
|
const isErrorClass = (prototype) => prototype !== null && (prototype.name === "Error" || isErrorClass(Object.getPrototypeOf(prototype)));
|
|
283
250
|
const hasConstructor = (ErrorClass) => typeof ErrorClass.prototype.constructor === "function";
|
|
284
|
-
|
|
285
|
-
//#endregion
|
|
286
|
-
//#region ../../node_modules/.pnpm/set-error-class@3.0.1/node_modules/set-error-class/build/src/enum.js
|
|
287
251
|
const setNonEnumProp$1 = (error, propName, value) => {
|
|
288
252
|
Object.defineProperty(error, propName, {
|
|
289
253
|
value,
|
|
@@ -292,9 +256,6 @@ const setNonEnumProp$1 = (error, propName, value) => {
|
|
|
292
256
|
configurable: true
|
|
293
257
|
});
|
|
294
258
|
};
|
|
295
|
-
|
|
296
|
-
//#endregion
|
|
297
|
-
//#region ../../node_modules/.pnpm/set-error-class@3.0.1/node_modules/set-error-class/build/src/prototype.js
|
|
298
259
|
const updatePrototype = (error, ErrorClass) => {
|
|
299
260
|
if (Object.getPrototypeOf(error) === ErrorClass.prototype) return;
|
|
300
261
|
setPrototype(error, ErrorClass);
|
|
@@ -316,9 +277,6 @@ const isDefinedString = (value) => typeof value === "string" && value !== "";
|
|
|
316
277
|
const deleteOwnProperty = (error, propName) => {
|
|
317
278
|
if (Object.hasOwn(error, propName)) delete error[propName];
|
|
318
279
|
};
|
|
319
|
-
|
|
320
|
-
//#endregion
|
|
321
|
-
//#region ../../node_modules/.pnpm/set-error-class@3.0.1/node_modules/set-error-class/build/src/stack.js
|
|
322
280
|
const updateStack$1 = (error, currentName) => {
|
|
323
281
|
if (!shouldUpdateStack(error, currentName)) return;
|
|
324
282
|
setNonEnumProp$1(error, "stack", getStack$2(error, currentName));
|
|
@@ -349,20 +307,13 @@ const getReplacers$1 = (currentName, newName) => [
|
|
|
349
307
|
[`${currentName} `, `${newName} `],
|
|
350
308
|
[currentName, newName]
|
|
351
309
|
];
|
|
352
|
-
|
|
353
|
-
//#endregion
|
|
354
|
-
//#region ../../node_modules/.pnpm/set-error-class@3.0.1/node_modules/set-error-class/build/src/main.js
|
|
355
310
|
const setErrorClass = (error, ErrorClass, currentName) => {
|
|
356
|
-
const errorA =
|
|
311
|
+
const errorA = normalizeException(error);
|
|
357
312
|
const currentNameA = normalizeArgs$1(errorA, ErrorClass, currentName);
|
|
358
313
|
updatePrototype(errorA, ErrorClass);
|
|
359
314
|
updateStack$1(errorA, currentNameA);
|
|
360
315
|
return errorA;
|
|
361
316
|
};
|
|
362
|
-
var main_default$5 = setErrorClass;
|
|
363
|
-
|
|
364
|
-
//#endregion
|
|
365
|
-
//#region ../../node_modules/.pnpm/redefine-property@3.0.1/node_modules/redefine-property/build/src/merge.js
|
|
366
317
|
const mergeDescriptors = (newDescriptor, currentDescriptor) => currentDescriptor.configurable === false ? mergeNonConfig(newDescriptor, currentDescriptor) : mergeConfig(newDescriptor, currentDescriptor);
|
|
367
318
|
const mergeNonConfig = (newDescriptor, currentDescriptor) => ({
|
|
368
319
|
...currentDescriptor,
|
|
@@ -397,9 +348,6 @@ const mergeValue = (newDescriptor, currentDescriptor, writable) => {
|
|
|
397
348
|
};
|
|
398
349
|
const hasGetSet = ({ get, set }) => get !== void 0 || set !== void 0;
|
|
399
350
|
const mergeDescriptor = (newValue, currentValue, defaultValue) => newValue ?? currentValue ?? defaultValue;
|
|
400
|
-
|
|
401
|
-
//#endregion
|
|
402
|
-
//#region ../../node_modules/.pnpm/redefine-property@3.0.1/node_modules/redefine-property/build/src/normalize.js
|
|
403
351
|
const normalizeInput = (input, key, newDescriptor) => {
|
|
404
352
|
if (!isAnyObj(input)) throw new TypeError(`Argument must be an object: ${input}`);
|
|
405
353
|
if (!isValidKey(key)) throw new TypeError(`Property key must be a string, a symbol or an integer: ${key}`);
|
|
@@ -455,14 +403,10 @@ const validateUnknownProps = (unknownProps) => {
|
|
|
455
403
|
const [unknownProp] = Object.keys(unknownProps);
|
|
456
404
|
if (unknownProp !== void 0) throw new TypeError(`Unknown descriptor property "${unknownProp}": ${unknownProps[unknownProp]}`);
|
|
457
405
|
};
|
|
458
|
-
|
|
459
|
-
//#endregion
|
|
460
|
-
//#region ../../node_modules/.pnpm/redefine-property@3.0.1/node_modules/redefine-property/build/src/main.js
|
|
461
406
|
const redefineProperty = (input, key, newDescriptor) => {
|
|
462
407
|
setProperty(input, key, mergeDescriptors(normalizeInput(input, key, newDescriptor), getCurrentDescriptor(input, key)));
|
|
463
408
|
return input;
|
|
464
409
|
};
|
|
465
|
-
var main_default$4 = redefineProperty;
|
|
466
410
|
const getCurrentDescriptor = (input, key) => {
|
|
467
411
|
const descriptor = Object.getOwnPropertyDescriptor(input, key);
|
|
468
412
|
if (descriptor !== void 0) return descriptor;
|
|
@@ -474,9 +418,6 @@ const setProperty = (input, key, finalDescriptor) => {
|
|
|
474
418
|
Object.defineProperty(input, key, finalDescriptor);
|
|
475
419
|
} catch {}
|
|
476
420
|
};
|
|
477
|
-
|
|
478
|
-
//#endregion
|
|
479
|
-
//#region ../../node_modules/.pnpm/set-error-props@6.0.1/node_modules/set-error-props/build/src/assign.js
|
|
480
421
|
const assignProp = (error, propName, propValue) => {
|
|
481
422
|
if (propValue !== void 0) return setProp(error, propName, propValue);
|
|
482
423
|
try {
|
|
@@ -485,15 +426,12 @@ const assignProp = (error, propName, propValue) => {
|
|
|
485
426
|
if (error[propName] !== void 0) return setProp(error, propName);
|
|
486
427
|
};
|
|
487
428
|
const setProp = (error, propName, propValue) => {
|
|
488
|
-
|
|
429
|
+
redefineProperty(error, propName, {
|
|
489
430
|
value: propValue,
|
|
490
431
|
...getNonEnum(propName)
|
|
491
432
|
});
|
|
492
433
|
};
|
|
493
434
|
const getNonEnum = (propName) => typeof propName === "string" && propName.startsWith("_") ? { enumerable: false } : {};
|
|
494
|
-
|
|
495
|
-
//#endregion
|
|
496
|
-
//#region ../../node_modules/.pnpm/set-error-props@6.0.1/node_modules/set-error-props/build/src/options.js
|
|
497
435
|
const normalizeOptions = (error, props, opts = {}) => {
|
|
498
436
|
validateErrorOrObject(error, "First argument");
|
|
499
437
|
validateErrorOrObject(props, "Second argument");
|
|
@@ -506,10 +444,7 @@ const validateErrorOrObject = (value, prefix) => {
|
|
|
506
444
|
if (value === void 0) throw new TypeError(`${prefix} is required.`);
|
|
507
445
|
if (!isErrorOrObject(value)) throw new TypeError(`${prefix} must be a plain object or an error: ${value}`);
|
|
508
446
|
};
|
|
509
|
-
const isErrorOrObject = (value) => isPlainObject(value) ||
|
|
510
|
-
|
|
511
|
-
//#endregion
|
|
512
|
-
//#region ../../node_modules/.pnpm/set-error-props@6.0.1/node_modules/set-error-props/build/src/skip.js
|
|
447
|
+
const isErrorOrObject = (value) => isPlainObject(value) || isErrorInstance(value);
|
|
513
448
|
const shouldSkipProp = ({ error, props, propName, soft }) => isIgnoredPropName(propName) || !isEnum.call(props, propName) || soft && error[propName] !== void 0;
|
|
514
449
|
const isIgnoredPropName = (propName) => propName in CHECK_ERROR || IGNORED_PROPS.has(propName);
|
|
515
450
|
const CHECK_ERROR = /* @__PURE__ */ new Error("check");
|
|
@@ -519,9 +454,6 @@ const IGNORED_PROPS = new Set([
|
|
|
519
454
|
"cause"
|
|
520
455
|
]);
|
|
521
456
|
const { propertyIsEnumerable: isEnum } = Object.prototype;
|
|
522
|
-
|
|
523
|
-
//#endregion
|
|
524
|
-
//#region ../../node_modules/.pnpm/set-error-props@6.0.1/node_modules/set-error-props/build/src/main.js
|
|
525
457
|
const setErrorProps = (error, props, opts) => {
|
|
526
458
|
const { soft } = normalizeOptions(error, props, opts);
|
|
527
459
|
for (const propName of Reflect.ownKeys(props)) setErrorProp({
|
|
@@ -532,7 +464,6 @@ const setErrorProps = (error, props, opts) => {
|
|
|
532
464
|
});
|
|
533
465
|
return error;
|
|
534
466
|
};
|
|
535
|
-
var main_default$3 = setErrorProps;
|
|
536
467
|
const setErrorProp = ({ error, props, propName, soft }) => {
|
|
537
468
|
if (!shouldSkipProp({
|
|
538
469
|
error,
|
|
@@ -541,9 +472,6 @@ const setErrorProp = ({ error, props, propName, soft }) => {
|
|
|
541
472
|
soft
|
|
542
473
|
})) assignProp(error, propName, props[propName]);
|
|
543
474
|
};
|
|
544
|
-
|
|
545
|
-
//#endregion
|
|
546
|
-
//#region ../../node_modules/.pnpm/merge-error-cause@5.0.2/node_modules/merge-error-cause/build/src/set.js
|
|
547
475
|
const setErrorProperty = (error, propName, value) => {
|
|
548
476
|
Object.defineProperty(error, propName, {
|
|
549
477
|
value,
|
|
@@ -552,9 +480,6 @@ const setErrorProperty = (error, propName, value) => {
|
|
|
552
480
|
configurable: true
|
|
553
481
|
});
|
|
554
482
|
};
|
|
555
|
-
|
|
556
|
-
//#endregion
|
|
557
|
-
//#region ../../node_modules/.pnpm/merge-error-cause@5.0.2/node_modules/merge-error-cause/build/src/aggregate.js
|
|
558
483
|
const mergeAggregateCauses = (parent, recurse) => {
|
|
559
484
|
if (parent.errors === void 0) return;
|
|
560
485
|
setErrorProperty(parent, "errors", parent.errors.map((error) => recurse(error).error).filter(Boolean));
|
|
@@ -570,17 +495,11 @@ const mergeSourceErrors = (target, source) => {
|
|
|
570
495
|
if (source.errors !== void 0) setErrorProperty(target, "errors", source.errors);
|
|
571
496
|
};
|
|
572
497
|
const hasErrors = (targetOrSource) => targetOrSource.errors !== void 0 && targetOrSource.errors.length !== 0;
|
|
573
|
-
|
|
574
|
-
//#endregion
|
|
575
|
-
//#region ../../node_modules/.pnpm/set-error-message@3.0.1/node_modules/set-error-message/build/src/args.js
|
|
576
498
|
const normalizeArgs = (error, newMessage, currentMessage = error.message) => {
|
|
577
499
|
if (typeof newMessage !== "string") throw new TypeError(`newMessage must be a string: ${newMessage}`);
|
|
578
500
|
if (typeof currentMessage !== "string") throw new TypeError(`currentMessage must be a string: ${currentMessage}`);
|
|
579
501
|
return currentMessage;
|
|
580
502
|
};
|
|
581
|
-
|
|
582
|
-
//#endregion
|
|
583
|
-
//#region ../../node_modules/.pnpm/set-error-message@3.0.1/node_modules/set-error-message/build/src/stack.js
|
|
584
503
|
const getStack$1 = ({ name, stack }, newMessage, currentMessage) => currentMessage !== "" && stack.includes(currentMessage) ? replaceMessage({
|
|
585
504
|
name,
|
|
586
505
|
stack,
|
|
@@ -604,17 +523,13 @@ const insertMessage = (name, stack, newMessage) => {
|
|
|
604
523
|
if (stack === name || stack.startsWith(`${name}\n`)) return stack.replace(name, `${nameAndColon}${newMessageA}`);
|
|
605
524
|
return stack.startsWith(nameAndColon) ? stack.replace(nameAndColon, `${nameAndColon}${newMessageA}\n`) : `${nameAndColon}${newMessageA}\n${stack}`;
|
|
606
525
|
};
|
|
607
|
-
|
|
608
|
-
//#endregion
|
|
609
|
-
//#region ../../node_modules/.pnpm/set-error-message@3.0.1/node_modules/set-error-message/build/src/main.js
|
|
610
526
|
const setErrorMessage = (error, newMessage, currentMessage) => {
|
|
611
|
-
const errorA =
|
|
527
|
+
const errorA = normalizeException(error);
|
|
612
528
|
const currentMessageA = normalizeArgs(errorA, newMessage, currentMessage);
|
|
613
529
|
setNonEnumProp(errorA, "message", newMessage);
|
|
614
530
|
updateStack(errorA, newMessage, currentMessageA);
|
|
615
531
|
return errorA;
|
|
616
532
|
};
|
|
617
|
-
var main_default$2 = setErrorMessage;
|
|
618
533
|
const updateStack = (error, newMessage, currentMessage) => {
|
|
619
534
|
if (newMessage === currentMessage || !stackIncludesMessage()) return;
|
|
620
535
|
setNonEnumProp(error, "stack", getStack$1(error, newMessage, currentMessage));
|
|
@@ -632,15 +547,11 @@ const setNonEnumProp = (error, propName, value) => {
|
|
|
632
547
|
configurable: true
|
|
633
548
|
});
|
|
634
549
|
};
|
|
635
|
-
|
|
636
|
-
//#endregion
|
|
637
|
-
//#region ../../node_modules/.pnpm/wrap-error-message@3.0.1/node_modules/wrap-error-message/build/src/main.js
|
|
638
550
|
const wrapErrorMessage = (error, newMessage, oldMessage) => {
|
|
639
551
|
if (typeof newMessage !== "string") throw new TypeError(`Second argument must be a message string: ${newMessage}`);
|
|
640
|
-
const errorA =
|
|
641
|
-
return
|
|
552
|
+
const errorA = normalizeException(error);
|
|
553
|
+
return setErrorMessage(errorA, getMessage(newMessage, errorA.message), oldMessage);
|
|
642
554
|
};
|
|
643
|
-
var main_default$1 = wrapErrorMessage;
|
|
644
555
|
const getMessage = (rawNewMessage, rawCurrentMessage) => {
|
|
645
556
|
const newMessage = rawNewMessage.trim();
|
|
646
557
|
const currentMessage = rawCurrentMessage.trim();
|
|
@@ -654,18 +565,12 @@ const concatMessages = (newMessage, currentMessage, rawNewMessage) => {
|
|
|
654
565
|
};
|
|
655
566
|
const PREPEND_CHAR = ":";
|
|
656
567
|
const PREPEND_NEWLINE_CHAR = "\n";
|
|
657
|
-
|
|
658
|
-
//#endregion
|
|
659
|
-
//#region ../../node_modules/.pnpm/merge-error-cause@5.0.2/node_modules/merge-error-cause/build/src/message.js
|
|
660
568
|
const mergeMessage = ({ parent, child, target, stackError }) => {
|
|
661
569
|
const parentMessage = parent.message;
|
|
662
570
|
const stackErrorMessage = stackError.message;
|
|
663
571
|
target.message = child.message;
|
|
664
|
-
return
|
|
572
|
+
return wrapErrorMessage(target, parentMessage, stackErrorMessage);
|
|
665
573
|
};
|
|
666
|
-
|
|
667
|
-
//#endregion
|
|
668
|
-
//#region ../../node_modules/.pnpm/merge-error-cause@5.0.2/node_modules/merge-error-cause/build/src/stack.js
|
|
669
574
|
const hasStack = (error, stack) => getStack(error) === stack;
|
|
670
575
|
const getStack = (error) => typeof error === "object" && error !== null ? error.stack : void 0;
|
|
671
576
|
const mergeStack = ({ wrap, target, source, childHasStack }) => {
|
|
@@ -673,25 +578,18 @@ const mergeStack = ({ wrap, target, source, childHasStack }) => {
|
|
|
673
578
|
setErrorProperty(target, "stack", source.stack);
|
|
674
579
|
return source;
|
|
675
580
|
};
|
|
676
|
-
|
|
677
|
-
//#endregion
|
|
678
|
-
//#region ../../node_modules/.pnpm/merge-error-cause@5.0.2/node_modules/merge-error-cause/build/src/wrap.js
|
|
679
581
|
const getWrap = (parent) => {
|
|
680
582
|
const { wrap, name } = parent;
|
|
681
583
|
if (typeof wrap !== "boolean") return name === "Error";
|
|
682
584
|
if (Object.hasOwn(parent, "wrap")) delete parent.wrap;
|
|
683
585
|
return wrap;
|
|
684
586
|
};
|
|
685
|
-
|
|
686
|
-
//#endregion
|
|
687
|
-
//#region ../../node_modules/.pnpm/merge-error-cause@5.0.2/node_modules/merge-error-cause/build/src/main.js
|
|
688
587
|
const mergeErrorCause = (error) => mergeError(error, []).error;
|
|
689
|
-
var main_default = mergeErrorCause;
|
|
690
588
|
const mergeError = (error, parents) => {
|
|
691
589
|
if (parents.includes(error)) return {};
|
|
692
590
|
const recurse = (innerError) => mergeError(innerError, [...parents, error]);
|
|
693
591
|
const stack = getStack(error);
|
|
694
|
-
const errorA =
|
|
592
|
+
const errorA = normalizeException(error, { shallow: true });
|
|
695
593
|
const parentHasStack = hasStack(errorA, stack);
|
|
696
594
|
mergeAggregateCauses(errorA, recurse);
|
|
697
595
|
const { parent: errorB, childHasStack } = mergeCause(errorA, recurse);
|
|
@@ -730,7 +628,7 @@ const mergeChild = ({ parent, child, childHasStack, wrap }) => {
|
|
|
730
628
|
const targetB = mergeMessage({
|
|
731
629
|
parent,
|
|
732
630
|
child,
|
|
733
|
-
target:
|
|
631
|
+
target: setErrorClass(target, target.constructor, stackError.name),
|
|
734
632
|
stackError
|
|
735
633
|
});
|
|
736
634
|
mergeAggregateErrors({
|
|
@@ -739,8 +637,6 @@ const mergeChild = ({ parent, child, childHasStack, wrap }) => {
|
|
|
739
637
|
parent,
|
|
740
638
|
child
|
|
741
639
|
});
|
|
742
|
-
return
|
|
640
|
+
return setErrorProps(targetB, source, { soft: !wrap });
|
|
743
641
|
};
|
|
744
|
-
|
|
745
|
-
//#endregion
|
|
746
|
-
export { main_default$1 as n, main_default as t };
|
|
642
|
+
export { wrapErrorMessage as n, mergeErrorCause as t };
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return
|
|
1
|
+
function serializeValue(value, seen, trace, currentPath) {
|
|
2
|
+
if (typeof value?.toJSON === "function") value = value.toJSON();
|
|
3
|
+
if (!(value !== null && typeof value === "object")) return value;
|
|
4
|
+
if (seen.has(value)) {
|
|
5
|
+
if (!trace) return "[Circular]";
|
|
6
|
+
const existingPath = seen.get(value);
|
|
7
|
+
return `[Circular ${existingPath === "" ? "*" : `*${existingPath}`}]`;
|
|
8
|
+
}
|
|
9
|
+
seen.set(value, currentPath);
|
|
10
|
+
const newValue = Array.isArray(value) ? [] : {};
|
|
11
|
+
for (const [propertyKey, propertyValue] of Object.entries(value)) newValue[propertyKey] = serializeValue(propertyValue, seen, trace, currentPath === "" ? propertyKey : `${currentPath}.${propertyKey}`);
|
|
12
|
+
seen.delete(value);
|
|
13
|
+
return newValue;
|
|
14
14
|
}
|
|
15
|
-
function safeStringify(
|
|
16
|
-
const
|
|
17
|
-
return JSON.stringify(
|
|
15
|
+
function safeStringify(value, { indentation, trace } = {}) {
|
|
16
|
+
const serializedValue = serializeValue(value, /* @__PURE__ */ new WeakMap(), trace, "");
|
|
17
|
+
return JSON.stringify(serializedValue, void 0, indentation);
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
export { safeStringify as t };
|
|
19
|
+
export { safeStringify as t };
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { n as
|
|
1
|
+
import { n as wrapErrorMessage, t as mergeErrorCause } from "./_chunks/libs/merge-error-cause.mjs";
|
|
2
2
|
import { t as safeStringify } from "./_chunks/libs/safe-stringify.mjs";
|
|
3
3
|
import { configureSync, getAnsiColorFormatter as getAnsiColorFormatter$1, getConsoleSink as getConsoleSink$1, getLogger, getTextFormatter as getTextFormatter$1, withFilter } from "@logtape/logtape";
|
|
4
|
-
|
|
5
|
-
//#region src/utils.ts
|
|
6
4
|
const parseStack = (stack) => {
|
|
7
5
|
return stack.split("\n").map((l) => {
|
|
8
6
|
return l.trim().replace("file://", "");
|
|
@@ -16,7 +14,7 @@ function indent(value, indentation = 2) {
|
|
|
16
14
|
function loggable(error) {
|
|
17
15
|
if (typeof error === "string") return error;
|
|
18
16
|
if (error instanceof Error) {
|
|
19
|
-
const mergedErr =
|
|
17
|
+
const mergedErr = mergeErrorCause(error);
|
|
20
18
|
if (mergedErr.stack) {
|
|
21
19
|
const stack = parseStack(mergedErr.stack);
|
|
22
20
|
return mergedErr.message + "\n" + indent(stack.slice(1));
|
|
@@ -25,49 +23,13 @@ function loggable(error) {
|
|
|
25
23
|
}
|
|
26
24
|
return safeStringify(error, { indentation: " " });
|
|
27
25
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Appends `message` to `error.message`. If `message` ends with `:` or `:\n`,
|
|
30
|
-
* prepends it instead.
|
|
31
|
-
*
|
|
32
|
-
* Returns `error`. If `error` is not an `Error` instance, it is converted to
|
|
33
|
-
* one.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```js
|
|
37
|
-
* wrapErrorMessage(new Error('Message.'), 'Additional message.')
|
|
38
|
-
* // Error: Message.
|
|
39
|
-
* // Additional message.
|
|
40
|
-
*
|
|
41
|
-
* wrapErrorMessage(new Error('Message.'), 'Additional message:')
|
|
42
|
-
* // Error: Additional message: Message.
|
|
43
|
-
*
|
|
44
|
-
* wrapErrorMessage(new Error('Message.'), 'Additional message:\n')
|
|
45
|
-
* // Error: Additional message:
|
|
46
|
-
* // Message.
|
|
47
|
-
*
|
|
48
|
-
* wrapErrorMessage(new Error('Message.'), '')
|
|
49
|
-
* // Error: Message.
|
|
50
|
-
*
|
|
51
|
-
* const invalidError = 'Message.'
|
|
52
|
-
* wrapErrorMessage(invalidError, 'Additional message.')
|
|
53
|
-
* // Error: Message.
|
|
54
|
-
* // Additional message.
|
|
55
|
-
*
|
|
56
|
-
* wrapErrorMessage(new Error(' Message with spaces '), ' Additional message ')
|
|
57
|
-
* // Error: Message with spaces
|
|
58
|
-
* // Additional message
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
26
|
function wrapError(error, newMessage) {
|
|
62
|
-
return
|
|
27
|
+
return wrapErrorMessage(error, newMessage);
|
|
63
28
|
}
|
|
64
|
-
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region src/formatters.ts
|
|
67
29
|
function gerErrorFromLogRecord(record) {
|
|
68
30
|
const errors = Object.entries(record.properties).flatMap(([k, err]) => {
|
|
69
31
|
if (err instanceof Error) {
|
|
70
|
-
const mergedErr =
|
|
32
|
+
const mergedErr = mergeErrorCause(err);
|
|
71
33
|
if (mergedErr.stack) mergedErr.stack = parseStack(mergedErr.stack).join("\n");
|
|
72
34
|
return [mergedErr];
|
|
73
35
|
}
|
|
@@ -79,7 +41,7 @@ function gerErrorFromLogRecord(record) {
|
|
|
79
41
|
}
|
|
80
42
|
function errorFromLogRecord(record) {
|
|
81
43
|
const error = gerErrorFromLogRecord(record);
|
|
82
|
-
if (error && typeof record.rawMessage === "string") return
|
|
44
|
+
if (error && typeof record.rawMessage === "string") return wrapErrorMessage(error, record.rawMessage + "\n");
|
|
83
45
|
return error;
|
|
84
46
|
}
|
|
85
47
|
function appendErrorToMessage(values, color = false) {
|
|
@@ -141,11 +103,6 @@ function getAnsiColorFormatter(options) {
|
|
|
141
103
|
}
|
|
142
104
|
});
|
|
143
105
|
}
|
|
144
|
-
/**
|
|
145
|
-
* The formatter returns an array where:
|
|
146
|
-
* - First element is the formatted message string
|
|
147
|
-
* - Second element is the record properties object
|
|
148
|
-
*/
|
|
149
106
|
function getConsoleFormatter(options) {
|
|
150
107
|
const formatter = options?.messageFormatter;
|
|
151
108
|
if (formatter) return (record) => {
|
|
@@ -159,19 +116,12 @@ function getConsoleFormatter(options) {
|
|
|
159
116
|
return message;
|
|
160
117
|
};
|
|
161
118
|
}
|
|
162
|
-
|
|
163
|
-
//#endregion
|
|
164
|
-
//#region src/sink.ts
|
|
165
119
|
function getConsoleSink(options) {
|
|
166
120
|
return getConsoleSink$1({
|
|
167
121
|
formatter: getConsoleFormatter(),
|
|
168
122
|
...options
|
|
169
123
|
});
|
|
170
124
|
}
|
|
171
|
-
/**
|
|
172
|
-
* Creates a console sink that writes to stderr.
|
|
173
|
-
* (MCP protocol requires stderr to be used for logging)
|
|
174
|
-
*/
|
|
175
125
|
function getConsoleStderrSink(options) {
|
|
176
126
|
const formatter = options?.formatter ?? getConsoleFormatter();
|
|
177
127
|
return (record) => {
|
|
@@ -182,16 +132,7 @@ function getConsoleStderrSink(options) {
|
|
|
182
132
|
} else console.error(...args);
|
|
183
133
|
};
|
|
184
134
|
}
|
|
185
|
-
|
|
186
|
-
//#endregion
|
|
187
|
-
//#region src/index.ts
|
|
188
135
|
const logger = getLogger("likec4");
|
|
189
|
-
/**
|
|
190
|
-
* Get a child logger with the given subcategory.
|
|
191
|
-
*
|
|
192
|
-
* @param subcategory The subcategory.
|
|
193
|
-
* @returns The child logger.
|
|
194
|
-
*/
|
|
195
136
|
function createLogger(subcategory) {
|
|
196
137
|
return logger.getChild(subcategory);
|
|
197
138
|
}
|
|
@@ -219,6 +160,4 @@ function configureLogger(config) {
|
|
|
219
160
|
console.error(e);
|
|
220
161
|
}
|
|
221
162
|
}
|
|
222
|
-
|
|
223
|
-
//#endregion
|
|
224
|
-
export { configureLogger, logger as consola, logger, logger as rootLogger, createLogger, errorFromLogRecord, getAnsiColorFormatter, getConsoleFormatter, getConsoleSink, getConsoleStderrSink, getMessageOnlyFormatter, getTextFormatter, loggable, withFilter, wrapError };
|
|
163
|
+
export { configureLogger, logger as consola, logger, logger as rootLogger, createLogger, errorFromLogRecord, getAnsiColorFormatter, getConsoleFormatter, getConsoleSink, getConsoleStderrSink, getMessageOnlyFormatter, getTextFormatter, loggable, withFilter, wrapError };
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@likec4/log",
|
|
3
3
|
"description": "Shared interface for logging",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.49.0",
|
|
6
6
|
"bugs": "https://github.com/likec4/likec4/issues",
|
|
7
7
|
"homepage": "https://likec4.dev",
|
|
8
8
|
"author": "Denis Davydkov <denis@davydkov.com>",
|
|
@@ -32,17 +32,16 @@
|
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@logtape/logtape": "^1.3.
|
|
36
|
-
"std-env": "^3.10.0"
|
|
35
|
+
"@logtape/logtape": "^1.3.7"
|
|
37
36
|
},
|
|
38
37
|
"devDependencies": {
|
|
39
|
-
"@types/node": "~22.19.
|
|
38
|
+
"@types/node": "~22.19.10",
|
|
40
39
|
"merge-error-cause": "^5.0.2",
|
|
41
|
-
"safe-stringify": "^1.
|
|
40
|
+
"safe-stringify": "^1.3.0",
|
|
42
41
|
"typescript": "5.9.3",
|
|
43
|
-
"obuild": "^0.4.
|
|
42
|
+
"obuild": "^0.4.27",
|
|
44
43
|
"wrap-error-message": "^3.0.1",
|
|
45
|
-
"@likec4/tsconfig": "1.
|
|
44
|
+
"@likec4/tsconfig": "1.49.0",
|
|
46
45
|
"@likec4/devops": "1.42.0"
|
|
47
46
|
},
|
|
48
47
|
"scripts": {
|