-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.go
69 lines (53 loc) · 1.53 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
59
60
61
62
63
64
65
66
67
68
69
package g2cache
import (
"log"
)
// 外部调用者可实现此日志接口用于将日志导出
type LoggerInterface interface {
LogInfoF(f string, s ...interface{})
LogInfo(s ...interface{})
LogDebug(s ...interface{})
LogDebugF(f string, s ...interface{})
LogErr(s ...interface{})
LogErrF(f string, s ...interface{})
}
func LogInfoF(f string, s ...interface{}) {
Logger.LogInfoF(f, s)
}
func LogInfo(s ...interface{}) {
Logger.LogInfo(s)
}
func LogDebug(s ...interface{}) {
Logger.LogDebug(s)
}
func LogDebugF(f string, s ...interface{}) {
Logger.LogDebugF(f, s)
}
func LogErr(s ...interface{}) {
Logger.LogErr(s)
}
func LogErrF(f string, s ...interface{}) {
Logger.LogErrF(f, s)
}
type sysLogger struct{}
var (
Logger LoggerInterface = &sysLogger{}
)
func (l *sysLogger) LogInfo(s ...interface{}) {
log.Println("[\u001B[32mg2cache\u001B[0m] [\u001B[32minfo\u001B[0m] ", s)
}
func (l *sysLogger) LogInfoF(f string, s ...interface{}) {
log.Printf("[\u001B[32mg2cache\u001B[0m] [\u001B[32minfo\u001B[0m] "+f, s)
}
func (l *sysLogger) LogDebug(s ...interface{}) {
log.Println("[\u001B[32mg2cache\u001B[0m] [\u001B[33mdebug\u001B[0m] ", s)
}
func (l *sysLogger) LogDebugF(f string, s ...interface{}) {
log.Printf("[\u001B[32mg2cache\u001B[0m] [\u001B[33mdebug\u001B[0m] "+f, s)
}
func (l *sysLogger) LogErr(s ...interface{}) {
log.Println("[\u001B[32mg2cache\u001B[0m] [\u001B[31merr\u001B[0m] ", s)
}
func (l *sysLogger) LogErrF(f string, s ...interface{}) {
log.Printf("[\u001B[32mg2cache\u001B[0m] [\u001B[31merr\u001B[0m] "+f, s)
}