-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.go
37 lines (29 loc) · 789 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
package main
import (
"log"
"os"
)
var flags = log.Ldate | log.Lshortfile
var logger = log.New(os.Stdout, "", flags)
var Gdebug = false
func EnableDebug() {
Gdebug = true
log.SetFlags(log.Ldate | log.Lmicroseconds)
}
func DebugPrint(fmt string, args ...interface{}) {
if Gdebug {
log.Printf("[\033[34;1m DEBUG \033[0m] "+fmt, args...)
}
}
func InfoPrint(fmt string, args ...interface{}) {
log.Printf("[\033[37;1m INFO \033[0m] "+fmt, args...)
}
func ErrorPrint(fmt string, args ...interface{}) {
log.Printf("[\033[31;1m ERROR \033[0m] "+fmt, args...)
}
func WarnPrint(fmt string, args ...interface{}) {
log.Printf("[\033[33;1mWARNING\033[0m] "+fmt, args...)
}
func FatalPrint(fmt string, args ...interface{}) {
log.Fatalf("[\033[31;1m FATAL \033[0m] "+fmt, args...)
}