Home

Handler samber/slog-zerolog

Handlers
Bench Tests
Verify Tests
Summary Links

samber/slog-zerolog is a wrapper around the pre-existing rs/zerolog logging library.

rs/zerolog
samber/slog-zerolog

Benchmark Data

Benchmark Runs Ns/Op Allocs/Op Bytes/Op MB/Sec
Attributes 216,938 5,288.00 60 5,582 74.89
Big Group 4,422 275,299.00 4,001 263,418 38.25
Disabled 320,353,143 3.75 0 0 0.00
Key Values 221,190 5,371.00 60 5,582 73.73
Logging 14,112 86,631.00 1,173 91,033 98.07
Simple 3,217,803 382.30 2 336 201.42
Simple Source 476,286 2,564.00 39 2,763 105.71
With Attrs Attributes 124,011 9,302.00 95 11,308 66.44
With Attrs Key Values 124,344 9,640.00 95 11,307 64.11
With Attrs Simple 239,511 5,049.00 59 5,342 84.77
With Group Attributes 100,422 11,401.00 144 13,961 33.42
With Group Key Values 104,217 11,509.00 144 13,961 33.11

Check box to see charts

Warnings

Required
Resolver LogValuer objects are not resolved
Verify: Resolve Group

Verify: Resolve Group With

Verify: Resolve Valuer

Verify: Resolve With

SlogTest Failure of embedded slog/slogtest
Verify: Slog Test

missing key "msg"
this test expects slog.TimeKey, slog.LevelKey and slog.MessageKey

unexpected key "time"
a Handler should ignore a zero Record.Time

missing key "c"
a Handler should inline the Attrs of a group with an empty key

missing key "msg"
a Handler should handle the WithGroup method

missing key "msg"
a Handler should handle multiple WithGroup and WithAttr calls

missing key "msg"
a Handler should not output groups if there are no attributes

"k"
got map[string]interface {}{}, want "replaced": a Handler should call Resolve on attribute values

"b"
got map[string]interface {}{}, want "v2": a Handler should call Resolve on attribute values in groups

"k"
got map[string]interface {}{}, want "replaced": a Handler should call Resolve on attribute values from WithAttrs

"b"
got map[string]interface {}{}, want "v2": a Handler should call Resolve on attribute values in groups from WithAttrs

ZeroTime Zero time is logged
Verify: Zero Time

0001-01-01T00:00:00Z

Implied
DefaultLevel Handler doesn't default to slog.LevelInfo
Verify: Default Level

defaultlevel is 'DEBUG'

Verify: Default Level

defaultlevel with AddSource is 'DEBUG'

MessageKey Wrong message key (should be 'msg')
Verify: Canceled Context

`message`

Verify: Canceled Context

`message`

Verify: Canceled Context

`message`

Verify: Keys

`message`

Verify: Source Key

`message`

Verify: Zero PC

`message`

Verify: Zero Time

`message`

NoReplAttrBasic HandlerOptions.ReplaceAttr not available for basic fields
Verify: Replace Attr Basic

too many attributes: 4

time field still exists

message field still exists

source == map[file:/home/runner/work/go-slog/go-slog/verify/tests/replace.go function:github.com/madkins23/go-slog/verify/tests.(*SlogTestSuite).TestReplaceAttrBasic line:89]

Verify: Replace Attr Fn Change Key

too few attributes: 3

no message key

message not string

Verify: Replace Attr Fn Level Case

level value not null

Verify: Replace Attr Fn Multi

Verify: Replace Attr Fn Remove Empty Key

Verify: Replace Attr Fn Remove Time

time value not empty string

Suggested
DurationMillis slog.Duration() logs milliseconds instead of nanoseconds
Verify: Log Attributes

GroupDuration
Verify: Group Duration

29002000.000000 != 29002000000000.000000

LevelCase Log level in lowercase
Verify: Canceled Context

'info'

Verify: Canceled Context

'info'

Verify: Canceled Context

'info'

Verify: Key Case

'debug'

Verify: Key Case

'info'

Verify: Key Case

'warn'

Verify: Key Case

'error'

Verify: Keys

'info'

Verify: Source Key

'info'

Verify: Zero PC

'info'

Verify: Zero Time

'info'

NoEmptyName Attributes with empty names are not logged
Verify: Attribute Empty Name

Verify: Attribute With Empty Name

Verify: Attributes Not Empty

Verify: Attributes With Not Empty

TimeMillis slog.Time() logs milliseconds instead of nanoseconds
Verify: Log Attributes

2025-02-16T01:41:19Z

Administrative
Unused Unused Warnings(s)
Verify: Group Inline

GroupInline

Verify: With Group Inline

GroupInline

Verify: Zero PC

ZeroPC