-
Notifications
You must be signed in to change notification settings - Fork 1
/
log.go
74 lines (59 loc) · 1.37 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
70
71
72
73
74
package prophet
import (
stdLog "log"
)
var (
log Logger
)
// Logger logger
type Logger interface {
Info(v ...interface{})
Infof(format string, v ...interface{})
Debug(v ...interface{})
Debugf(format string, v ...interface{})
Warning(v ...interface{})
Warningf(format string, v ...interface{})
Error(v ...interface{})
Errorf(format string, v ...interface{})
Fatal(v ...interface{})
Fatalf(format string, v ...interface{})
}
type emptyLog struct{}
func (l *emptyLog) Info(v ...interface{}) {
stdLog.Print(v...)
}
func (l *emptyLog) Infof(format string, v ...interface{}) {
stdLog.Printf(format, v...)
}
func (l *emptyLog) Debug(v ...interface{}) {
stdLog.Print(v...)
}
func (l *emptyLog) Debugf(format string, v ...interface{}) {
stdLog.Printf(format, v...)
}
func (l *emptyLog) Warning(v ...interface{}) {
stdLog.Print(v...)
}
func (l *emptyLog) Warningf(format string, v ...interface{}) {
stdLog.Printf(format, v...)
}
func (l *emptyLog) Error(v ...interface{}) {
stdLog.Print(v...)
}
func (l *emptyLog) Errorf(format string, v ...interface{}) {
stdLog.Printf(format, v...)
}
func (l *emptyLog) Fatal(v ...interface{}) {
stdLog.Panic(v...)
}
func (l *emptyLog) Fatalf(format string, v ...interface{}) {
stdLog.Panicf(format, v...)
}
func init() {
log = &emptyLog{}
}
// SetLogger set the log for prophet
func SetLogger(l Logger) {
log = l
log.Infof("logger set")
}