@likec4/log 1.35.0 → 1.36.1
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 +1 -0
- package/package.json +5 -4
- package/src/formatters.ts +1 -71
package/dist/index.mjs
CHANGED
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.1",
|
|
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
38
|
"@types/node": "~20.19.2",
|
|
38
39
|
"merge-error-cause": "^5.0.2",
|
|
39
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.1"
|
|
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 ',
|