Skip to content

Commit

Permalink
fix: only tint the output if running in a terminal
Browse files Browse the repository at this point in the history
This should keep logfiles, Jenkins output, etc., readable

style: drop the log message for a cache hit from WARN to INFO.

Fixes: Issue #75
  • Loading branch information
nisimond authored and retr0h committed Dec 27, 2023
1 parent 964ca66 commit c9f7195
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/lmittmann/tint"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"golang.org/x/term"

"github.com/retr0h/go-gilt/pkg"
"github.com/retr0h/go-gilt/pkg/config"
Expand Down Expand Up @@ -92,6 +93,7 @@ func initLogger() {
tint.NewHandler(os.Stderr, &tint.Options{
Level: logLevel,
TimeFormat: time.Kitchen,
NoColor: !term.IsTerminal(int(os.Stdout.Fd())),
}),
)
}
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/spf13/viper v1.18.2
github.com/stretchr/testify v1.8.4
go.hein.dev/go-version v0.1.0
golang.org/x/term v0.15.0
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4=
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
Expand Down
2 changes: 1 addition & 1 deletion internal/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (r *Repository) Clone(
return targetDir, err
}
} else {
r.logger.Warn("clone already exists", slog.String("dstDir", targetDir))
r.logger.Info("clone already exists", slog.String("dstDir", targetDir))
}

return targetDir, nil
Expand Down

0 comments on commit c9f7195

Please sign in to comment.