Skip to content

Commit

Permalink
Return string attr for unrecognized kind
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Mar 12, 2024
1 parent 2e13353 commit 9ce4320
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion bridges/sloghandler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,13 @@ func convertValue(v slog.Value) log.Value {
case slog.KindLogValuer:
return convertValue(v.Resolve())
default:

Check warning on line 357 in bridges/sloghandler/handler.go

View check run for this annotation

Codecov / codecov/patch

bridges/sloghandler/handler.go#L357

Added line #L357 was not covered by tests
panic(fmt.Sprintf("unhandled attribute kind: %s", v.Kind()))
// Try to handle this as gracefully as possible.
//
// Don't panic here. The goal here is to have developers find this
// first if a new slog.Kind is added. A test on the new kind will find
// this malformed attribute as well as a panic. However, it is
// preferable to have user's open issue asking why their attributes
// have a "unhandled: " prefix than say that their code is panicking.
return log.StringValue(fmt.Sprintf("unhandled: %+v", v.Any()))

Check warning on line 365 in bridges/sloghandler/handler.go

View check run for this annotation

Codecov / codecov/patch

bridges/sloghandler/handler.go#L365

Added line #L365 was not covered by tests
}
}

0 comments on commit 9ce4320

Please sign in to comment.