fix: AppPath is wrong. Move BeeLogger to config.go init.
Showing
2 changed files
with
9 additions
and
9 deletions
| ... | @@ -3,12 +3,13 @@ package beego | ... | @@ -3,12 +3,13 @@ package beego |
| 3 | import ( | 3 | import ( |
| 4 | "html/template" | 4 | "html/template" |
| 5 | "os" | 5 | "os" |
| 6 | "path" | 6 | "path/filepath" |
| 7 | "runtime" | 7 | "runtime" |
| 8 | "strconv" | 8 | "strconv" |
| 9 | "strings" | 9 | "strings" |
| 10 | 10 | ||
| 11 | "github.com/astaxie/beego/config" | 11 | "github.com/astaxie/beego/config" |
| 12 | "github.com/astaxie/beego/logs" | ||
| 12 | "github.com/astaxie/beego/session" | 13 | "github.com/astaxie/beego/session" |
| 13 | ) | 14 | ) |
| 14 | 15 | ||
| ... | @@ -64,8 +65,8 @@ func init() { | ... | @@ -64,8 +65,8 @@ func init() { |
| 64 | BeeApp = NewApp() | 65 | BeeApp = NewApp() |
| 65 | 66 | ||
| 66 | // initialize default configurations | 67 | // initialize default configurations |
| 67 | os.Chdir(path.Dir(os.Args[0])) | 68 | AppPath, _ = filepath.Abs(filepath.Dir(os.Args[0])) |
| 68 | AppPath = path.Dir(os.Args[0]) | 69 | os.Chdir(AppPath) |
| 69 | 70 | ||
| 70 | StaticDir = make(map[string]string) | 71 | StaticDir = make(map[string]string) |
| 71 | StaticDir["/static"] = "static" | 72 | StaticDir["/static"] = "static" |
| ... | @@ -103,7 +104,7 @@ func init() { | ... | @@ -103,7 +104,7 @@ func init() { |
| 103 | 104 | ||
| 104 | EnableGzip = false | 105 | EnableGzip = false |
| 105 | 106 | ||
| 106 | AppConfigPath = path.Join(AppPath, "conf", "app.conf") | 107 | AppConfigPath = filepath.Join(AppPath, "conf", "app.conf") |
| 107 | 108 | ||
| 108 | HttpServerTimeOut = 0 | 109 | HttpServerTimeOut = 0 |
| 109 | 110 | ||
| ... | @@ -123,6 +124,10 @@ func init() { | ... | @@ -123,6 +124,10 @@ func init() { |
| 123 | 124 | ||
| 124 | runtime.GOMAXPROCS(runtime.NumCPU()) | 125 | runtime.GOMAXPROCS(runtime.NumCPU()) |
| 125 | 126 | ||
| 127 | // init BeeLogger | ||
| 128 | BeeLogger = logs.NewLogger(10000) | ||
| 129 | BeeLogger.SetLogger("console", "") | ||
| 130 | |||
| 126 | err := ParseConfig() | 131 | err := ParseConfig() |
| 127 | if err != nil && !os.IsNotExist(err) { | 132 | if err != nil && !os.IsNotExist(err) { |
| 128 | // for init if doesn't have app.conf will not panic | 133 | // for init if doesn't have app.conf will not panic | ... | ... |
| ... | @@ -25,11 +25,6 @@ func SetLevel(l int) { | ... | @@ -25,11 +25,6 @@ func SetLevel(l int) { |
| 25 | // logger references the used application logger. | 25 | // logger references the used application logger. |
| 26 | var BeeLogger *logs.BeeLogger | 26 | var BeeLogger *logs.BeeLogger |
| 27 | 27 | ||
| 28 | func init() { | ||
| 29 | BeeLogger = logs.NewLogger(10000) | ||
| 30 | BeeLogger.SetLogger("console", "") | ||
| 31 | } | ||
| 32 | |||
| 33 | // SetLogger sets a new logger. | 28 | // SetLogger sets a new logger. |
| 34 | func SetLogger(adaptername string, config string) { | 29 | func SetLogger(adaptername string, config string) { |
| 35 | BeeLogger.SetLogger(adaptername, config) | 30 | BeeLogger.SetLogger(adaptername, config) | ... | ... |
-
Please register or sign in to post a comment