@@ -23,7 +23,6 @@ import (
23
23
"bytes"
24
24
"context"
25
25
"errors"
26
- "fmt"
27
26
"io"
28
27
"log"
29
28
"os"
@@ -60,7 +59,7 @@ func ExecCmdDirBytesWithContext(ctx context.Context, dir, cmdName string, args .
60
59
err := cmd .Run ()
61
60
if err != nil {
62
61
if e , y := err .(* exec.ExitError ); y {
63
- OnCmdExitError (append ([] string { cmdName }, args ... ) , e )
62
+ OnCmdExitError (cmd , e )
64
63
} else {
65
64
cmd .Stderr .Write ([]byte (err .Error () + "\n " ))
66
65
}
@@ -515,8 +514,8 @@ func RunCmdStrWriterWithContext(ctx context.Context, command string, writer ...i
515
514
return RunCmdWriterWithContext (ctx , params , writer ... )
516
515
}
517
516
518
- var OnCmdExitError = func (params [] string , err * exec.ExitError ) {
519
- fmt .Printf ("[%v]The process exited abnormally: PID(%d) PARAMS (%v) ERR(%v)\n " , time .Now ().Format (`2006-01-02 15:04:05` ), err .Pid (), params , err )
517
+ var OnCmdExitError = func (cmd * exec. Cmd , err * exec.ExitError ) {
518
+ log .Printf ("[%v]The process exited abnormally: PID(%d) CMD (%v) ERR(%v)\n " , time .Now ().Format (`2006-01-02 15:04:05` ), err .Pid (), cmd . String () , err )
520
519
}
521
520
522
521
func RunCmdReaderWriterWithContext (ctx context.Context , params []string , reader io.Reader , writer ... io.Writer ) * exec.Cmd {
@@ -527,7 +526,7 @@ func RunCmdReaderWriterWithContext(ctx context.Context, params []string, reader
527
526
err := cmd .Run ()
528
527
if err != nil {
529
528
if e , y := err .(* exec.ExitError ); y {
530
- OnCmdExitError (params , e )
529
+ OnCmdExitError (cmd , e )
531
530
} else {
532
531
cmd .Stderr .Write ([]byte (err .Error () + "\n " ))
533
532
}
@@ -552,7 +551,7 @@ func RunCmdWriterWithContext(ctx context.Context, params []string, writer ...io.
552
551
err := cmd .Run ()
553
552
if err != nil {
554
553
if e , y := err .(* exec.ExitError ); y {
555
- OnCmdExitError (params , e )
554
+ OnCmdExitError (cmd , e )
556
555
} else {
557
556
cmd .Stderr .Write ([]byte (err .Error () + "\n " ))
558
557
}
@@ -587,7 +586,7 @@ func RunCmdWriterxWithContext(ctx context.Context, params []string, wait time.Du
587
586
err = cmd .Run ()
588
587
if err != nil {
589
588
if e , y := err .(* exec.ExitError ); y {
590
- OnCmdExitError (params , e )
589
+ OnCmdExitError (cmd , e )
591
590
} else {
592
591
cmd .Stderr .Write ([]byte (err .Error () + "\n " ))
593
592
}
0 commit comments