From f5b77d50b5caaa5c0f9acf758fde234e2c3d06ad Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Thu, 20 Apr 2017 17:56:49 -0400 Subject: [PATCH] fix setting log level --- cmd/tendermint/commands/root.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/cmd/tendermint/commands/root.go b/cmd/tendermint/commands/root.go index cee5b6604..0cbaa289f 100644 --- a/cmd/tendermint/commands/root.go +++ b/cmd/tendermint/commands/root.go @@ -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")) }