Browse Source

fix setting log level

pull/451/head
Ethan Buchman 8 years ago
parent
commit
f5b77d50b5
1 changed files with 6 additions and 10 deletions
  1. +6
    -10
      cmd/tendermint/commands/root.go

+ 6
- 10
cmd/tendermint/commands/root.go View File

@ -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 log = logger.New("module", "main")
var (
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…
Cancel
Save