Skip to content

Commit

Permalink
Fixed struct attribute name output (#57)
Browse files Browse the repository at this point in the history
* added field name test case

* fixed field name output

---------

Co-authored-by: lmittmann <lmittmann@users.noreply.github.com>
  • Loading branch information
lmittmann and lmittmann committed Jan 18, 2024
1 parent 2027ee7 commit 88f9530
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ func (h *handler) appendValue(buf *buffer, v slog.Value, quote bool) {
case *slog.Source:
h.appendSource(buf, cv)
default:
appendString(buf, fmt.Sprint(v.Any()), quote)
appendString(buf, fmt.Sprintf("%+v", v.Any()), quote)
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,15 @@ func TestHandler(t *testing.T) {
},
Want: `Nov 10 23:00:00.000 ERR test group.err=fail`,
},
{ // https://github.com/lmittmann/tint/issues/55
F: func(l *slog.Logger) {
l.Info("test", "key", struct {
A int
B *string
}{A: 123})
},
Want: `Nov 10 23:00:00.000 INF test key="{A:123 B:<nil>}"`,
},
}

for i, test := range tests {
Expand Down

0 comments on commit 88f9530

Please sign in to comment.