Home

Handler samber/slog-zap

Handlers
Bench Tests
Verify Tests
Summary Links

samber/slog-zap is a wrapper around the pre-existing uber-go/zap logging library.

samber/slog-zap
uber-go/zap

Benchmark Data

Score: 54.33
Benchmark Runs Ns/Op Allocs/Op Bytes/Op MB/Sec Score
Attributes 231,032 5,756.00 47 6,646 67.58 50.77
Big Group 2,034 594,119.00 8,236 440,998 43.86 15.19
Disabled 322,795,513 3.72 0 0 0.00 96.86
Key Values 200,066 5,887.00 47 6,646 66.07 50.62
Logging 10,000 101,970.00 1,020 121,340 81.32 61.36
Simple 2,544,134 467.50 2 336 156.15 86.65
Simple Source 1,673,392 714.50 5 592 149.76 90.19
With Attrs Attributes 124,971 9,936.00 69 12,454 61.19 43.58
With Attrs Key Values 122,162 9,978.00 69 12,453 60.93 43.62
With Attrs Simple 232,490 5,080.00 42 5,540 82.88 51.76
With Group Attributes 113,708 10,878.00 128 12,632 34.75 30.44
With Group Key Values 110,640 10,803.00 128 12,633 34.99 30.85

Benchmark Charts

samber/slog-zap Ns/Op samber/slog-zap Allocs/Op
samber/slog-zap Bytes/Op samber/slog-zap GB/Sec

Warnings

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

Verify: Attributes Empty

Verify: Attributes With Empty

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

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

unexpected key ""
a Handler should ignore an empty Attr

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

"k"
got "

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

"k"
got "

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

ZeroPC SourceKey logged for zero PC
Verify: Zero PC

non-standard key 'caller'

ZeroTime Zero time is logged
Verify: Zero Time

2024-05-19T01:15:07Z

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

too many attributes: 4

time field still exists

msg field still exists

source ==

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

tests/benchmarks.go:96

Verify: Source Key

reflect/value.go:596

Suggested
DurationSeconds slog.Duration() logs seconds instead of nanoseconds
Verify: Log Attributes

GroupDuration
Verify: Group Duration

29002.000000 != 29002000000000.000000

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

2024-05-19T01:15:07Z