Skip to content

Commit

Permalink
force log color on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
boqiu committed May 23, 2024
1 parent ee471be commit 49592f3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"runtime"
"strings"
"sync"

Expand Down Expand Up @@ -146,7 +147,11 @@ func BindFlags(cmd *cobra.Command) {
cmd.PersistentFlags().String("log-level", "info", "The logging level (trace|debug|info|warn|error|fatal|panic)")
viper.BindPFlag("log.level", cmd.Flag("log-level"))

cmd.PersistentFlags().Bool("log-force-color", false, "Force colored logs")
var defaultLogForceColor bool
if runtime.GOOS == "windows" {
defaultLogForceColor = true
}
cmd.PersistentFlags().Bool("log-force-color", defaultLogForceColor, "Force colored logs")
viper.BindPFlag("log.forceColor", cmd.Flag("log-force-color"))

cmd.PersistentFlags().Bool("log-disable-color", false, "Disable colored logs")
Expand Down

0 comments on commit 49592f3

Please sign in to comment.