-
-
Notifications
You must be signed in to change notification settings - Fork 126
/
log.go
58 lines (51 loc) · 1.19 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
48
49
50
51
52
53
54
55
56
57
58
package utils
import (
"log"
)
var Reset = "\033[0m"
var Red = "\033[31m"
var Green = "\033[32m"
var Yellow = "\033[33m"
var Blue = "\033[34m"
var Purple = "\033[35m"
var Cyan = "\033[36m"
var Gray = "\033[37m"
var White = "\033[97m"
func Debug(message string) {
ll := LoggingLevelLabels[GetMainConfig().LoggingLevel]
if ll <= DEBUG {
log.Println(Purple + "[DEBUG] " + message + Reset)
}
}
func Log(message string) {
ll := LoggingLevelLabels[GetMainConfig().LoggingLevel]
if ll <= INFO {
log.Println(Blue + "[INFO] " + message + Reset)
}
}
func Warn(message string) {
ll := LoggingLevelLabels[GetMainConfig().LoggingLevel]
if ll <= WARNING {
log.Println(Yellow + "[WARN] " + message + Reset)
}
}
func Error(message string, err error) {
ll := LoggingLevelLabels[GetMainConfig().LoggingLevel]
errStr := ""
if err != nil {
errStr = err.Error()
}
if ll <= ERROR {
log.Println(Red + "[ERROR] " + message + " : " + errStr + Reset)
}
}
func Fatal(message string, err error) {
ll := LoggingLevelLabels[GetMainConfig().LoggingLevel]
errStr := ""
if err != nil {
errStr = err.Error()
}
if ll <= ERROR {
log.Fatal(Red + "[FATAL] " + message + " : " + errStr + Reset)
}
}