Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions json.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@ func (l *Logger) jsonFormatterItem(jw *jsonWriter, key, value any) {
func (l *Logger) writeSlogValue(jw *jsonWriter, v slogValue) {
switch v.Kind() {
case slogKindGroup:
d := jw.d
jw.start()
for _, attr := range v.Group() {
l.jsonFormatterItem(jw, attr.Key, attr.Value)
}
jw.end()
jw.d = d
default:
a := v.Any()
_, jm := a.(json.Marshaler)
Expand Down
8 changes: 8 additions & 0 deletions logger_121_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,14 @@ func TestSlogAttr(t *testing.T) {
)},
},
},
{
name: "log valuer empty group",
expected: `{"level":"info","msg":"message","lv":{},"k":"v"}` + "\n",
kvs: []any{
"lv", testLogValue{slog.GroupValue()},
"k", "v",
},
},
}

for _, c := range cases {
Expand Down