package util import ( "os/exec" log "github.com/sirupsen/logrus" ) // NewCommand creates a new Command with stdout/stderr wired to our standard logger func NewCommand(name string, arg ...string) *exec.Cmd { cmd := exec.Command(name, arg...) cmd.Stdout = log.NewEntry(log.StandardLogger()). WithField("cmd", cmd.Args[0]). WithField("std", "out"). WriterLevel(log.InfoLevel) cmd.Stderr = log.NewEntry(log.StandardLogger()). WithField("cmd", cmd.Args[0]). WithField("std", "err"). WriterLevel(log.WarnLevel) return cmd }