-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.go
More file actions
43 lines (38 loc) · 887 Bytes
/
Copy pathlog.go
File metadata and controls
43 lines (38 loc) · 887 Bytes
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
package main
import (
"encoding/json"
"os"
"path/filepath"
"github.com/astaxie/beego/logs"
)
type logconfig struct {
Filename string `json:"filename"`
Level int `json:"level"`
MaxLines int `json:"maxlines"`
MaxSize int `json:"maxsize"`
Daily bool `json:"daily"`
MaxDays int `json:"maxdays"`
Color bool `json:"color"`
}
var logCfg = logconfig{
Filename: os.Args[0],
Level: logs.LevelInformational,
Daily: true,
MaxSize: 10 * 1024 * 1024,
MaxLines: 100 * 1024,
MaxDays: 7,
Color: false,
}
func LogInit() {
logCfg.Filename = filepath.Join(RunlogDirGet(), "autoproxy.log")
value, err := json.Marshal(&logCfg)
if err != nil {
return
}
err = logs.SetLogger(logs.AdapterFile, string(value))
if err != nil {
return
}
logs.EnableFuncCallDepth(true)
logs.SetLogFuncCallDepth(3)
}