fix option Verbosity in toml file

This commit is contained in:
parmarrushabh 2018-11-02 12:51:24 +05:30
parent b969dc7790
commit 5afb844e0a
4 changed files with 13 additions and 11 deletions

View file

@ -36,6 +36,7 @@ import (
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6" whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"github.com/naoina/toml" "github.com/naoina/toml"
"strings" "strings"
"github.com/ethereum/go-ethereum/log"
) )
var ( var (
@ -131,7 +132,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, XDCConfig) {
Node: defaultNodeConfig(), Node: defaultNodeConfig(),
Dashboard: dashboard.DefaultConfig, Dashboard: dashboard.DefaultConfig,
StakeEnable: true, StakeEnable: true,
Verbosity: 0, Verbosity: 3,
NAT: "", NAT: "",
} }
// Load config file. // Load config file.
@ -144,7 +145,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, XDCConfig) {
cfg.StakeEnable = ctx.GlobalBool(utils.StakingEnabledFlag.Name) cfg.StakeEnable = ctx.GlobalBool(utils.StakingEnabledFlag.Name)
} }
if !ctx.GlobalIsSet(debug.VerbosityFlag.Name) { if !ctx.GlobalIsSet(debug.VerbosityFlag.Name) {
ctx.Set(debug.VerbosityFlag.Name, string(cfg.Verbosity)) debug.Glogger.Verbosity(log.Lvl(cfg.Verbosity))
} }
if !ctx.GlobalIsSet(utils.NATFlag.Name) && cfg.NAT != "" { if !ctx.GlobalIsSet(utils.NATFlag.Name) && cfg.NAT != "" {

View file

@ -653,6 +653,7 @@ func setListenAddress(ctx *cli.Context, cfg *p2p.Config) {
// setNAT creates a port mapper from command line flags. // setNAT creates a port mapper from command line flags.
func setNAT(ctx *cli.Context, cfg *p2p.Config) { func setNAT(ctx *cli.Context, cfg *p2p.Config) {
if ctx.GlobalIsSet(NATFlag.Name) { if ctx.GlobalIsSet(NATFlag.Name) {
log.Info("NAT is setted","value",ctx.GlobalString(NATFlag.Name))
natif, err := nat.Parse(ctx.GlobalString(NATFlag.Name)) natif, err := nat.Parse(ctx.GlobalString(NATFlag.Name))
if err != nil { if err != nil {
Fatalf("Option %s: %v", NATFlag.Name, err) Fatalf("Option %s: %v", NATFlag.Name, err)

View file

@ -53,19 +53,19 @@ type HandlerT struct {
// Verbosity sets the log verbosity ceiling. The verbosity of individual packages // Verbosity sets the log verbosity ceiling. The verbosity of individual packages
// and source files can be raised using Vmodule. // and source files can be raised using Vmodule.
func (*HandlerT) Verbosity(level int) { func (*HandlerT) Verbosity(level int) {
glogger.Verbosity(log.Lvl(level)) Glogger.Verbosity(log.Lvl(level))
} }
// Vmodule sets the log verbosity pattern. See package log for details on the // Vmodule sets the log verbosity pattern. See package log for details on the
// pattern syntax. // pattern syntax.
func (*HandlerT) Vmodule(pattern string) error { func (*HandlerT) Vmodule(pattern string) error {
return glogger.Vmodule(pattern) return Glogger.Vmodule(pattern)
} }
// BacktraceAt sets the log backtrace location. See package log for details on // BacktraceAt sets the log backtrace location. See package log for details on
// the pattern syntax. // the pattern syntax.
func (*HandlerT) BacktraceAt(location string) error { func (*HandlerT) BacktraceAt(location string) error {
return glogger.BacktraceAt(location) return Glogger.BacktraceAt(location)
} }
// MemStats returns detailed runtime memory statistics. // MemStats returns detailed runtime memory statistics.

View file

@ -92,7 +92,7 @@ var Flags = []cli.Flag{
memprofilerateFlag, blockprofilerateFlag, cpuprofileFlag, traceFlag, memprofilerateFlag, blockprofilerateFlag, cpuprofileFlag, traceFlag,
} }
var glogger *log.GlogHandler var Glogger *log.GlogHandler
func init() { func init() {
usecolor := term.IsTty(os.Stderr.Fd()) && os.Getenv("TERM") != "dumb" usecolor := term.IsTty(os.Stderr.Fd()) && os.Getenv("TERM") != "dumb"
@ -100,7 +100,7 @@ func init() {
if usecolor { if usecolor {
output = colorable.NewColorableStderr() output = colorable.NewColorableStderr()
} }
glogger = log.NewGlogHandler(log.StreamHandler(output, log.TerminalFormat(usecolor))) Glogger = log.NewGlogHandler(log.StreamHandler(output, log.TerminalFormat(usecolor)))
} }
// Setup initializes profiling and logging based on the CLI flags. // Setup initializes profiling and logging based on the CLI flags.
@ -108,10 +108,10 @@ func init() {
func Setup(ctx *cli.Context) error { func Setup(ctx *cli.Context) error {
// logging // logging
log.PrintOrigins(ctx.GlobalBool(debugFlag.Name)) log.PrintOrigins(ctx.GlobalBool(debugFlag.Name))
glogger.Verbosity(log.Lvl(ctx.GlobalInt(VerbosityFlag.Name))) Glogger.Verbosity(log.Lvl(ctx.GlobalInt(VerbosityFlag.Name)))
glogger.Vmodule(ctx.GlobalString(vmoduleFlag.Name)) Glogger.Vmodule(ctx.GlobalString(vmoduleFlag.Name))
glogger.BacktraceAt(ctx.GlobalString(backtraceAtFlag.Name)) Glogger.BacktraceAt(ctx.GlobalString(backtraceAtFlag.Name))
log.Root().SetHandler(glogger) log.Root().SetHandler(Glogger)
// profiling, tracing // profiling, tracing
runtime.MemProfileRate = ctx.GlobalInt(memprofilerateFlag.Name) runtime.MemProfileRate = ctx.GlobalInt(memprofilerateFlag.Name)