@@ -128,13 +128,13 @@ func runCmd(ctx *cli.Context) error {
128128 if ctx .GlobalString (CodeFileFlag .Name ) == "-" {
129129 //Try reading from stdin
130130 if hexcode , err = ioutil .ReadAll (os .Stdin ); err != nil {
131- fmt .Printf ( "Could not load code from stdin: %v\n " , err )
131+ fmt .Fprintf ( ctx . App . ErrWriter , "Could not load code from stdin: %v\n " , err )
132132 os .Exit (1 )
133133 }
134134 } else {
135135 // Codefile with hex assembly
136136 if hexcode , err = ioutil .ReadFile (ctx .GlobalString (CodeFileFlag .Name )); err != nil {
137- fmt .Printf ( "Could not load code from file: %v\n " , err )
137+ fmt .Fprintf ( ctx . App . ErrWriter , "Could not load code from file: %v\n " , err )
138138 os .Exit (1 )
139139 }
140140 }
@@ -172,11 +172,11 @@ func runCmd(ctx *cli.Context) error {
172172 if cpuProfilePath := ctx .GlobalString (CPUProfileFlag .Name ); cpuProfilePath != "" {
173173 f , err := os .Create (cpuProfilePath )
174174 if err != nil {
175- fmt .Println ( "could not create CPU profile: " , err )
175+ fmt .Fprintf ( ctx . App . ErrWriter , "could not create CPU profile: %v \n " , err )
176176 os .Exit (1 )
177177 }
178178 if err := pprof .StartCPUProfile (f ); err != nil {
179- fmt .Println ( "could not start CPU profile: " , err )
179+ fmt .Fprintf ( ctx . App . ErrWriter , "could not start CPU profile: %v \n " , err )
180180 os .Exit (1 )
181181 }
182182 defer pprof .StopCPUProfile ()
@@ -200,35 +200,35 @@ func runCmd(ctx *cli.Context) error {
200200
201201 if ctx .GlobalBool (DumpFlag .Name ) {
202202 statedb .IntermediateRoot (true )
203- fmt .Println ( string (statedb .Dump ()))
203+ fmt .Fprintln ( ctx . App . Writer , string (statedb .Dump ()))
204204 }
205205
206206 if memProfilePath := ctx .GlobalString (MemProfileFlag .Name ); memProfilePath != "" {
207207 f , err := os .Create (memProfilePath )
208208 if err != nil {
209- fmt .Println ( "could not create memory profile: " , err )
209+ fmt .Fprintf ( ctx . App . ErrWriter , "could not create memory profile: %v \n " , err )
210210 os .Exit (1 )
211211 }
212212 if err := pprof .WriteHeapProfile (f ); err != nil {
213- fmt .Println ( "could not write memory profile: " , err )
213+ fmt .Fprintf ( ctx . App . ErrWriter , "could not create memory profile: %v \n " , err )
214214 os .Exit (1 )
215215 }
216216 f .Close ()
217217 }
218218
219219 if ctx .GlobalBool (DebugFlag .Name ) {
220220 if debugLogger != nil {
221- fmt .Fprintln (os . Stderr , "#### TRACE ####" )
222- vm .WriteTrace (os . Stderr , debugLogger .StructLogs ())
221+ fmt .Fprintln (ctx . App . ErrWriter , "#### TRACE ####" )
222+ vm .WriteTrace (ctx . App . ErrWriter , debugLogger .StructLogs ())
223223 }
224- fmt .Fprintln (os . Stderr , "#### LOGS ####" )
225- vm .WriteLogs (os . Stderr , statedb .Logs ())
224+ fmt .Fprintln (ctx . App . ErrWriter , "#### LOGS ####" )
225+ vm .WriteLogs (ctx . App . ErrWriter , statedb .Logs ())
226226 }
227227
228228 if ctx .GlobalBool (StatDumpFlag .Name ) {
229229 var mem goruntime.MemStats
230230 goruntime .ReadMemStats (& mem )
231- fmt .Fprintf (os . Stderr , `evm execution time: %v
231+ fmt .Fprintf (ctx . App . ErrWriter , `evm execution time: %v
232232heap objects: %d
233233allocations: %d
234234total allocations: %d
@@ -238,9 +238,9 @@ Gas used: %d
238238` , execTime , mem .HeapObjects , mem .Alloc , mem .TotalAlloc , mem .NumGC , initialGas - leftOverGas )
239239 }
240240 if tracer == nil {
241- fmt .Printf ( "0x%x\n " , ret )
241+ fmt .Fprintf ( ctx . App . Writer , "0x%x\n " , ret )
242242 if err != nil {
243- fmt .Printf ( " error: %v\n " , err )
243+ fmt .Fprintf ( ctx . App . ErrWriter , " error: %v\n " , err )
244244 }
245245 }
246246
0 commit comments