fix utils

This commit is contained in:
therecipe 2016-11-19 01:15:43 +01:00
parent 02751dcb9c
commit 4efdadb17c

View file

@ -73,15 +73,17 @@ func RunCmd(cmd *exec.Cmd, name string) string {
Log.WithFields(fields).Debug("Execute")
var out, err = cmd.CombinedOutput()
if err != nil {
Log.WithError(err).WithFields(fields).WithField("output", out).Panic("failed to run command")
Log.WithError(err).WithFields(fields).WithField("output", string(out)).Panic("failed to run command")
}
return string(out)
}
func RunCmdOptional(cmd *exec.Cmd, name string) string {
fields := logrus.Fields{"func": "RunCmdOptional", "name": name, "cmd": strings.Join(cmd.Args, " ")}
Log.WithFields(fields).Debug("Execute")
var out, err = cmd.CombinedOutput()
if err != nil {
Log.WithError(err).Errorf("failed to %v\nerror: %s\ncmd: %v", name, out, cmd)
Log.WithError(err).WithFields(fields).WithField("output", string(out)).Error("failed to run command")
}
return string(out)
}