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 (
|
import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
cfg "github.com/tendermint/go-config"
|
|
||||||
"github.com/tendermint/go-logger"
|
"github.com/tendermint/go-logger"
|
||||||
tmcfg "github.com/tendermint/tendermint/config/tendermint"
|
tmcfg "github.com/tendermint/tendermint/config/tendermint"
|
||||||
)
|
)
|
||||||
|
|
||||||
var config cfg.Config
|
var (
|
||||||
var log = logger.New("module", "main")
|
config = tmcfg.GetConfig("")
|
||||||
|
log = logger.New("module", "main")
|
||||||
|
)
|
||||||
|
|
||||||
//global flag
|
//global flag
|
||||||
var logLevel string
|
var logLevel string
|
||||||
@ -18,18 +19,13 @@ var RootCmd = &cobra.Command{
|
|||||||
Use: "tendermint",
|
Use: "tendermint",
|
||||||
Short: "Tendermint Core (BFT Consensus) in Go",
|
Short: "Tendermint Core (BFT Consensus) in Go",
|
||||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||||
|
// set the log level in the config and logger
|
||||||
config.Set("log_level", logLevel)
|
config.Set("log_level", logLevel)
|
||||||
|
logger.SetLogLevel(logLevel)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
||||||
// Get configuration
|
|
||||||
config = tmcfg.GetConfig("")
|
|
||||||
|
|
||||||
//parse flag and set config
|
//parse flag and set config
|
||||||
RootCmd.PersistentFlags().StringVar(&logLevel, "log_level", config.GetString("log_level"), "Log level")
|
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