Skip to content

Commit

Permalink
fix: should disable color when logging to a file
Browse files Browse the repository at this point in the history
  • Loading branch information
we11adam committed May 20, 2024
1 parent f332ea1 commit c366d25
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/go-resty/resty/v2 v2.12.0
github.com/joho/godotenv v1.5.1
github.com/lmittmann/tint v1.0.4
github.com/mattn/go-isatty v0.0.20
github.com/spf13/viper v1.18.2
)

Expand All @@ -18,7 +19,6 @@ require (
github.com/hashicorp/go-retryablehttp v0.7.5 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
Expand Down
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
_ "github.com/joho/godotenv/autoload"
"github.com/lmittmann/tint"
"github.com/mattn/go-isatty"
"github.com/spf13/viper"
"github.com/we11adam/uddns/app"
"github.com/we11adam/uddns/notifier"
Expand All @@ -22,7 +23,8 @@ import (

func init() {
slog.SetDefault(slog.New(
tint.NewHandler(os.Stderr, &tint.Options{
tint.NewHandler(os.Stdout, &tint.Options{
NoColor: !isatty.IsTerminal(os.Stdout.Fd()),
Level: slog.LevelDebug,
TimeFormat: time.DateTime,
}),
Expand Down

0 comments on commit c366d25

Please sign in to comment.