slog.Duration() logs a string representation instead of nanoseconds
The slog.JSONHandler uses nanoseconds for time.Duration but some other handlers use a string representation.
Svcrunner Jsonlog
8h3m22s
{
"group": {
"inner": "8h3m22s"
},
"level": "INFO",
"message": "This is a message",
"outer": "8h3m22s",
"time": "2025-02-16T01:41:19.49527052Z"
}
GroupDuration
Some handlers that change the way time.Duration objects are logged (see warnings DurationMillis and DurationSeconds)
only manage to make the change at the top level of the logged record, duration objects in groups are still in nanoseconds.
Samber Zap
29002.000000 != 29002000000000.000000
{
"group": {
"inner": 29002000000000
},
"level": "info",
"msg": "This is a message",
"outer": 29002,
"time": "2025-02-16T01:41:19Z"
}
Samber Zerolog
29002000.000000 != 29002000000000.000000
{
"group": {
"inner": 29002000000000
},
"level": "info",
"message": "This is a message",
"outer": 29002000,
"time": "2025-02-16T01:41:19Z"
}