Skip to content

Commit 88f9530

Browse files
authored
Fixed struct attribute name output (#57)
* added field name test case * fixed field name output --------- Co-authored-by: lmittmann <lmittmann@users.noreply.github.com>
1 parent 2027ee7 commit 88f9530

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ func (h *handler) appendValue(buf *buffer, v slog.Value, quote bool) {
390390
case *slog.Source:
391391
h.appendSource(buf, cv)
392392
default:
393-
appendString(buf, fmt.Sprint(v.Any()), quote)
393+
appendString(buf, fmt.Sprintf("%+v", v.Any()), quote)
394394
}
395395
}
396396
}

handler_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,15 @@ func TestHandler(t *testing.T) {
335335
},
336336
Want: `Nov 10 23:00:00.000 ERR test group.err=fail`,
337337
},
338+
{ // https://github.com/lmittmann/tint/issues/55
339+
F: func(l *slog.Logger) {
340+
l.Info("test", "key", struct {
341+
A int
342+
B *string
343+
}{A: 123})
344+
},
345+
Want: `Nov 10 23:00:00.000 INF test key="{A:123 B:<nil>}"`,
346+
},
338347
}
339348

340349
for i, test := range tests {

0 commit comments

Comments
 (0)