fix: ANSI color codes being printed on Windows (#1225)

* added go-colorable

* fixed bug which prevented windows builds
This commit is contained in:
Kwitsch 2023-11-08 00:29:53 +01:00 committed by GitHub
parent 23ce44d457
commit d87e6b4157
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

2
go.mod
View File

@ -15,7 +15,7 @@ require (
github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/golang-lru v1.0.2
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-colorable v0.1.13
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/miekg/dns v1.1.56
github.com/mroth/weightedrand/v2 v2.1.0

View File

@ -8,6 +8,7 @@ import (
"strings"
"sync"
"github.com/mattn/go-colorable"
"github.com/sirupsen/logrus"
prefixed "github.com/x-cray/logrus-prefixed-formatter"
"golang.org/x/exp/maps"
@ -111,6 +112,9 @@ func ConfigureLogger(cfg *Config) {
logger.SetFormatter(logFormatter)
// Windows does not support ANSI colors
logger.SetOutput(colorable.NewColorableStdout())
case FormatTypeJson:
logger.SetFormatter(&logrus.JSONFormatter{})
}

View File

@ -1,4 +1,6 @@
package server
func registerPrintConfigurationTrigger(s *Server) {
import "context"
func registerPrintConfigurationTrigger(ctx context.Context, s *Server) {
}