aboutsummaryrefslogtreecommitdiffstats
path: root/internal/debug/flags.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/debug/flags.go')
-rw-r--r--internal/debug/flags.go28
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