mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
fix: change zerolog to no color in windows
Change-Id: Ibb5d19debec13af0cb67e08387746df4084bbbaf
This commit is contained in:
@@ -2,6 +2,7 @@ package cmd
|
||||
|
||||
import (
|
||||
"os"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
@@ -31,8 +32,12 @@ Website: https://httprunner.com
|
||||
Github: https://github.com/httprunner/hrp
|
||||
Copyright 2021 debugtalk`,
|
||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||
var noColor = false
|
||||
if runtime.GOOS == "windows" {
|
||||
noColor = true
|
||||
}
|
||||
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.")
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user