-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathlog.go
47 lines (38 loc) · 1.09 KB
/
log.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package core
import (
"errors"
"fmt"
"github.com/fatih/color"
"github.com/urfave/cli"
)
func Conform(message interface{}) {
fmt.Printf("%v %v", color.CyanString("[CONFIRM]"), message)
}
func Conformf(format string, value ...interface{}) {
fmt.Printf("%v ", color.CyanString("[CONFIRM]"))
fmt.Printf(format, value...)
}
func Info(message interface{}) {
fmt.Printf("%v %v\n", color.GreenString("[INFO]"), message)
}
func Infof(format string, value ...interface{}) {
fmt.Printf("%v ", color.GreenString("[INFO]"))
fmt.Printf(format, value...)
}
func Debug(message interface{}) {
if ctx.Verbose {
fmt.Printf("%v %v\n", color.CyanString("[DEBUG]"), message)
}
}
func Debugf(format string, value ...interface{}) {
if ctx.Verbose {
fmt.Printf("%v ", color.CyanString("[DEBUG]"))
fmt.Printf(format, value...)
}
}
func NewExitError(message interface{}) *cli.ExitError {
return cli.NewExitError(errors.New(color.RedString("[ERROR] %v", message)), 1)
}
func NewExitErrorf(format string, value ...interface{}) error {
return cli.NewExitError(color.RedString("[ERROR] "+format, value...), 1)
}