added trace

master
Paulo Simão 2021-10-25 19:05:17 -03:00
parent dfdb8f0c50
commit 5bac0b2643
1 changed files with 7 additions and 0 deletions

7
lib.go
View File

@ -8,6 +8,7 @@ import (
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"runtime" "runtime"
"runtime/debug"
"strings" "strings"
) )
@ -49,6 +50,7 @@ const (
// Opts.SetupProc will customize the processes before execution - Eg.: setting out and err // Opts.SetupProc will customize the processes before execution - Eg.: setting out and err
type Opts struct { type Opts struct {
Debug bool Debug bool
Trace bool
Await bool Await bool
Wd string Wd string
SetupProc func(cmd *exec.Cmd) SetupProc func(cmd *exec.Cmd)
@ -227,6 +229,11 @@ func Exec(str string, opts ...*Opts) ([]*exec.Cmd, error) {
} }
} }
if opt.Trace {
bs := debug.Stack()
log.Printf("Running: %s\n%s", str, string(bs))
}
cmdwd := opt.Wd cmdwd := opt.Wd
prepCmd := func(l Line) *exec.Cmd { prepCmd := func(l Line) *exec.Cmd {