Skip to content

Commit

Permalink
Merge pull request XinFinOrg#742 from gzliudan/fix-pr734
Browse files Browse the repository at this point in the history
use global function when cli v1
  • Loading branch information
gzliudan authored Nov 21, 2024
2 parents 8e72c6d + bd916d1 commit 962be21
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions cmd/evm/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ func runCmd(ctx *cli.Context) error {
logconfig := &vm.LogConfig{
EnableMemory: !ctx.GlobalBool(DisableMemoryFlag.Name),
DisableStack: ctx.GlobalBool(DisableStackFlag.Name),
DisableStorage: ctx.Bool(DisableStorageFlag.Name),
EnableReturnData: !ctx.Bool(DisableReturnDataFlag.Name),
Debug: ctx.Bool(DebugFlag.Name),
DisableStorage: ctx.GlobalBool(DisableStorageFlag.Name),
EnableReturnData: !ctx.GlobalBool(DisableReturnDataFlag.Name),
Debug: ctx.GlobalBool(DebugFlag.Name),
}

var (
Expand Down
4 changes: 2 additions & 2 deletions cmd/evm/staterunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func stateTestCmd(ctx *cli.Context) error {
config := &vm.LogConfig{
EnableMemory: !ctx.GlobalBool(DisableMemoryFlag.Name),
DisableStack: ctx.GlobalBool(DisableStackFlag.Name),
DisableStorage: ctx.Bool(DisableStorageFlag.Name),
EnableReturnData: !ctx.Bool(DisableReturnDataFlag.Name),
DisableStorage: ctx.GlobalBool(DisableStorageFlag.Name),
EnableReturnData: !ctx.GlobalBool(DisableReturnDataFlag.Name),
}

var (
Expand Down
24 changes: 12 additions & 12 deletions internal/debug/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ func Setup(ctx *cli.Context) error {
handler slog.Handler
terminalOutput = io.Writer(os.Stderr)
output io.Writer
logFmtFlag = ctx.String(logFormatFlag.Name)
logFmtFlag = ctx.GlobalString(logFormatFlag.Name)
)
var (
logFile = ctx.String(logFileFlag.Name)
rotation = ctx.Bool(logRotateFlag.Name)
logFile = ctx.GlobalString(logFileFlag.Name)
rotation = ctx.GlobalBool(logRotateFlag.Name)
)
if len(logFile) > 0 {
if err := validateLogLocation(filepath.Dir(logFile)); err != nil {
Expand All @@ -205,10 +205,10 @@ func Setup(ctx *cli.Context) error {
}
logOutputFile = &lumberjack.Logger{
Filename: logFile,
MaxSize: ctx.Int(logMaxSizeMBsFlag.Name),
MaxBackups: ctx.Int(logMaxBackupsFlag.Name),
MaxAge: ctx.Int(logMaxAgeFlag.Name),
Compress: ctx.Bool(logCompressFlag.Name),
MaxSize: ctx.GlobalInt(logMaxSizeMBsFlag.Name),
MaxBackups: ctx.GlobalInt(logMaxBackupsFlag.Name),
MaxAge: ctx.GlobalInt(logMaxAgeFlag.Name),
Compress: ctx.GlobalBool(logCompressFlag.Name),
}
output = io.MultiWriter(terminalOutput, logOutputFile)
} else if logFile != "" {
Expand All @@ -223,7 +223,7 @@ func Setup(ctx *cli.Context) error {
}

switch {
case ctx.Bool(logjsonFlag.Name):
case ctx.GlobalBool(logjsonFlag.Name):
// Retain backwards compatibility with `--log-json` flag if `--log-format` not set
defer log.Warn("The flag '--log-json' is deprecated, please use '--log-format=json' instead")
handler = log.JSONHandlerWithLevel(output, log.LevelInfo)
Expand All @@ -244,18 +244,18 @@ func Setup(ctx *cli.Context) error {
handler = log.NewTerminalHandler(output, useColor)
default:
// Unknown log format specified
return fmt.Errorf("unknown log format: %v", ctx.String(logFormatFlag.Name))
return fmt.Errorf("unknown log format: %v", ctx.GlobalString(logFormatFlag.Name))
}

glogger = log.NewGlogHandler(handler)

// logging
verbosity := log.FromLegacyLevel(ctx.Int(verbosityFlag.Name))
verbosity := log.FromLegacyLevel(ctx.GlobalInt(verbosityFlag.Name))
glogger.Verbosity(verbosity)
vmodule := ctx.String(logVmoduleFlag.Name)
vmodule := ctx.GlobalString(logVmoduleFlag.Name)
if vmodule == "" {
// Retain backwards compatibility with `--vmodule` flag if `--log-vmodule` not set
vmodule = ctx.String(vmoduleFlag.Name)
vmodule = ctx.GlobalString(vmoduleFlag.Name)
if vmodule != "" {
defer log.Warn("The flag '--vmodule' is deprecated, please use '--log-vmodule' instead")
}
Expand Down

0 comments on commit 962be21

Please sign in to comment.