feat: colorize log output (#195)

Makes it easier to read, uses lmittmann/tint.
This commit is contained in:
Julian Tölle 2025-06-14 15:11:28 +02:00 committed by GitHub
parent 50b2762dca
commit eae0045359
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 3 deletions

View file

@ -4,7 +4,9 @@ import (
"log/slog"
"os"
"runtime/debug"
"time"
"github.com/lmittmann/tint"
"github.com/spf13/cobra"
)
@ -46,8 +48,12 @@ func Execute() {
}
func init() {
logger = slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{
logger = slog.New(
tint.NewHandler(os.Stderr, &tint.Options{
Level: slog.LevelDebug,
}))
TimeFormat: time.RFC3339,
}),
)
slog.SetDefault(logger)
}

1
go.mod
View file

@ -10,6 +10,7 @@ require (
github.com/go-git/go-git/v5 v5.16.2
github.com/google/go-github/v72 v72.0.0
github.com/leodido/go-conventionalcommits v0.12.0
github.com/lmittmann/tint v1.1.2
github.com/spf13/cobra v1.9.1
github.com/stretchr/testify v1.10.0
github.com/teekennedy/goldmark-markdown v0.5.1

2
go.sum
View file

@ -65,6 +65,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leodido/go-conventionalcommits v0.12.0 h1:pG01rl8Ze+mxnSSVB2wPdGASXyyU25EGwLUc0bWrmKc=
github.com/leodido/go-conventionalcommits v0.12.0/go.mod h1:DW+n8pQb5w/c7Vba7iGOMS3rkbPqykVlnrDykGjlsJM=
github.com/lmittmann/tint v1.1.2 h1:2CQzrL6rslrsyjqLDwD11bZ5OpLBPU+g3G/r5LSfS8w=
github.com/lmittmann/tint v1.1.2/go.mod h1:HIS3gSy7qNwGCj+5oRjAutErFBl4BzdQP6cJZ0NfMwE=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=