mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-19 08:09:51 +00:00
fix: slog error log serialization (#1276)
This commit is contained in:
parent
2553137395
commit
a16554d445
1 changed files with 12 additions and 2 deletions
|
|
@ -66,12 +66,22 @@ func (h *APILogHandler) Handle(ctx context.Context, r slog.Record) error {
|
|||
|
||||
h.mu.Lock()
|
||||
for _, attr := range h.attrs {
|
||||
extra[attr.Key] = attr.Value.Any()
|
||||
val := attr.Value.Any()
|
||||
if err, ok := val.(error); ok {
|
||||
extra[attr.Key] = err.Error()
|
||||
} else {
|
||||
extra[attr.Key] = val
|
||||
}
|
||||
}
|
||||
h.mu.Unlock()
|
||||
|
||||
r.Attrs(func(attr slog.Attr) bool {
|
||||
extra[attr.Key] = attr.Value.Any()
|
||||
val := attr.Value.Any()
|
||||
if err, ok := val.(error); ok {
|
||||
extra[attr.Key] = err.Error()
|
||||
} else {
|
||||
extra[attr.Key] = val
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue