-
Notifications
You must be signed in to change notification settings - Fork 11
Add slog compatibility #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c729dda
b4feed7
e398330
7332cd0
253e34c
99bec3d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,7 @@ package errtrace | |
| import ( | ||
| "fmt" | ||
| "io" | ||
| "log/slog" | ||
| "strings" | ||
| ) | ||
|
|
||
|
|
@@ -123,6 +124,11 @@ func (e *errTrace) Format(s fmt.State, verb rune) { | |
| fmt.Fprintf(s, fmt.FormatString(s, verb), e.err) | ||
| } | ||
|
|
||
| // LogValue implements the [slog.LogValuer] interface. | ||
| func (e *errTrace) LogValue() slog.Value { | ||
| return slog.StringValue(FormatString(e)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no changes needed, but wanted to consider whether this should return a string value, or a group with multiple fields for message, trace, etc. I think a string makes sense to start, and allows callers to choose how they want the error encoded, e.g., in their equivalent of the |
||
| } | ||
|
|
||
| // TracePC returns the program counter for the location | ||
| // in the frame that the error originated with. | ||
| // | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like this changelog entry was left behind after the LogAttr func was removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We realized this after merging too, and fixed it in #126.
Thanks for catching either way!