diff --git a/README.md b/README.md index e354fe4..41524ca 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ `devslog` is zero dependency custom logging handler for Go's standard [`log/slog`](https://pkg.go.dev/log/slog) package that provides structured logging with colorful and indented structure for developing. ### Develop with this output -![image](https://github.com/golang-cz/devslog/assets/17728576/be0eca2c-192b-442f-b3c0-eecef107871a) +![image](https://github.com/golang-cz/devslog/assets/17728576/0bae7ec7-0513-41a4-9682-0e0fc74747e7) ### Instead of these outputs `TextHandler` diff --git a/devslog.go b/devslog.go index 0b8912a..a75c384 100644 --- a/devslog.go +++ b/devslog.go @@ -233,6 +233,13 @@ func (h *developHandler) colorize(buf []byte, as attributes, level int, groups [ val = cs(val, fgCyan) case slog.KindAny: a := a.Value.Any() + err, isError := a.(error) + if isError { + mark = cs("E", fgRed) + val = csb(fmt.Sprintf(" %v ", err), fgBlack, bgRed) + break + } + jsonBytes, err := json.Marshal(a) if err != nil { break