{
"group": {
"hidden": {},
"pi": 3.141592653589793
},
"level": "info",
"msg": "This is a message",
"time": "2025-02-16T01:41:19Z"
}
Verify:
Resolve Group With
{
"group": {
"hidden": {},
"pi": 3.141592653589793
},
"level": "info",
"msg": "This is a message",
"time": "2025-02-16T01:41:19Z"
}
Verify:
Resolve Valuer
{
"hidden": {},
"level": "info",
"msg": "This is a message",
"time": "2025-02-16T01:41:19Z"
}
Verify:
Resolve With
{
"hidden": {},
"level": "info",
"msg": "This is a message",
"time": "2025-02-16T01:41:19Z"
}
SlogTest
Failure of embedded slog/slogtest
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.
{
"level": "info",
"msg": "This is a message",
"time": "2025-02-16T01:41:19Z"
}
Implied
NoReplAttrBasic
HandlerOptions.ReplaceAttr not available for basic fields
Some handlers (e.g. phsym/zeroslog) support
HandlerOptions.ReplaceAttr
except for the four main fields time, level, msg, and source.
When that is the case it is better to use this (WarnNoReplAttrBasic) warning.
{
"group": {
"alpha": "OMEGA",
"pi": 3.141592653589793,
"subGroup": {
"e": 2.718281828459045,
"goober": "snoofus",
"la la la": "omega",
"oneMore": {
"alpha": "omega",
"gibbering": "moontic",
"phi": 1.618033988749895
}
}
},
"level": "info",
"msg": "This is a message",
"time": "2025-02-16T01:41:19Z"
}
Verify:
Replace Attr Fn Remove Empty Key
Verify:
Replace Attr Fn Remove Time
time value not empty string
Suggested
LevelCase
Log level in lowercase
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
'debug'
Verify:
Key Case
'info'
Verify:
Key Case
'error'
Verify:
Keys
'info'
Verify:
Source Key
'info'
Verify:
Zero PC
'info'
Verify:
Zero Time
'info'
LevelWrong
Log level is incorrect
The log level name is not what was expected (e.g. "WARNING" instead of "WARN").
This is different from the LevelCase warning which is from the right level name but the wrong character case.
Verify:
Key Case
should be 'WARN', not 'warning'
NoEmptyName
Attributes with empty names are not logged
Until documented otherwise, an attribute with an empty field name ("") and a non-nil value should be logged.
{
"first": "one",
"level": "info",
"msg": "This is a message",
"pi": 3.141592653589793,
"time": "2025-02-16T01:41:19Z"
}
Verify:
Attribute With Empty Name
{
"first": "one",
"level": "info",
"msg": "This is a message",
"pi": 3.141592653589793,
"time": "2025-02-16T01:41:19Z"
}
Verify:
Attributes Not Empty
{
"first": "one",
"level": "info",
"msg": "This is a message",
"pi": 3.141592653589793,
"time": "2025-02-16T01:41:19Z"
}
Verify:
Attributes With Not Empty
{
"first": "one",
"level": "info",
"msg": "This is a message",
"pi": 3.141592653589793,
"second": 2,
"time": "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.