logger.go
805 字节
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
package log
import (
"encoding/json"
"github.com/astaxie/beego/logs"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/constant"
)
func init() {
logs.SetLevel(logLevel(constant.LOG_LEVEL))
logs.SetLogFuncCall(false)
logs.SetLogger("file", getlogFileConfig())
logs.SetPrefix(constant.Log_PREFIX)
logs.Async()
logs.Async(2 * 1e3)
}
func getlogFileConfig() string {
m := map[string]string{
"filename": constant.LOG_File,
}
s, _ := json.Marshal(m)
return string(s)
}
//LogLevel ...
func logLevel(s string) (i int) {
switch s {
case "info":
i = logs.LevelInfo
case "debug":
i = logs.LevelDebug
case "warning":
i = logs.LevelWarning
case "error":
i = logs.LevelError
default:
i = logs.LevelDebug
}
return
}
func PrintSql(bt []byte) {
logs.Debug("SQL PRINT : ", string(bt))
}