Skip to content

Commit

Permalink
make error attrs red
Browse files Browse the repository at this point in the history
  • Loading branch information
MatusOllah committed May 24, 2024
1 parent 12e79ad commit e027c7b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"path/filepath"
"runtime"
"strconv"
"strings"
"sync"

"github.com/fatih/color"
Expand Down Expand Up @@ -126,7 +127,12 @@ func (h *Handler) Handle(_ context.Context, r slog.Record) error {
fmt.Fprint(&bf, color.New(color.FgCyan).Sprint("."))
}
}
fmt.Fprint(&bf, color.New(color.FgCyan).Sprintf("%s=", a.Key)+a.Value.String())

if strings.Contains(a.Key, "err") {
fmt.Fprint(&bf, color.New(color.FgRed).Sprintf("%s=", a.Key)+a.Value.String())
} else {
fmt.Fprint(&bf, color.New(color.FgCyan).Sprintf("%s=", a.Key)+a.Value.String())
}
}

fmt.Fprint(&bf, "\n")
Expand Down

0 comments on commit e027c7b

Please sign in to comment.