charmbracelet / charmbracelet/log
support log/slog.LogValuer
- Dominant language
- Go
- Stars
- 3.4k
- Forks
- 103
- PR merge metrics
- No merged PRs in 30d
Description
current logger didn't support [log/slog.LogValuer](https://pkg.go.dev/log/slog#LogValuer), rather just `a.Value.String()`
should `a.Value.Resolve` to respect interface `LogValuer`
```
// Handle handles the Record. It will only be called if Enabled returns true.
//
// Implements slog.Handler.
func (l *Logger) Handle(_ context.Context, record slog.Record) error {
fields := make([]interface{}, 0, record.NumAttrs()*2)
record.Attrs(func(a slog.Attr) bool {
fields = append(fields, a.Key, a.Value.String()) <- a.Value.String()
return true
})
```
Contributor guide
Research direction
Start at Logger.Handle, where record attributes are converted into fields and the issue identifies the current value handling. Check how slog.Value.Resolve should be applied for LogValuer support, then add or update coverage for an attribute implementing LogValuer and confirm the logged output uses its resolved value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100