Browse Source

Reset log after config changes.

pull/43/merge
Jae Kwon 10 years ago
committed by Ethan Buchman
parent
commit
39d5ff9ccb
4 changed files with 18 additions and 12 deletions
  1. +3
    -0
      cmd/main.go
  2. +3
    -1
      config/config.go
  3. +11
    -10
      logger/log.go
  4. +1
    -1
      rpc/test/test.go

+ 3
- 0
cmd/main.go View File

@ -6,6 +6,7 @@ import (
"github.com/tendermint/tendermint2/config" "github.com/tendermint/tendermint2/config"
"github.com/tendermint/tendermint2/daemon" "github.com/tendermint/tendermint2/daemon"
"github.com/tendermint/tendermint2/logger"
) )
func main() { func main() {
@ -27,6 +28,7 @@ Commands:
switch args[0] { switch args[0] {
case "daemon": case "daemon":
config.ParseFlags(args[1:]) config.ParseFlags(args[1:])
logger.Reset()
daemon.Daemon() daemon.Daemon()
case "gen_account": case "gen_account":
gen_account() gen_account()
@ -34,6 +36,7 @@ Commands:
gen_validator() gen_validator()
case "gen_tx": case "gen_tx":
config.ParseFlags(args[1:]) config.ParseFlags(args[1:])
logger.Reset()
gen_tx() gen_tx()
case "probe_upnp": case "probe_upnp":
probe_upnp() probe_upnp()


+ 3
- 1
config/config.go View File

@ -163,8 +163,9 @@ func ParseFlags(args []string) {
flags.BoolVar(&printHelp, "help", false, "Print this help message.") flags.BoolVar(&printHelp, "help", false, "Print this help message.")
flags.String("listen_addr", app.GetString("ListenAddr"), "Listen address. (0.0.0.0:0 means any interface, any port)") flags.String("listen_addr", app.GetString("ListenAddr"), "Listen address. (0.0.0.0:0 means any interface, any port)")
flags.String("seed_node", app.GetString("SeedNode"), "Address of seed node") flags.String("seed_node", app.GetString("SeedNode"), "Address of seed node")
flags.Bool("fast_sync", app.GetBool("FastSync"), "Fast blockchain syncing")
flags.String("rpc_http_listen_addr", app.GetString("RPC.HTTP.ListenAddr"), "RPC listen address. Port required") flags.String("rpc_http_listen_addr", app.GetString("RPC.HTTP.ListenAddr"), "RPC listen address. Port required")
flags.Bool("fast_sync", app.GetBool("FastSync"), "Fast blockchain syncing")
flags.String("log_stdout_level", app.GetString("Log.Stdout.Level"), "Stdout log level")
flags.Parse(args) flags.Parse(args)
if printHelp { if printHelp {
flags.PrintDefaults() flags.PrintDefaults()
@ -176,6 +177,7 @@ func ParseFlags(args []string) {
app.BindPFlag("SeedNode", flags.Lookup("seed_node")) app.BindPFlag("SeedNode", flags.Lookup("seed_node"))
app.BindPFlag("FastSync", flags.Lookup("fast_sync")) app.BindPFlag("FastSync", flags.Lookup("fast_sync"))
app.BindPFlag("RPC.HTTP.ListenAddr", flags.Lookup("rpc_http_listen_addr")) app.BindPFlag("RPC.HTTP.ListenAddr", flags.Lookup("rpc_http_listen_addr"))
app.BindPFlag("Log.Stdout.Level", flags.Lookup("log_stdout_level"))
// Confused? // Confused?
//app.Debug() //app.Debug()


+ 11
- 10
logger/log.go View File

@ -11,19 +11,12 @@ import (
var rootHandler log15.Handler var rootHandler log15.Handler
func getLevel(lvlString string) log15.Lvl {
lvl, err := log15.LvlFromString(lvlString)
if err != nil {
Exit(Fmt("Invalid log level %v: %v", lvlString, err))
}
return lvl
}
func init() { func init() {
InitLog()
Reset()
} }
func InitLog() {
// You might want to call this after resetting tendermint/config.
func Reset() {
handlers := []log15.Handler{} handlers := []log15.Handler{}
// By default, there's a stdout terminal format handler. // By default, there's a stdout terminal format handler.
@ -62,3 +55,11 @@ func RootHandler() log15.Handler {
func New(ctx ...interface{}) log15.Logger { func New(ctx ...interface{}) log15.Logger {
return log15.Root().New(ctx...) return log15.Root().New(ctx...)
} }
func getLevel(lvlString string) log15.Lvl {
lvl, err := log15.LvlFromString(lvlString)
if err != nil {
Exit(Fmt("Invalid log level %v: %v", lvlString, err))
}
return lvl
}

+ 1
- 1
rpc/test/test.go View File

@ -60,7 +60,7 @@ func init() {
app.Set("PrivValidatorFile", rootDir+"/priv_validator.json") app.Set("PrivValidatorFile", rootDir+"/priv_validator.json")
app.Set("Log.Stdout.Level", "debug") app.Set("Log.Stdout.Level", "debug")
config.SetApp(app) config.SetApp(app)
logger.InitLog()
logger.Reset()
// start a node // start a node
ready := make(chan struct{}) ready := make(chan struct{})
go newNode(ready) go newNode(ready)


Loading…
Cancel
Save