aboutsummaryrefslogtreecommitdiffstats
path: root/internal/debug/flags.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-02-23 17:44:16 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-02-23 18:16:47 +0800
commitf89dd627760b43bd405cb3db1e5efdb100835db5 (patch)
treeedaf8a63eb7f7434cd9b9cbd764b3c4c3d76191e /internal/debug/flags.go
parent1ca20a2697e5df840a0541b61f274379b43fddc7 (diff)
downloaddexon-f89dd627760b43bd405cb3db1e5efdb100835db5.tar
dexon-f89dd627760b43bd405cb3db1e5efdb100835db5.tar.gz
dexon-f89dd627760b43bd405cb3db1e5efdb100835db5.tar.bz2
dexon-f89dd627760b43bd405cb3db1e5efdb100835db5.tar.lz
dexon-f89dd627760b43bd405cb3db1e5efdb100835db5.tar.xz
dexon-f89dd627760b43bd405cb3db1e5efdb100835db5.tar.zst
dexon-f89dd627760b43bd405cb3db1e5efdb100835db5.zip
internal, log: support debug log prints, displaying log origins
Diffstat (limited to 'internal/debug/flags.go')
-rw-r--r--internal/debug/flags.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/internal/debug/flags.go b/internal/debug/flags.go
index 780aa1647..29d1f3388 100644
--- a/internal/debug/flags.go
+++ b/internal/debug/flags.go
@@ -30,12 +30,12 @@ import (
var (
verbosityFlag = cli.IntFlag{
Name: "verbosity",
- Usage: "Logging verbosity: 0=silent, 1=error, 2=warn, 3=info, 4=core, 5=debug, 6=detail",
+ Usage: "Logging verbosity: 0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=detail",
Value: 3,
}
vmoduleFlag = cli.StringFlag{
Name: "vmodule",
- Usage: "Per-module verbosity: comma-separated list of <pattern>=<level> (e.g. eth/*=6,p2p=5)",
+ Usage: "Per-module verbosity: comma-separated list of <pattern>=<level> (e.g. eth/*=5,p2p=4)",
Value: "",
}
backtraceAtFlag = cli.StringFlag{
@@ -43,6 +43,10 @@ var (
Usage: "Request a stack trace at a specific logging statement (e.g. \"block.go:271\")",
Value: "",
}
+ debugFlag = cli.BoolFlag{
+ Name: "debug",
+ Usage: "Prepends log messages with call-site location (file and line number)",
+ }
pprofFlag = cli.BoolFlag{
Name: "pprof",
Usage: "Enable the pprof HTTP server",
@@ -78,17 +82,21 @@ var (
// Flags holds all command-line flags required for debugging.
var Flags = []cli.Flag{
- verbosityFlag, vmoduleFlag, backtraceAtFlag,
+ verbosityFlag, vmoduleFlag, backtraceAtFlag, debugFlag,
pprofFlag, pprofAddrFlag, pprofPortFlag,
memprofilerateFlag, blockprofilerateFlag, cpuprofileFlag, traceFlag,
}
+// glogger is the glog handler used by Geth, allowing the debug APIs to modify
+// verbosity levels, vmodules and backtrace locations.
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
+ log.PrintOrigins(ctx.GlobalBool(debugFlag.Name))
+
glogger.Verbosity(log.Lvl(ctx.GlobalInt(verbosityFlag.Name)))
glogger.Vmodule(ctx.GlobalString(vmoduleFlag.Name))
glogger.BacktraceAt(ctx.GlobalString(backtraceAtFlag.Name))