-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.go
49 lines (44 loc) · 903 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
40
41
42
43
44
45
46
47
48
49
package log
import (
"github.com/fatih/color"
l "log"
)
type LoggerLevel int
const (
INFO LoggerLevel = iota
OK
WARN
FAILED
FATAL
EXTENSION
DEBUG
)
var FatalColor = color.New(color.BgHiRed, color.FgHiWhite)
func Log(level LoggerLevel, log string) {
switch level {
case INFO:
l.Printf("[ INFO ] %s\n", log)
break
case OK:
l.Printf("[ %s ] %s\n", color.HiGreenString("OK"), log)
break
case WARN:
l.Printf("[ %s ] %s\n", color.HiYellowString("WARN"), log)
break
case FAILED:
l.Printf("[%s] %s\n", color.HiRedString("FAILED"), log)
break
case FATAL:
l.Fatalf("[ %s ] %s\n", FatalColor.Sprint("FATL"), log)
break
case EXTENSION:
l.Println(" ->", log)
break
case DEBUG:
l.Printf("[ %s ] %s\n", color.BlueString("DBUG"), log)
break
default:
l.Printf("[%s] Parameter level is not of type LoggerLevel!\n", color.HiRedString("FAILED"))
break
}
}