-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlogger.go
49 lines (38 loc) · 804 Bytes
/
logger.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 grpc
import (
syslog "log"
"os"
)
type logInterface interface {
Debug(msg ...interface{})
Info(msg ...interface{})
Error(msg ...interface{})
Warn(msg ...interface{})
Fatal(msg ...interface{})
}
type logger struct{}
var log logInterface
func init() {
log = &logger{}
}
// SetLogger redirect the log output stream to logger
// which implement logInerface
func SetLogger(logger logInterface) {
log = logger
}
func (lg *logger) Debug(msg ...interface{}) {
syslog.Println(msg...)
}
func (lg *logger) Info(msg ...interface{}) {
syslog.Println(msg...)
}
func (lg *logger) Warn(msg ...interface{}) {
syslog.Println(msg...)
}
func (lg *logger) Error(msg ...interface{}) {
syslog.Println(msg...)
}
func (lg *logger) Fatal(msg ...interface{}) {
syslog.Println(msg...)
os.Exit(1)
}