Skip to content

Commit

Permalink
feat: add %e error formatter (#2726)
Browse files Browse the repository at this point in the history
Try to log the stack trace, if it's not available use the message
  • Loading branch information
achingbrain authored Sep 25, 2024
1 parent 9800384 commit c5988cc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/logger/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ debug.formatters.a = (v?: Multiaddr): string => {
return v == null ? 'undefined' : v.toString()
}

// Add a formatter for stringifying Errors
debug.formatters.e = (v?: Error): string => {
return v == null ? 'undefined' : v.stack ?? v.message
}

export interface Logger {
(formatter: any, ...args: any[]): void
error(formatter: any, ...args: any[]): void
Expand Down

0 comments on commit c5988cc

Please sign in to comment.