mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-04 11:02:13 +00:00
fix setting log level
This commit is contained in:
parent
757a548edf
commit
f5b77d50b5
@ -3,13 +3,14 @@ package commands
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
cfg "github.com/tendermint/go-config"
|
||||
"github.com/tendermint/go-logger"
|
||||
tmcfg "github.com/tendermint/tendermint/config/tendermint"
|
||||
)
|
||||
|
||||
var config cfg.Config
|
||||
var log = logger.New("module", "main")
|
||||
var (
|
||||
config = tmcfg.GetConfig("")
|
||||
log = logger.New("module", "main")
|
||||
)
|
||||
|
||||
//global flag
|
||||
var logLevel string
|
||||
@ -18,18 +19,13 @@ var RootCmd = &cobra.Command{
|
||||
Use: "tendermint",
|
||||
Short: "Tendermint Core (BFT Consensus) in Go",
|
||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||
// set the log level in the config and logger
|
||||
config.Set("log_level", logLevel)
|
||||
logger.SetLogLevel(logLevel)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
// Get configuration
|
||||
config = tmcfg.GetConfig("")
|
||||
|
||||
//parse flag and set config
|
||||
RootCmd.PersistentFlags().StringVar(&logLevel, "log_level", config.GetString("log_level"), "Log level")
|
||||
|
||||
// set the log level
|
||||
logger.SetLogLevel(config.GetString("log_level"))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user