Skip to content

Commit 0cc39f2

Browse files
committed
fix: keep errors in memory log
1 parent a9f0ca7 commit 0cc39f2

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/common/data/convert.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Uint8ArrayToHexDump } from './bin'
2+
import { objectPlain } from './object'
23

34
// import { jsonStringify } from './json'
45

@@ -111,6 +112,7 @@ export function formatMessages(
111112
return `${obj.name || 'Error'}: ${obj.message}\n${obj.stack}`
112113
}
113114
try {
115+
obj = objectPlain(obj)
114116
return pretty ? JSON.stringify(obj, null, 2) : JSON.stringify(obj)
115117
}
116118
catch (err) {}

src/common/log/log-memory.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ export function LoggerMemoryHandler(
3232

3333
msg.timestamp ??= getTimestamp()
3434

35-
const m = objectPlain(msg, { maxDepth, errorTrace })
35+
const m = objectPlain(msg, {
36+
maxDepth,
37+
errorTrace,
38+
keepAsIs: v => v instanceof Error,
39+
})
3640

3741
if (compact === true)
3842
(messages as LogMessageCompact[]).push([m.timestamp, m.level, m.name, ...m.messages])

0 commit comments

Comments
 (0)