1
|
package log
|
1
|
package log
|
2
|
|
2
|
|
3
|
import (
|
3
|
import (
|
|
|
4
|
+ "encoding/json"
|
|
|
5
|
+
|
4
|
"github.com/astaxie/beego/logs"
|
6
|
"github.com/astaxie/beego/logs"
|
5
|
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/constant"
|
7
|
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/constant"
|
6
|
)
|
8
|
)
|
7
|
|
9
|
|
8
|
func init() {
|
10
|
func init() {
|
|
|
11
|
+
|
9
|
logs.SetLevel(logLevel(constant.LOG_LEVEL))
|
12
|
logs.SetLevel(logLevel(constant.LOG_LEVEL))
|
10
|
logs.SetLogFuncCall(false)
|
13
|
logs.SetLogFuncCall(false)
|
11
|
- logs.SetLogger("file", `{"filename":"log/partnermg.log"}`)
|
14
|
+ logs.SetLogger("file", getlogFileConfig())
|
12
|
logs.Async()
|
15
|
logs.Async()
|
13
|
logs.Async(2 * 1e3)
|
16
|
logs.Async(2 * 1e3)
|
14
|
}
|
17
|
}
|
15
|
|
18
|
|
|
|
19
|
+func getlogFileConfig() string {
|
|
|
20
|
+ m := map[string]string{
|
|
|
21
|
+ "filename": constant.LOG_File,
|
|
|
22
|
+ }
|
|
|
23
|
+ s, _ := json.Marshal(m)
|
|
|
24
|
+ return string(s)
|
|
|
25
|
+}
|
|
|
26
|
+
|
16
|
//LogLevel ...
|
27
|
//LogLevel ...
|
17
|
func logLevel(s string) (i int) {
|
28
|
func logLevel(s string) (i int) {
|
18
|
switch s {
|
29
|
switch s {
|