作者 tangxvhui

修改log 配置

... ... @@ -25,3 +25,4 @@ opp
/vendor
/*.exe~
/log
/logs
... ...
... ... @@ -5,7 +5,7 @@ import "os"
const SERVICE_NAME = "partnermg"
var LOG_LEVEL = "debug"
var LOG_File = "app.log"
var LOG_File = "./logs/partnermg.log"
func init() {
if os.Getenv("LOG_LEVEL") != "" {
... ...
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", `{"filename":"log/partnermg.log"}`)
logs.SetLogger("file", getlogFileConfig())
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 {
... ...
... ... @@ -6,5 +6,5 @@ import (
)
func init() {
beego.SetStaticPath("/log", "./log/"+constant.LOG_File)
beego.SetStaticPath("/log", constant.LOG_File)
}
... ...