diff --git a/cmd/akash/cmd/root.go b/cmd/akash/cmd/root.go index 45b522c633..fdc8da4dca 100644 --- a/cmd/akash/cmd/root.go +++ b/cmd/akash/cmd/root.go @@ -95,6 +95,7 @@ func Execute(rootCmd *cobra.Command, envPrefix string) error { rootCmd.PersistentFlags().String(flags.FlagLogLevel, zerolog.InfoLevel.String(), "The logging level (trace|debug|info|warn|error|fatal|panic)") rootCmd.PersistentFlags().String(flags.FlagLogFormat, tmcfg.LogFormatPlain, "The logging format (json|plain)") + rootCmd.PersistentFlags().Bool(utilcli.FlagLogColor, false, "Pretty logging output. Applied only when log_format=plain") executor := tmcli.PrepareBaseCmd(rootCmd, envPrefix, app.DefaultHome) return executor.ExecuteContext(ctx) diff --git a/util/cli/configs.go b/util/cli/configs.go index fb3b977d97..f955606ede 100644 --- a/util/cli/configs.go +++ b/util/cli/configs.go @@ -9,14 +9,20 @@ import ( "strings" "time" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/server" - "github.com/cosmos/cosmos-sdk/server/config" "github.com/rs/zerolog" "github.com/spf13/cobra" "github.com/spf13/pflag" "github.com/spf13/viper" + tmcfg "github.com/tendermint/tendermint/config" + + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/server" + "github.com/cosmos/cosmos-sdk/server/config" +) + +const ( + FlagLogColor = "log_color" ) var ( @@ -67,9 +73,13 @@ func InterceptConfigsPreRunHandler(cmd *cobra.Command, envPrefixes []string, all var logWriter io.Writer if strings.ToLower(serverCtx.Viper.GetString(flags.FlagLogFormat)) == tmcfg.LogFormatPlain { - logWriter = zerolog.ConsoleWriter{Out: os.Stderr} + if serverCtx.Viper.GetBool(FlagLogColor) { + logWriter = zerolog.ConsoleWriter{Out: os.Stdout} + } else { + logWriter = zerolog.New(os.Stdout) + } } else { - logWriter = os.Stderr + logWriter = os.Stdout } logLvlStr := serverCtx.Viper.GetString(flags.FlagLogLevel)