cockroachdb / cockroachdb/errors
Implement slog.LogValuer
- Dominant language
- Go
- Stars
- 2.5k
- Forks
- 74
- PR merge metrics
- No merged PRs in 30d
Description
The new [slog](https://pkg.go.dev/golang.org/x/exp/slog) library provides a `slog.LogValuer` interface for formatting attributes.
Documentation here: https://pkg.go.dev/golang.org/x/exp/slog#hdr-Customizing_a_type_s_logging_behavior
I think cockroachdb/errors should implement it.
```go
type customError struct {
...
}
func (e customError) Error() string {
...
}
// implements slog.LogValuer
func (e customError) LogValue() slog.Value {
return slog.GroupValue(
slog.Int("code", e.code),
slog.String("message", e.msg),
slog.String("stacktrace", e.stacktrace),
)
}
```
`slog` will be released in go 1.21. But is already available and `golang.org/x/exp/slog`
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue names no repository files, tests, or entry points. Start with the linked slog.LogValuer documentation and inspect the repository's existing error-formatting integration; done means errors implement the interface with structured values like code, message, and stacktrace.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- observability-sre
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100