作者 tangxvhui

修改log 配置

@@ -25,3 +25,4 @@ opp @@ -25,3 +25,4 @@ opp
25 /vendor 25 /vendor
26 /*.exe~ 26 /*.exe~
27 /log 27 /log
  28 +/logs
@@ -5,7 +5,7 @@ import "os" @@ -5,7 +5,7 @@ import "os"
5 const SERVICE_NAME = "partnermg" 5 const SERVICE_NAME = "partnermg"
6 6
7 var LOG_LEVEL = "debug" 7 var LOG_LEVEL = "debug"
8 -var LOG_File = "app.log" 8 +var LOG_File = "./logs/partnermg.log"
9 9
10 func init() { 10 func init() {
11 if os.Getenv("LOG_LEVEL") != "" { 11 if os.Getenv("LOG_LEVEL") != "" {
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 {
@@ -6,5 +6,5 @@ import ( @@ -6,5 +6,5 @@ import (
6 ) 6 )
7 7
8 func init() { 8 func init() {
9 - beego.SetStaticPath("/log", "./log/"+constant.LOG_File) 9 + beego.SetStaticPath("/log", constant.LOG_File)
10 } 10 }