|
|
@ -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")) |
|
|
|
} |