Skip to content

Commit c5988cc

Browse files
authored
feat: add %e error formatter (#2726)
Try to log the stack trace, if it's not available use the message
1 parent 9800384 commit c5988cc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/logger/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ debug.formatters.a = (v?: Multiaddr): string => {
7777
return v == null ? 'undefined' : v.toString()
7878
}
7979

80+
// Add a formatter for stringifying Errors
81+
debug.formatters.e = (v?: Error): string => {
82+
return v == null ? 'undefined' : v.stack ?? v.message
83+
}
84+
8085
export interface Logger {
8186
(formatter: any, ...args: any[]): void
8287
error(formatter: any, ...args: any[]): void

0 commit comments

Comments
 (0)