diff --git a/go.mod b/go.mod index c12c051..1da3b2d 100644 --- a/go.mod +++ b/go.mod @@ -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 ) @@ -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 diff --git a/main.go b/main.go index e59ea48..db09554 100644 --- a/main.go +++ b/main.go @@ -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" @@ -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, }),