{
"group": {
"hidden": {},
"pi": 3.141592653589793
},
"level": "info",
"msg": "This is a message",
"time": "2024-05-19T01:15:07Z"
}
Verify:
Resolve Group With
{
"group": {
"hidden": {},
"pi": 3.141592653589793
},
"level": "info",
"msg": "This is a message",
"time": "2024-05-19T01:15:07Z"
}
Verify:
Resolve Valuer
{
"hidden": {},
"level": "info",
"msg": "This is a message",
"time": "2024-05-19T01:15:07Z"
}
Verify:
Resolve With
{
"hidden": {},
"level": "info",
"msg": "This is a message",
"time": "2024-05-19T01:15:07Z"
}
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.
The slog.Record.PC field can be loaded with a program counter (PC).
This is normally done by the slog.Logger code.
If the PC is non-zero and the slog.HandlerOptions.AddSource flag is set
the source field will contain a slog.Source record
containing the function name, file name, and file line at which the log record was generated.
If the PC is zero then this field and its associated group should not be logged.
{
"level": "info",
"msg": "This is a message",
"time": "2024-05-19T01:15:07Z"
}
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": "2024-05-19T01:15:07Z"
}
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.