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

Benchmark Runs Ns/Op Allocs/Op Bytes/Op MB/Sec
Attributes 210,345 6,138.00 50 7,223 63.38
Big Group 4,429 270,907.00 4,001 252,209 38.85
Disabled 319,758,386 3.75 0 0 0.00
Key Values 186,898 6,201.00 50 7,224 62.73
Logging 10,000 114,341.00 1,071 131,958 72.52
Simple 2,526,602 475.20 2 336 153.63
Simple Source 1,643,460 735.10 5 592 145.55
With Attrs Attributes 109,345 12,163.00 78 14,983 49.99
With Attrs Key Values 106,971 11,254.00 78 14,985 54.03
With Attrs Simple 205,501 5,922.00 49 6,983 71.08
With Group Attributes 101,349 11,621.00 142 13,737 32.44
With Group Key Values 102,225 11,496.00 142 13,737 32.79

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

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

2025-02-16T01:41:19Z

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

'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