mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 08:00:57 +00:00
fix go run hello.go & console log
This commit is contained in:
parent
31de651053
commit
fc982feeb9
2
beego.go
2
beego.go
@ -188,7 +188,7 @@ func initBeforeHttpRun() {
|
|||||||
// if AppConfigPath not In the conf/app.conf reParse config
|
// if AppConfigPath not In the conf/app.conf reParse config
|
||||||
if AppConfigPath != filepath.Join(AppPath, "conf", "app.conf") {
|
if AppConfigPath != filepath.Join(AppPath, "conf", "app.conf") {
|
||||||
err := ParseConfig()
|
err := ParseConfig()
|
||||||
if err != nil {
|
if err != nil && AppConfigPath != filepath.Join(workPath, "conf", "app.conf") {
|
||||||
// configuration is critical to app, panic here if parse failed
|
// configuration is critical to app, panic here if parse failed
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package beego
|
package beego
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -143,9 +144,12 @@ func init() {
|
|||||||
|
|
||||||
// init BeeLogger
|
// init BeeLogger
|
||||||
BeeLogger = logs.NewLogger(10000)
|
BeeLogger = logs.NewLogger(10000)
|
||||||
BeeLogger.SetLogger("console", "")
|
err := BeeLogger.SetLogger("console", "")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("init console log error:", err)
|
||||||
|
}
|
||||||
|
|
||||||
err := ParseConfig()
|
err = ParseConfig()
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
// for init if doesn't have app.conf will not panic
|
// for init if doesn't have app.conf will not panic
|
||||||
Info(err)
|
Info(err)
|
||||||
|
@ -29,9 +29,6 @@ func NewConn() LoggerInterface {
|
|||||||
// init connection writer with json config.
|
// init connection writer with json config.
|
||||||
// json config only need key "level".
|
// json config only need key "level".
|
||||||
func (c *ConnWriter) Init(jsonconfig string) error {
|
func (c *ConnWriter) Init(jsonconfig string) error {
|
||||||
if len(jsonconfig) == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
err := json.Unmarshal([]byte(jsonconfig), c)
|
err := json.Unmarshal([]byte(jsonconfig), c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -90,9 +90,6 @@ func NewFileWriter() LoggerInterface {
|
|||||||
// "rotate":true
|
// "rotate":true
|
||||||
// }
|
// }
|
||||||
func (w *FileLogWriter) Init(jsonconfig string) error {
|
func (w *FileLogWriter) Init(jsonconfig string) error {
|
||||||
if len(jsonconfig) == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
err := json.Unmarshal([]byte(jsonconfig), w)
|
err := json.Unmarshal([]byte(jsonconfig), w)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -38,9 +38,6 @@ func NewSmtpWriter() LoggerInterface {
|
|||||||
// "level":LevelError
|
// "level":LevelError
|
||||||
// }
|
// }
|
||||||
func (s *SmtpWriter) Init(jsonconfig string) error {
|
func (s *SmtpWriter) Init(jsonconfig string) error {
|
||||||
if len(jsonconfig) == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
err := json.Unmarshal([]byte(jsonconfig), s)
|
err := json.Unmarshal([]byte(jsonconfig), s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user