@likec4/log 1.34.2 → 1.36.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/index.mjs +5 -2
- package/package.json +7 -6
- package/src/formatters.ts +1 -71
package/dist/index.mjs
CHANGED
|
@@ -1241,7 +1241,7 @@ return targetC
|
|
|
1241
1241
|
};
|
|
1242
1242
|
|
|
1243
1243
|
function safeStringifyReplacer(seen) {
|
|
1244
|
-
|
|
1244
|
+
const replacer = function (key, value) {
|
|
1245
1245
|
// Handle objects with a custom `.toJSON()` method.
|
|
1246
1246
|
if (typeof value?.toJSON === 'function') {
|
|
1247
1247
|
value = value.toJSON();
|
|
@@ -1260,13 +1260,15 @@ function safeStringifyReplacer(seen) {
|
|
|
1260
1260
|
const newValue = Array.isArray(value) ? [] : {};
|
|
1261
1261
|
|
|
1262
1262
|
for (const [key2, value2] of Object.entries(value)) {
|
|
1263
|
-
newValue[key2] =
|
|
1263
|
+
newValue[key2] = replacer(key2, value2);
|
|
1264
1264
|
}
|
|
1265
1265
|
|
|
1266
1266
|
seen.delete(value);
|
|
1267
1267
|
|
|
1268
1268
|
return newValue;
|
|
1269
1269
|
};
|
|
1270
|
+
|
|
1271
|
+
return replacer;
|
|
1270
1272
|
}
|
|
1271
1273
|
|
|
1272
1274
|
function safeStringify(object, {indentation} = {}) {
|
|
@@ -1338,6 +1340,7 @@ function appendErrorToMessage(values, color) {
|
|
|
1338
1340
|
return values;
|
|
1339
1341
|
}
|
|
1340
1342
|
const levelAbbreviations = {
|
|
1343
|
+
"trace": "TRACE",
|
|
1341
1344
|
"debug": "DEBUG",
|
|
1342
1345
|
"info": "INFO ",
|
|
1343
1346
|
"warning": "WARN ",
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likec4/log",
|
|
3
|
+
"description": "Shared interface for logging",
|
|
3
4
|
"license": "MIT",
|
|
4
|
-
"version": "1.
|
|
5
|
+
"version": "1.36.0",
|
|
5
6
|
"bugs": "https://github.com/likec4/likec4/issues",
|
|
6
7
|
"homepage": "https://likec4.dev",
|
|
7
8
|
"author": "Denis Davydkov <denis@davydkov.com>",
|
|
@@ -31,17 +32,17 @@
|
|
|
31
32
|
"access": "public"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
|
-
"@logtape/logtape": "^0.
|
|
35
|
+
"@logtape/logtape": "^0.12.2"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"@types/node": "~20.19.
|
|
38
|
+
"@types/node": "~20.19.2",
|
|
38
39
|
"merge-error-cause": "^5.0.2",
|
|
39
|
-
"safe-stringify": "^1.
|
|
40
|
+
"safe-stringify": "^1.2.0",
|
|
40
41
|
"std-env": "^3.9.0",
|
|
41
|
-
"typescript": "5.
|
|
42
|
+
"typescript": "5.9.2",
|
|
42
43
|
"unbuild": "3.5.0",
|
|
43
44
|
"wrap-error-message": "^3.0.1",
|
|
44
|
-
"@likec4/tsconfig": "1.
|
|
45
|
+
"@likec4/tsconfig": "1.36.0"
|
|
45
46
|
},
|
|
46
47
|
"scripts": {
|
|
47
48
|
"typecheck": "tsc -b --verbose",
|
package/src/formatters.ts
CHANGED
|
@@ -15,61 +15,6 @@ import mergeErrorCause from 'merge-error-cause'
|
|
|
15
15
|
import wrapErrorMessage from 'wrap-error-message'
|
|
16
16
|
import { ident, parseStack } from './utils'
|
|
17
17
|
|
|
18
|
-
// export function formatProperties(properties: Record<string, unknown>): {
|
|
19
|
-
// properties: Record<string, unknown>
|
|
20
|
-
// output?: string
|
|
21
|
-
// error?: never
|
|
22
|
-
// } | {
|
|
23
|
-
// properties: Record<string, unknown>
|
|
24
|
-
// output: string
|
|
25
|
-
// error?: {
|
|
26
|
-
// message: string
|
|
27
|
-
// name: string
|
|
28
|
-
// stack?: string
|
|
29
|
-
// }
|
|
30
|
-
// } {
|
|
31
|
-
// let error: {
|
|
32
|
-
// message: string
|
|
33
|
-
// name: string
|
|
34
|
-
// stack?: string
|
|
35
|
-
// } | undefined
|
|
36
|
-
// let totalProps = 0
|
|
37
|
-
// const formattedProperties = {} as Record<string, unknown>
|
|
38
|
-
// for (const [key, value] of Object.entries(properties)) {
|
|
39
|
-
// if (value instanceof Error) {
|
|
40
|
-
// const mergedErr = mergeErrorCause(value)
|
|
41
|
-
// const stack = mergedErr.stack ? parseStack(mergedErr.stack) : undefined
|
|
42
|
-
// const formattedError = {
|
|
43
|
-
// message: mergedErr.message,
|
|
44
|
-
// name: mergedErr.name,
|
|
45
|
-
// ...stack && { stack: stack.join('\n') },
|
|
46
|
-
// }
|
|
47
|
-
// error ??= formattedError
|
|
48
|
-
// formattedProperties[key] = formattedError
|
|
49
|
-
// } else {
|
|
50
|
-
// formattedProperties[key] = value
|
|
51
|
-
// }
|
|
52
|
-
// totalProps++
|
|
53
|
-
// }
|
|
54
|
-
// if (totalProps === 0) {
|
|
55
|
-
// return {
|
|
56
|
-
// properties: formattedProperties,
|
|
57
|
-
// }
|
|
58
|
-
// }
|
|
59
|
-
// if (error) {
|
|
60
|
-
// return {
|
|
61
|
-
// error: error,
|
|
62
|
-
// output: error.stack ? error.message + '\n' + ident(error.stack.slice(1)) : error.message,
|
|
63
|
-
// properties: formattedProperties,
|
|
64
|
-
// }
|
|
65
|
-
// }
|
|
66
|
-
// return {
|
|
67
|
-
// ...(error && { error: error }),
|
|
68
|
-
// output: safeStringify(formattedProperties, { indentation: '\t' }),
|
|
69
|
-
// properties: formattedProperties,
|
|
70
|
-
// }
|
|
71
|
-
// }
|
|
72
|
-
|
|
73
18
|
function gerErrorFromLogRecord(record: LogRecord): Error | null {
|
|
74
19
|
const errors = Object
|
|
75
20
|
.values(record.properties)
|
|
@@ -113,23 +58,8 @@ export function appendErrorToMessage(values: FormattedValues, color?: boolean):
|
|
|
113
58
|
return values
|
|
114
59
|
}
|
|
115
60
|
|
|
116
|
-
// export function formatRecord(values: FormattedValues): FormattedValues {
|
|
117
|
-
// const props = formatProperties(values.record.properties)
|
|
118
|
-
// if (props.output) {
|
|
119
|
-
// props.output = ' \n' + ident(props.output)
|
|
120
|
-
// return {
|
|
121
|
-
// ...values,
|
|
122
|
-
// record: {
|
|
123
|
-
// ...values.record,
|
|
124
|
-
// properties: props.properties,
|
|
125
|
-
// },
|
|
126
|
-
// message: `${values.message}${props.output}`,
|
|
127
|
-
// }
|
|
128
|
-
// }
|
|
129
|
-
// return values
|
|
130
|
-
// }
|
|
131
|
-
|
|
132
61
|
const levelAbbreviations: Record<LogLevel, string> = {
|
|
62
|
+
'trace': 'TRACE',
|
|
133
63
|
'debug': 'DEBUG',
|
|
134
64
|
'info': 'INFO ',
|
|
135
65
|
'warning': 'WARN ',
|