forked from rebuy-de/aws-nuke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.go
39 lines (33 loc) · 933 Bytes
/
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
package cmd
import (
"fmt"
"github.com/fatih/color"
"github.com/rebuy-de/aws-nuke/resources"
)
var (
ReasonSkip = *color.New(color.FgYellow)
ReasonError = *color.New(color.FgRed)
ReasonRemoveTriggered = *color.New(color.FgGreen)
ReasonWaitPending = *color.New(color.FgBlue)
ReasonSuccess = *color.New(color.FgGreen)
ColorID = *color.New(color.Bold)
Warning = *color.New(color.FgYellow)
)
func Log(reg string, r resources.Resource, c color.Color, msg string) {
ColorID.Printf("%s", reg)
fmt.Printf(" - ")
fmt.Print(resources.GetCategory(r))
fmt.Printf(" - ")
ColorID.Printf("'%s'", r.String())
fmt.Printf(" - ")
c.Printf("%s\n", msg)
}
func LogWarn(s string, i ...interface{}) {
Warning.Printf("WARNING: "+s, i...)
}
func LogErrorf(err error) {
out := color.New(color.FgRed)
trace := fmt.Sprintf("%+v", err)
out.Println(trace)
out.Println("")
}