refactor: remove cometbft/libs/cli import (#15673)
This commit is contained in:
@@ -3,7 +3,6 @@ package cmd
|
||||
import (
|
||||
"context"
|
||||
|
||||
cmtcfg "github.com/cometbft/cometbft/config"
|
||||
cmtcli "github.com/cometbft/cometbft/libs/cli"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -27,7 +26,8 @@ func Execute(rootCmd *cobra.Command, envPrefix, defaultHome string) error {
|
||||
ctx := CreateExecuteContext(context.Background())
|
||||
|
||||
rootCmd.PersistentFlags().String(flags.FlagLogLevel, zerolog.InfoLevel.String(), "The logging level (trace|debug|info|warn|error|fatal|panic)")
|
||||
rootCmd.PersistentFlags().String(flags.FlagLogFormat, cmtcfg.LogFormatPlain, "The logging format (json|plain)")
|
||||
// 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)")
|
||||
|
||||
executor := cmtcli.PrepareBaseCmd(rootCmd, envPrefix, defaultHome)
|
||||
return executor.ExecuteContext(ctx)
|
||||
|
||||
+5
-5
@@ -16,7 +16,6 @@ import (
|
||||
|
||||
cmtcmd "github.com/cometbft/cometbft/cmd/cometbft/commands"
|
||||
cmtcfg "github.com/cometbft/cometbft/config"
|
||||
cmtcli "github.com/cometbft/cometbft/libs/cli"
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/spf13/cast"
|
||||
@@ -170,7 +169,7 @@ func InterceptConfigsAndCreateContext(cmd *cobra.Command, customAppConfigTemplat
|
||||
// It reads the log level and format from the server context.
|
||||
func CreateSDKLogger(ctx *Context, out io.Writer) (log.Logger, error) {
|
||||
var opts []log.Option
|
||||
if ctx.Viper.GetString(flags.FlagLogFormat) == cmtcfg.LogFormatJSON {
|
||||
if ctx.Viper.GetString(flags.FlagLogFormat) == flags.OutputFormatJSON {
|
||||
opts = append(opts, log.OutputJSONOption())
|
||||
}
|
||||
|
||||
@@ -181,7 +180,8 @@ func CreateSDKLogger(ctx *Context, out io.Writer) (log.Logger, error) {
|
||||
}
|
||||
|
||||
logLvl, err := zerolog.ParseLevel(logLvlStr)
|
||||
if err != nil {
|
||||
switch {
|
||||
case err != nil:
|
||||
// If the log level is not a valid zerolog level, then we try to parse it as a key filter.
|
||||
filterFunc, err := log.ParseLogLevel(logLvlStr)
|
||||
if err != nil {
|
||||
@@ -190,11 +190,11 @@ func CreateSDKLogger(ctx *Context, out io.Writer) (log.Logger, error) {
|
||||
|
||||
opts = append(opts, log.FilterOption(filterFunc))
|
||||
|
||||
} else if ctx.Viper.GetBool(cmtcli.TraceFlag) {
|
||||
case ctx.Viper.GetBool("trace"): // cmtcli.TraceFlag
|
||||
// Check if the CometBFT flag for trace logging is set if it is then setup a tracing logger in this app as well.
|
||||
// Note it overrides log level passed in `log_levels`.
|
||||
opts = append(opts, log.LevelOption(zerolog.TraceLevel))
|
||||
} else {
|
||||
default:
|
||||
opts = append(opts, log.LevelOption(logLvl))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user