Browse Source

No global config

pull/1842/head
Jae Kwon 9 years ago
parent
commit
529efe50ea
2 changed files with 1 additions and 30 deletions
  1. +0
    -14
      config.go
  2. +1
    -16
      log.go

+ 0
- 14
config.go View File

@ -1,14 +0,0 @@
package logger
import (
cfg "github.com/tendermint/go-config"
)
var config cfg.Config = nil
func init() {
cfg.OnConfig(func(newConfig cfg.Config) {
config = newConfig
Reset() // reset log root upon config change.
})
}

+ 1
- 16
log.go View File

@ -7,12 +7,11 @@ import (
"github.com/tendermint/log15"
)
//var rootHandler log15.Handler
var mainHandler log15.Handler
var bypassHandler log15.Handler
func init() {
Reset()
resetWithLogLevel("debug")
}
func SetLogLevel(logLevel string) {
@ -32,24 +31,10 @@ func resetWithLogLevel(logLevel string) {
bypassHandler = log15.StreamHandler(os.Stdout, log15.TerminalFormat())
//handlers = append(handlers, bypassHandler)
// Set rootHandler.
//rootHandler = log15.MultiHandler(handlers...)
// By setting handlers on the root, we handle events from all loggers.
log15.Root().SetHandler(mainHandler)
}
// You might want to call this after resetting tendermint/go-config.
func Reset() {
var logLevel string = "debug"
if config != nil && config.IsSet("log_level") {
logLevel = config.GetString("log_level")
}
resetWithLogLevel(logLevel)
}
// See go-wire/log for an example of usage.
func MainHandler() log15.Handler {
return mainHandler


Loading…
Cancel
Save