-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathlog.go
38 lines (31 loc) · 782 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
38
package gracehttp
import (
"log"
)
type Log struct {
Info func(args ...interface{})
Notice func(args ...interface{})
Error func(args ...interface{})
}
var srvLog *Log
func init() {
srvLog = new(Log)
srvLog.Info = func(args ...interface{}) {
log.Printf("[gracehtto-log][Info] %v \n", args)
}
srvLog.Notice = func(args ...interface{}) {
log.Printf("[gracehtto-log][Notice] %v \n", args)
}
srvLog.Error = func(args ...interface{}) {
log.Printf("[gracehtto-log][Error] %v \n", args)
}
}
func SetInfoLogCallback(infoFunc func(args ...interface{})) {
srvLog.Info = infoFunc
}
func SetNoticeLogCallback(noticeFunc func(args ...interface{})) {
srvLog.Notice = noticeFunc
}
func SetErrorLogCallback(errFunc func(args ...interface{})) {
srvLog.Error = errFunc
}