mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-04 23:16:57 +08:00
fix: change zerolog to no color in windows
Change-Id: Ibb5d19debec13af0cb67e08387746df4084bbbaf
This commit is contained in:
+6
-1
@@ -2,6 +2,7 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
@@ -31,8 +32,12 @@ Website: https://httprunner.com
|
|||||||
Github: https://github.com/httprunner/hrp
|
Github: https://github.com/httprunner/hrp
|
||||||
Copyright 2021 debugtalk`,
|
Copyright 2021 debugtalk`,
|
||||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||||
|
var noColor = false
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
noColor = true
|
||||||
|
}
|
||||||
if !logJSON {
|
if !logJSON {
|
||||||
log.Logger = zerolog.New(zerolog.ConsoleWriter{Out: os.Stderr}).With().Timestamp().Logger()
|
log.Logger = zerolog.New(zerolog.ConsoleWriter{NoColor: noColor, Out: os.Stderr}).With().Timestamp().Logger()
|
||||||
log.Info().Msg("Set log to color console other than JSON format.")
|
log.Info().Msg("Set log to color console other than JSON format.")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user