Home

Handler phsym/zeroslog

Handlers
Bench Tests
Verify Tests
Summary Links

phsym/zeroslog is a wrapper around the pre-existing rs/zerolog logging library. The phsym/zerolog handler, like the underlying rs/zerolog logging library, is in the fastest ranks of slog.Handler implementations tested.

phsym/zeroslog
rs/zerolog

Benchmark Data

Benchmark Runs Ns/Op Allocs/Op Bytes/Op MB/Sec
Attributes 1,202,805 1,001.00 3 352 395.58
Big Group 76,651 16,221.00 1 48 649.10
Disabled 319,660,309 3.77 0 0 0.00
Key Values 1,000,000 1,035.00 3 352 382.51
Logging 69,572 17,394.00 0 0 488.44
Simple 6,082,543 199.40 0 0 386.17
Simple Source 2,509,022 476.30 4 312 317.01
With Attrs Attributes 1,000,000 1,021.00 3 352 731.43
With Attrs Key Values 996,313 1,042.00 3 352 716.93
With Attrs Simple 5,802,163 209.60 0 0 2,042.39
With Group Attributes 1,000,000 1,148.00 4 640 357.11
With Group Key Values 964,652 1,189.00 4 640 344.75

Check box to see charts

Warnings

Required
EmptyAttributes Empty attribute(s) logged ("":null)
Verify: Attribute With Empty

Verify: Attributes Empty

Verify: Attributes With Empty

GroupEmpty Empty (sub)group(s) logged
Verify: Group With Multi Sub Empty

found 'subGroup' group

GroupInline Group with empty key does not inline subfields
Verify: Group Inline

SlogTest Failure of embedded slog/slogtest
Verify: Slog Test

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

unexpected key ""
a Handler should ignore an empty Attr

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

unexpected key "H"
a Handler should not output groups if there are no attributes

WithGroupEmpty Empty WithGroup() logged
Verify: With Group Empty

too many fields, found field 'group1', value is group, length: 1

Implied
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`

NoReplAttr HandlerOptions.ReplaceAttr not available
Verify: Replace Attr

too many attributes: 6, alpha == beta, change still exists, remove still exists

Verify: Replace Attr Basic

too many attributes: 4

time field still exists

message field still exists

source ==

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

SourceCaller Source data logged as 'caller' instead of 'source'
Bench: Simple Source

/home/runner/work/go-slog/go-slog/bench/tests/benchmarks.go:96

Verify: Source Key

/opt/hostedtoolcache/go/1.22.12/x64/src/reflect/value.go:596

Suggested
Duplicates Duplicate field(s) found
Verify: Attribute Duplicate

map[alpha:2 charlie:3]

Verify: Attribute With Duplicate

map[alpha:2 charlie:3]

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

LevelCase Log level in lowercase
Verify: Canceled Context

'info'

Verify: Canceled Context

'info'

Verify: Canceled Context

'info'

Verify: Key Case

'error'

Verify: Key Case

'debug'

Verify: Key Case

'info'

Verify: Key Case

'warn'

Verify: Keys

'info'

Verify: Source Key

'info'

Verify: Zero PC

'info'

Verify: Zero Time

'info'

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

2025-02-16T01:41:19Z

Administrative
Unused Unused Warnings(s)
Verify: Zero Time

ZeroTime