diff options
author | 2015-11-07 21:25:34 +1000 | |
---|---|---|
committer | 2015-11-07 21:25:34 +1000 | |
commit | 1699299eddc755447f7c4c9afb43b345d9134022 (patch) | |
tree | 223c363ee765c1e92336801b50ac373f5bc294cc | |
parent | 56b69f60815aa18a19c2471e5386dda290662673 (diff) |
Improved logging - less unnecessary fatals
-rw-r--r-- | lib/errors.go | 7 | ||||
-rw-r--r-- | main.go | 9 |
2 files changed, 8 insertions, 8 deletions
diff --git a/lib/errors.go b/lib/errors.go index 6d7dd0e..263cb17 100644 --- a/lib/errors.go +++ b/lib/errors.go @@ -16,13 +16,10 @@ package lib -import log "github.com/Sirupsen/logrus" +import "github.com/Sirupsen/logrus" func handleError(str string, err error) { if err != nil { - log.WithFields(log.Fields{ - "error": err, - "during": str, - }).Fatal("An error occured") + logrus.WithError(err).Error(str) } } @@ -23,7 +23,7 @@ import ( "os" "strings" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" gogetme "go.owls.io/gogetme/lib" ) @@ -33,12 +33,15 @@ func checkVarPromptUnset(promptVar *string, promptDesc string) { input, err := bufio.NewReader(os.Stdin).ReadString('\n') if err != nil { - log.Fatal("Reading input string | ", err) + logrus.WithError(err).Fatal("Reading input string!") } *promptVar = strings.Trim(input, "\n") } - log.Info(promptDesc, " set to '", *promptVar, "'") + logrus.WithFields(logrus.Fields{ + "parameter": promptDesc, + "value": *promptVar, + }).Info("Set value of parameter") } func main() { |