Skip to content

Commit

Permalink
Fixed wrong group prefix for error attribute (#45)
Browse files Browse the repository at this point in the history
* added test case

* fixed #44

---------

Co-authored-by: lmittmann <lmittmann@users.noreply.github.com>
  • Loading branch information
lmittmann and lmittmann committed Oct 3, 2023
1 parent ccda5f8 commit 0c0d0cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,9 @@ func (h *handler) appendValue(buf *buffer, v slog.Value, quote bool) {
}
}

func (h *handler) appendTintError(buf *buffer, err error, groups string) {
func (h *handler) appendTintError(buf *buffer, err error, groupsPrefix string) {
buf.WriteStringIf(!h.noColor, ansiBrightRedFaint)
appendString(buf, h.groupPrefix+groups+errKey, true)
appendString(buf, groupsPrefix+errKey, true)
buf.WriteByte('=')
buf.WriteStringIf(!h.noColor, ansiResetFaint)
appendString(buf, err.Error(), true)
Expand Down
7 changes: 7 additions & 0 deletions handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,13 @@ func TestHandler(t *testing.T) {
},
Want: `Nov 10 23:00:00.000 INF tint/handler_test.go:326 test`,
},
{ // https://github.com/lmittmann/tint/issues/44
F: func(l *slog.Logger) {
l = l.WithGroup("group")
l.Error("test", tint.Err(errTest))
},
Want: `Nov 10 23:00:00.000 ERR test group.err=fail`,
},
}

for i, test := range tests {
Expand Down

0 comments on commit 0c0d0cf

Please sign in to comment.