From 16cb824d26c226301ea050396bf3e3abad5f03b8 Mon Sep 17 00:00:00 2001 From: "Subhas Dandapani (RDX)" Date: Fri, 28 Apr 2017 00:42:48 +0200 Subject: [PATCH] More support for verbose=0 level (#89) --- core/execution.go | 6 +++--- examples/shell/package_test.go | 4 +++- main.go | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/core/execution.go b/core/execution.go index da79aa7..6e644b8 100644 --- a/core/execution.go +++ b/core/execution.go @@ -1,9 +1,9 @@ package core import ( - "errors" "github.com/apex/log" "github.com/kardianos/osext" + "github.com/pkg/errors" "os" "os/exec" "strings" @@ -64,11 +64,11 @@ func (e *Execution) Execute() error { elapsed := time.Since(start) if err != nil { - log.Errorf("%v/%v: Failed, Took: %v", e.Project.Name, e.Task.Name, elapsed) + log.Infof("%v: Failed, Took: %v", displayName, elapsed) } else { log.Infof("%v: Completed, Took: %v", displayName, elapsed) } - return err + return errors.Wrap(err, displayName) } func (e *Execution) executeTask() error { diff --git a/examples/shell/package_test.go b/examples/shell/package_test.go index c6218df..38faa4e 100644 --- a/examples/shell/package_test.go +++ b/examples/shell/package_test.go @@ -6,11 +6,13 @@ import ( ) var tests = []TestTable{ + {Arg: `-v=0 error`, Out: `error`, Err: true}, {Arg: `-v=0 error`, Out: `(Failed){0}`, Err: true}, {Arg: `-v=0 error`, Out: `(foobar.*not found)`, Err: true}, {Arg: `-v=0 echo`, Out: `(Running){0}`}, {Arg: `-v=0 echo`, Out: `(echo){0}`}, - {Arg: `-v=1 error`, Out: `(Failed)`, Err: true}, + {Arg: `-v=1 error`, Out: `error`, Err: true}, + {Arg: `-v=1 error`, Out: `(Failed){0}`, Err: true}, {Arg: `-v=1 echo`, Out: `(Running){0}`}, {Arg: `-v=1 echo`, Out: `(echo)`}, {Arg: `subshell`, Out: `subshell works`}, diff --git a/main.go b/main.go index a5142be..f9cce01 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( func main() { if err := cmd.Exec(os.Args[1:]); err != nil { - log.WithError(err).Fatal("error") + log.WithError(err).Error("error") + os.Exit(1) } }