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/daemon"
"github.com/tendermint/tendermint2/logger"
)
func main() {
@ -27,6 +28,7 @@ Commands:
switch args[0] {
case "daemon":
config.ParseFlags(args[1:])
logger.Reset()
daemon.Daemon()
case "gen_account":
gen_account()
@ -34,6 +36,7 @@ Commands:
gen_validator()
case "gen_tx":
config.ParseFlags(args[1:])
logger.Reset()
gen_tx()
case "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.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.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.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)
if printHelp {
flags.PrintDefaults()
@ -176,6 +177,7 @@ func ParseFlags(args []string) {
app.BindPFlag("SeedNode", flags.Lookup("seed_node"))
app.BindPFlag("FastSync", flags.Lookup("fast_sync"))
app.BindPFlag("RPC.HTTP.ListenAddr", flags.Lookup("rpc_http_listen_addr"))
app.BindPFlag("Log.Stdout.Level", flags.Lookup("log_stdout_level"))
// Confused?
//app.Debug()


+ 11
- 10
logger/log.go View File

@ -11,19 +11,12 @@ import (
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() {
InitLog()
Reset()
}
func InitLog() {
// You might want to call this after resetting tendermint/config.
func Reset() {
handlers := []log15.Handler{}
// By default, there's a stdout terminal format handler.
@ -62,3 +55,11 @@ func RootHandler() log15.Handler {
func New(ctx ...interface{}) log15.Logger {
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("Log.Stdout.Level", "debug")
config.SetApp(app)
logger.InitLog()
logger.Reset()
// start a node
ready := make(chan struct{})
go newNode(ready)


Loading…
Cancel
Save