diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-02-22 20:10:07 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-02-23 18:16:44 +0800 |
commit | d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851 (patch) | |
tree | 17c93170551d3eeabe2935de1765f157007f0dc2 /internal/debug/flags.go | |
parent | 47af53f9aaf9aa7b12cd976eb150ccf3d64da6fd (diff) | |
download | go-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar go-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.gz go-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.bz2 go-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.lz go-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.xz go-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.zst go-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.zip |
all: blidly swap out glog to our log15, logs need rework
Diffstat (limited to 'internal/debug/flags.go')
-rw-r--r-- | internal/debug/flags.go | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/internal/debug/flags.go b/internal/debug/flags.go index d7bbfae1e..780aa1647 100644 --- a/internal/debug/flags.go +++ b/internal/debug/flags.go @@ -20,28 +20,28 @@ import ( "fmt" "net/http" _ "net/http/pprof" + "os" "runtime" - "github.com/ethereum/go-ethereum/logger" - "github.com/ethereum/go-ethereum/logger/glog" + "github.com/ethereum/go-ethereum/log" "gopkg.in/urfave/cli.v1" ) var ( - verbosityFlag = cli.GenericFlag{ + verbosityFlag = cli.IntFlag{ Name: "verbosity", Usage: "Logging verbosity: 0=silent, 1=error, 2=warn, 3=info, 4=core, 5=debug, 6=detail", - Value: glog.GetVerbosity(), + Value: 3, } - vmoduleFlag = cli.GenericFlag{ + vmoduleFlag = cli.StringFlag{ Name: "vmodule", Usage: "Per-module verbosity: comma-separated list of <pattern>=<level> (e.g. eth/*=6,p2p=5)", - Value: glog.GetVModule(), + Value: "", } - backtraceAtFlag = cli.GenericFlag{ + backtraceAtFlag = cli.StringFlag{ Name: "backtrace", Usage: "Request a stack trace at a specific logging statement (e.g. \"block.go:271\")", - Value: glog.GetTraceLocation(), + Value: "", } pprofFlag = cli.BoolFlag{ Name: "pprof", @@ -83,12 +83,16 @@ var Flags = []cli.Flag{ memprofilerateFlag, blockprofilerateFlag, cpuprofileFlag, traceFlag, } +var glogger = log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat())) + // Setup initializes profiling and logging based on the CLI flags. // It should be called as early as possible in the program. func Setup(ctx *cli.Context) error { // logging - glog.CopyStandardLogTo("INFO") - glog.SetToStderr(true) + glogger.Verbosity(log.Lvl(ctx.GlobalInt(verbosityFlag.Name))) + glogger.Vmodule(ctx.GlobalString(vmoduleFlag.Name)) + glogger.BacktraceAt(ctx.GlobalString(backtraceAtFlag.Name)) + log.Root().SetHandler(glogger) // profiling, tracing runtime.MemProfileRate = ctx.GlobalInt(memprofilerateFlag.Name) @@ -108,8 +112,8 @@ func Setup(ctx *cli.Context) error { if ctx.GlobalBool(pprofFlag.Name) { address := fmt.Sprintf("%s:%d", ctx.GlobalString(pprofAddrFlag.Name), ctx.GlobalInt(pprofPortFlag.Name)) go func() { - glog.V(logger.Info).Infof("starting pprof server at http://%s/debug/pprof", address) - glog.Errorln(http.ListenAndServe(address, nil)) + log.Info(fmt.Sprintf("starting pprof server at http://%s/debug/pprof", address)) + log.Error(fmt.Sprint(http.ListenAndServe(address, nil))) }() } return nil |