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.
Documentation on building a handler suggests testing using slog/slogtest, part of the Go release since 1.21.
While the verification suite includes tests patterned after those in slogtest,
an additional single test invokes the slogtest testing sequence (involving multiple tests).
Since this is a separate package, all error messages are returned at once.
This is the only warning that affects TestSlogTest and all of its error messages.
If HandlerOptions.ReplaceAttr
is provided it should be honored by the handler.
However, documentation on implementing handler methods seems to suggest it is optional.
Source data logged as 'caller' instead of 'source'
Some handlers return source data as a single string on the caller field
in the format <file>:<line> where <file> and <line> correspond
to the File and Line fields of the source data group and Function is not provided.
{
"caller": "/opt/hostedtoolcache/go/1.22.12/x64/src/reflect/value.go:596",
"level": "info",
"message": "This is a message",
"time": "2025-02-16T01:41:19Z"
}
Suggested
Duplicates
Duplicate field(s) found
Some handlers (e.g. slog.JSONHandler)
will output multiple occurrences of the same field name
if the logger is called with multiple instances of the same field,
generally by using WithAttrs and then the same fields in the eventual log call (e.g. Info).
This behavior is currently under debate
with no resolution at this time (2024-01-15) and a
release milestone of (currently unscheduled) Go 1.23,
(whereas Go Release 1.22
is currently expected in February 2024).
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
The slog.JSONHandler uses nanoseconds for time.Duration but some other handlers use seconds.
Each JSON log record contains the logging level of the log statement as a string.
Different handlers provide that string in uppercase or lowercase.
Documentation for slog.Level
says that its String() and MarshalJSON() methods will return uppercase
but UnmarshalJSON() will parse in a case-insensitive manner.
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
The slog.JSONHandler uses nanoseconds for time.Time but some other handlers use milliseconds.
This does not apply to the basic time field, only attribute fields.
I can't find any supporting documentation or bug on this but
Go issue 59345 (see previous warning)
may have fixed this as well in Go 1.21.
Verify:
Log Attributes
2025-02-16T01:41:19Z
Administrative
Unused
Unused Warnings(s)
If a warning is specified but the condition is not actually present
one of these warnings will be issued with the specified warning.
These are intended to help clean out unnecessary WarnOnly settings
from a test suite as issues are fixed in the tested handler.