lmittmann / tint

🌈 slog.Handler that writes tinted (colorized) logs

Home Page:https://pkg.go.dev/github.com/lmittmann/tint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ignored group values

mdigger opened this issue · comments

slog.Group("rpc", slog.String("request", "test"))

5:33PM INF call rpc= duration=161.792µs req=

I tried looking into this (https://github.com/FabianTe/tint/commits/feat/grouped-attrs).

Adding support for grouped values seems to require adding some logic to handler.appendAttr. Have a look at the implementation of the text handler (here and here)

The implementation makes use of a handleState type which is not present int tint.

@lmittmann what do you think? I guess it could be useful to adopt handleState?

As an alternative to handleState, take a look at withsupport in jba's slog extras repository.

I'm using that as an internal package in a handler that I'm currently writing, and it works well.

@lmittmann Nice! I have to admin I am a bit amazed about your simple solution 👍🏻