aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/evm/runner.go
diff options
context:
space:
mode:
authorChen Quan <terasum@163.com>2018-07-31 15:48:27 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-07-31 15:48:27 +0800
commitfb9f7261ec51e38eedb454594fc19f00de1a6834 (patch)
tree9d026596c599e832fd7deb8eb548248b4de837c9 /cmd/evm/runner.go
parentd927cbb638419866de47929a723b5f2b8922c88e (diff)
downloadgo-tangerine-fb9f7261ec51e38eedb454594fc19f00de1a6834.tar
go-tangerine-fb9f7261ec51e38eedb454594fc19f00de1a6834.tar.gz
go-tangerine-fb9f7261ec51e38eedb454594fc19f00de1a6834.tar.bz2
go-tangerine-fb9f7261ec51e38eedb454594fc19f00de1a6834.tar.lz
go-tangerine-fb9f7261ec51e38eedb454594fc19f00de1a6834.tar.xz
go-tangerine-fb9f7261ec51e38eedb454594fc19f00de1a6834.tar.zst
go-tangerine-fb9f7261ec51e38eedb454594fc19f00de1a6834.zip
cmd/evm: change error msg output to stderr (#17118)
* cmd/evm: change error msg output to stderr * cmd/evm: fix some linter error
Diffstat (limited to 'cmd/evm/runner.go')
-rw-r--r--cmd/evm/runner.go28
1 files changed, 14 insertions, 14 deletions
diff --git a/cmd/evm/runner.go b/cmd/evm/runner.go
index 7138a9ddd..fed41f53a 100644
--- a/cmd/evm/runner.go
+++ b/cmd/evm/runner.go
@@ -128,13 +128,13 @@ func runCmd(ctx *cli.Context) error {
if ctx.GlobalString(CodeFileFlag.Name) == "-" {
//Try reading from stdin
if hexcode, err = ioutil.ReadAll(os.Stdin); err != nil {
- fmt.Printf("Could not load code from stdin: %v\n", err)
+ fmt.Fprintf(ctx.App.ErrWriter, "Could not load code from stdin: %v\n", err)
os.Exit(1)
}
} else {
// Codefile with hex assembly
if hexcode, err = ioutil.ReadFile(ctx.GlobalString(CodeFileFlag.Name)); err != nil {
- fmt.Printf("Could not load code from file: %v\n", err)
+ fmt.Fprintf(ctx.App.ErrWriter, "Could not load code from file: %v\n", err)
os.Exit(1)
}
}
@@ -172,11 +172,11 @@ func runCmd(ctx *cli.Context) error {
if cpuProfilePath := ctx.GlobalString(CPUProfileFlag.Name); cpuProfilePath != "" {
f, err := os.Create(cpuProfilePath)
if err != nil {
- fmt.Println("could not create CPU profile: ", err)
+ fmt.Fprintf(ctx.App.ErrWriter, "could not create CPU profile: %v\n", err)
os.Exit(1)
}
if err := pprof.StartCPUProfile(f); err != nil {
- fmt.Println("could not start CPU profile: ", err)
+ fmt.Fprintf(ctx.App.ErrWriter, "could not start CPU profile: %v\n", err)
os.Exit(1)
}
defer pprof.StopCPUProfile()
@@ -200,17 +200,17 @@ func runCmd(ctx *cli.Context) error {
if ctx.GlobalBool(DumpFlag.Name) {
statedb.IntermediateRoot(true)
- fmt.Println(string(statedb.Dump()))
+ fmt.Fprintln(ctx.App.Writer, string(statedb.Dump()))
}
if memProfilePath := ctx.GlobalString(MemProfileFlag.Name); memProfilePath != "" {
f, err := os.Create(memProfilePath)
if err != nil {
- fmt.Println("could not create memory profile: ", err)
+ fmt.Fprintf(ctx.App.ErrWriter, "could not create memory profile: %v\n", err)
os.Exit(1)
}
if err := pprof.WriteHeapProfile(f); err != nil {
- fmt.Println("could not write memory profile: ", err)
+ fmt.Fprintf(ctx.App.ErrWriter, "could not create memory profile: %v\n", err)
os.Exit(1)
}
f.Close()
@@ -218,17 +218,17 @@ func runCmd(ctx *cli.Context) error {
if ctx.GlobalBool(DebugFlag.Name) {
if debugLogger != nil {
- fmt.Fprintln(os.Stderr, "#### TRACE ####")
- vm.WriteTrace(os.Stderr, debugLogger.StructLogs())
+ fmt.Fprintln(ctx.App.ErrWriter, "#### TRACE ####")
+ vm.WriteTrace(ctx.App.ErrWriter, debugLogger.StructLogs())
}
- fmt.Fprintln(os.Stderr, "#### LOGS ####")
- vm.WriteLogs(os.Stderr, statedb.Logs())
+ fmt.Fprintln(ctx.App.ErrWriter, "#### LOGS ####")
+ vm.WriteLogs(ctx.App.ErrWriter, statedb.Logs())
}
if ctx.GlobalBool(StatDumpFlag.Name) {
var mem goruntime.MemStats
goruntime.ReadMemStats(&mem)
- fmt.Fprintf(os.Stderr, `evm execution time: %v
+ fmt.Fprintf(ctx.App.ErrWriter, `evm execution time: %v
heap objects: %d
allocations: %d
total allocations: %d
@@ -238,9 +238,9 @@ Gas used: %d
`, execTime, mem.HeapObjects, mem.Alloc, mem.TotalAlloc, mem.NumGC, initialGas-leftOverGas)
}
if tracer == nil {
- fmt.Printf("0x%x\n", ret)
+ fmt.Fprintf(ctx.App.Writer, "0x%x\n", ret)
if err != nil {
- fmt.Printf(" error: %v\n", err)
+ fmt.Fprintf(ctx.App.ErrWriter, " error: %v\n", err)
}
}