Skip to content

Commit

Permalink
feat: add %e error formatter
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 committed Sep 25, 2024
1 parent fa83ee1 commit 4840bf6
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
}

Check warning on line 83 in packages/logger/src/index.ts

View check run for this annotation

Codecov / codecov/patch

packages/logger/src/index.ts#L82-L83

Added lines #L82 - L83 were not covered by tests

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

0 comments on commit 4840bf6

Please sign in to comment.