No color output in redirect

This commit is contained in:
tiltowait
2025-10-26 19:28:13 -07:00
parent 31399fd58c
commit 01bea14edb
4 changed files with 17 additions and 5 deletions

View File

@ -13,6 +13,7 @@ import (
"github.com/lmittmann/tint"
"github.com/spf13/cobra"
"golang.org/x/term"
"faceclaimer/checks"
"faceclaimer/routes"
@ -85,9 +86,13 @@ func init() {
// initLogger configures slog.
func initLogger() {
// Detect if stderr is a terminal
noColor := !term.IsTerminal(int(os.Stderr.Fd()))
handler := tint.NewHandler(os.Stderr, &tint.Options{
Level: slog.LevelInfo,
TimeFormat: time.DateTime,
NoColor: noColor,
})
logger := slog.New(handler)
slog.SetDefault(logger)

14
go.mod
View File

@ -2,15 +2,22 @@ module faceclaimer
go 1.24.7
require (
github.com/gen2brain/webp v0.5.5
github.com/gin-gonic/gin v1.11.0
github.com/lmittmann/tint v1.1.2
github.com/spf13/cobra v1.10.1
go.mongodb.org/mongo-driver v1.17.4
golang.org/x/term v0.33.0
)
require (
github.com/bytedance/sonic v1.14.0 // indirect
github.com/bytedance/sonic/loader v0.3.0 // indirect
github.com/cloudwego/base64x v0.1.6 // indirect
github.com/ebitengine/purego v0.8.3 // indirect
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
github.com/gen2brain/webp v0.5.5 // indirect
github.com/gin-contrib/sse v1.1.0 // indirect
github.com/gin-gonic/gin v1.11.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.27.0 // indirect
@ -20,19 +27,16 @@ require (
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/lmittmann/tint v1.1.2 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/quic-go/qpack v0.5.1 // indirect
github.com/quic-go/quic-go v0.54.0 // indirect
github.com/spf13/cobra v1.10.1 // indirect
github.com/spf13/pflag v1.0.9 // indirect
github.com/tetratelabs/wazero v1.9.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.3.0 // indirect
go.mongodb.org/mongo-driver v1.17.4 // indirect
go.uber.org/mock v0.5.0 // indirect
golang.org/x/arch v0.20.0 // indirect
golang.org/x/crypto v0.40.0 // indirect

2
go.sum
View File

@ -86,6 +86,8 @@ golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/term v0.33.0 h1:NuFncQrRcaRvVmgRkvM3j/F00gWIAlcmlB8ACEKmGIg=
golang.org/x/term v0.33.0/go.mod h1:s18+ql9tYWp1IfpV9DmCtQDDSRBUjKaw9M1eAv5UeF0=
golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4=
golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU=
golang.org/x/tools v0.34.0 h1:qIpSLOxeCYGg9TrcJokLBG4KFA6d795g0xkBkiESGlo=

View File

@ -30,6 +30,7 @@ type UploadRequest struct {
ImageURL string `json:"image_url"`
}
// setupRouter sets up gin's route handlers.
func setupRouter(cfg *Config) *gin.Engine {
r := gin.Default()
r.SetTrustedProxies(nil)