Refactor logging

This commit is contained in:
stefanprodan
2020-04-25 13:16:34 +03:00
parent 2d300d7344
commit 8392c4fe24
5 changed files with 57 additions and 42 deletions

View File

@ -47,7 +47,7 @@ func init() {
func main() {
log.SetFlags(0)
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
logFailure("%v", err)
os.Exit(1)
}
}
@ -81,3 +81,15 @@ func execCommand(command string) (string, error) {
}
return string(output), nil
}
func logAction(format string, a ...interface{}) {
fmt.Println(``, fmt.Sprintf(format, a...))
}
func logSuccess(format string, a ...interface{}) {
fmt.Println(``, fmt.Sprintf(format, a...))
}
func logFailure(format string, a ...interface{}) {
fmt.Println(``, fmt.Sprintf(format, a...))
}