evm cli: no logs if --json (#8925)

This commit is contained in:
Alex Sharov 2023-12-09 13:42:07 +07:00 committed by GitHub
parent 4696769d25
commit e006db6ed9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 8 deletions

View File

@ -119,10 +119,12 @@ func timedExec(bench bool, execFunc func() ([]byte, uint64, error)) (output []by
}
func runCmd(ctx *cli.Context) error {
log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler))
//glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false)))
//glogger.Verbosity(log.Lvl(ctx.GlobalInt(VerbosityFlag.Name)))
//log.Root().SetHandler(glogger)
machineFriendlyOutput := ctx.Bool(MachineFlag.Name)
if machineFriendlyOutput {
log.Root().SetHandler(log.DiscardHandler())
} else {
log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler))
}
logconfig := &logger.LogConfig{
DisableMemory: ctx.Bool(DisableMemoryFlag.Name),
DisableStack: ctx.Bool(DisableStackFlag.Name),
@ -140,7 +142,7 @@ func runCmd(ctx *cli.Context) error {
receiver = libcommon.BytesToAddress([]byte("receiver"))
genesisConfig *types.Genesis
)
if ctx.Bool(MachineFlag.Name) {
if machineFriendlyOutput {
tracer = logger.NewJSONLogger(logconfig, os.Stdout)
} else if ctx.Bool(DebugFlag.Name) {
debugLogger = logger.NewStructLogger(logconfig)

View File

@ -57,8 +57,12 @@ type StatetestResult struct {
}
func stateTestCmd(ctx *cli.Context) error {
// Configure the go-ethereum logger
log.Root().SetHandler(log.LvlFilterHandler(log.LvlDebug, log.StderrHandler))
machineFriendlyOutput := ctx.Bool(MachineFlag.Name)
if machineFriendlyOutput {
log.Root().SetHandler(log.DiscardHandler())
} else {
log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler))
}
// Configure the EVM logger
config := &logger.LogConfig{
@ -70,7 +74,7 @@ func stateTestCmd(ctx *cli.Context) error {
cfg := vm.Config{
Debug: ctx.Bool(DebugFlag.Name) || ctx.Bool(MachineFlag.Name),
}
if ctx.Bool(MachineFlag.Name) {
if machineFriendlyOutput {
cfg.Tracer = logger.NewJSONLogger(config, os.Stderr)
} else if ctx.Bool(DebugFlag.Name) {
cfg.Tracer = logger.NewStructLogger(config)