rs / zerolog

Zero Allocation JSON Logger
MIT License
10.33k stars 564 forks source link

Resolve panic in the console writer for short `level` field values #665

Closed ndk closed 4 months ago

ndk commented 4 months ago

This PR fixes an issue in the zerolog console writer. Specifying a non-typical value for the level field, resulting in a serialized value of less than 3 bytes, causes a panic. For instance:

log := zerolog.New(zerolog.NewConsoleWriter())
log.Debug().Str("level", "-").Msg("Hello World")