feat(server): cmd flag to disable colored logs (#18478)
This commit is contained in:
parent
c3308d3477
commit
8c7e694117
@ -50,6 +50,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
* (server) [#17094](https://github.com/cosmos/cosmos-sdk/pull/17094) Add duration `shutdown-grace` for resource clean up (closing database handles) before exit.
|
||||
* (x/auth/vesting) [#17810](https://github.com/cosmos/cosmos-sdk/pull/17810) Add the ability to specify a start time for continuous vesting accounts.
|
||||
* (runtime) [#18475](https://github.com/cosmos/cosmos-sdk/pull/18475) Adds an implementation for core.branch.Service.
|
||||
* (server) [#18478](https://github.com/cosmos/cosmos-sdk/pull/18478) CMD flag to disable colored logs.
|
||||
|
||||
### Improvements
|
||||
|
||||
|
||||
@ -86,8 +86,9 @@ const (
|
||||
// This differs from FlagOutputDocument that is used to set the output file.
|
||||
FlagOutput = "output"
|
||||
// Logging flags
|
||||
FlagLogLevel = "log_level"
|
||||
FlagLogFormat = "log_format"
|
||||
FlagLogLevel = "log_level"
|
||||
FlagLogFormat = "log_format"
|
||||
FlagLogNoColor = "log_no_color"
|
||||
)
|
||||
|
||||
// List of supported output formats
|
||||
|
||||
@ -28,6 +28,7 @@ func Execute(rootCmd *cobra.Command, envPrefix, defaultHome string) error {
|
||||
rootCmd.PersistentFlags().String(flags.FlagLogLevel, zerolog.InfoLevel.String(), "The logging level (trace|debug|info|warn|error|fatal|panic|disabled or '*:<level>,<key>:<level>')")
|
||||
// NOTE: The default logger is only checking for the "json" value, any other value will default to plain text.
|
||||
rootCmd.PersistentFlags().String(flags.FlagLogFormat, "plain", "The logging format (json|plain)")
|
||||
rootCmd.PersistentFlags().Bool(flags.FlagLogNoColor, false, "Disable colored logs")
|
||||
|
||||
executor := cmtcli.PrepareBaseCmd(rootCmd, envPrefix, defaultHome)
|
||||
return executor.ExecuteContext(ctx)
|
||||
|
||||
@ -173,6 +173,10 @@ func CreateSDKLogger(ctx *Context, out io.Writer) (log.Logger, error) {
|
||||
if ctx.Viper.GetString(flags.FlagLogFormat) == flags.OutputFormatJSON {
|
||||
opts = append(opts, log.OutputJSONOption())
|
||||
}
|
||||
opts = append(opts,
|
||||
log.ColorOption(!ctx.Viper.GetBool(flags.FlagLogNoColor)),
|
||||
// We use CometBFT flag (cmtcli.TraceFlag) for trace logging.
|
||||
log.TraceOption(ctx.Viper.GetBool(FlagTrace)))
|
||||
|
||||
// check and set filter level or keys for the logger if any
|
||||
logLvlStr := ctx.Viper.GetString(flags.FlagLogLevel)
|
||||
@ -194,9 +198,6 @@ func CreateSDKLogger(ctx *Context, out io.Writer) (log.Logger, error) {
|
||||
opts = append(opts, log.LevelOption(logLvl))
|
||||
}
|
||||
|
||||
// Check if the CometBFT flag for trace logging is set and enable stack traces if so.
|
||||
opts = append(opts, log.TraceOption(ctx.Viper.GetBool("trace"))) // cmtcli.TraceFlag
|
||||
|
||||
return log.NewLogger(out, opts...), nil
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user