When using tint.Attr in the ReplaceAttr function to color a slog.LevelKey, the color "bleeds" and is applied not only to that attribute but also to slog.SourceKey.
Code to Reproduce
package main
import (
"log/slog"
"os"
"github.com/lmittmann/tint"
)
func main() {
handler := tint.NewHandler(os.Stdout, &tint.Options{
Level: slog.LevelDebug,
AddSource: true,
ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr {
if a.Key == slog.LevelKey {
if lvl, ok := a.Value.Any().(slog.Level); ok && lvl == slog.LevelDebug {
return tint.Attr(13, a) // Expected: only "DBG" should be colored
}
}
return a
},
})
logger := slog.New(handler)
logger.Debug("test message", "key", "value")
}
Expected Behavior
Only the level text ("DBG") should be colored.
Actual Behavior
The color is applied to both the level and the source location (e.g., "DBG issue-folder/test.go:27").