fix go run hello.go & console log
Showing
5 changed files
with
7 additions
and
12 deletions
| ... | @@ -188,7 +188,7 @@ func initBeforeHttpRun() { | ... | @@ -188,7 +188,7 @@ func initBeforeHttpRun() { |
| 188 | // if AppConfigPath not In the conf/app.conf reParse config | 188 | // if AppConfigPath not In the conf/app.conf reParse config |
| 189 | if AppConfigPath != filepath.Join(AppPath, "conf", "app.conf") { | 189 | if AppConfigPath != filepath.Join(AppPath, "conf", "app.conf") { |
| 190 | err := ParseConfig() | 190 | err := ParseConfig() |
| 191 | if err != nil { | 191 | if err != nil && AppConfigPath != filepath.Join(workPath, "conf", "app.conf") { |
| 192 | // configuration is critical to app, panic here if parse failed | 192 | // configuration is critical to app, panic here if parse failed |
| 193 | panic(err) | 193 | panic(err) |
| 194 | } | 194 | } | ... | ... |
| 1 | package beego | 1 | package beego |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "fmt" | ||
| 4 | "html/template" | 5 | "html/template" |
| 5 | "os" | 6 | "os" |
| 6 | "path/filepath" | 7 | "path/filepath" |
| ... | @@ -143,9 +144,12 @@ func init() { | ... | @@ -143,9 +144,12 @@ func init() { |
| 143 | 144 | ||
| 144 | // init BeeLogger | 145 | // init BeeLogger |
| 145 | BeeLogger = logs.NewLogger(10000) | 146 | BeeLogger = logs.NewLogger(10000) |
| 146 | BeeLogger.SetLogger("console", "") | 147 | err := BeeLogger.SetLogger("console", "") |
| 148 | if err != nil { | ||
| 149 | fmt.Println("init console log error:", err) | ||
| 150 | } | ||
| 147 | 151 | ||
| 148 | err := ParseConfig() | 152 | err = ParseConfig() |
| 149 | if err != nil && !os.IsNotExist(err) { | 153 | if err != nil && !os.IsNotExist(err) { |
| 150 | // for init if doesn't have app.conf will not panic | 154 | // for init if doesn't have app.conf will not panic |
| 151 | Info(err) | 155 | Info(err) | ... | ... |
| ... | @@ -29,9 +29,6 @@ func NewConn() LoggerInterface { | ... | @@ -29,9 +29,6 @@ func NewConn() LoggerInterface { |
| 29 | // init connection writer with json config. | 29 | // init connection writer with json config. |
| 30 | // json config only need key "level". | 30 | // json config only need key "level". |
| 31 | func (c *ConnWriter) Init(jsonconfig string) error { | 31 | func (c *ConnWriter) Init(jsonconfig string) error { |
| 32 | if len(jsonconfig) == 0 { | ||
| 33 | return nil | ||
| 34 | } | ||
| 35 | err := json.Unmarshal([]byte(jsonconfig), c) | 32 | err := json.Unmarshal([]byte(jsonconfig), c) |
| 36 | if err != nil { | 33 | if err != nil { |
| 37 | return err | 34 | return err | ... | ... |
| ... | @@ -90,9 +90,6 @@ func NewFileWriter() LoggerInterface { | ... | @@ -90,9 +90,6 @@ func NewFileWriter() LoggerInterface { |
| 90 | // "rotate":true | 90 | // "rotate":true |
| 91 | // } | 91 | // } |
| 92 | func (w *FileLogWriter) Init(jsonconfig string) error { | 92 | func (w *FileLogWriter) Init(jsonconfig string) error { |
| 93 | if len(jsonconfig) == 0 { | ||
| 94 | return nil | ||
| 95 | } | ||
| 96 | err := json.Unmarshal([]byte(jsonconfig), w) | 93 | err := json.Unmarshal([]byte(jsonconfig), w) |
| 97 | if err != nil { | 94 | if err != nil { |
| 98 | return err | 95 | return err | ... | ... |
| ... | @@ -38,9 +38,6 @@ func NewSmtpWriter() LoggerInterface { | ... | @@ -38,9 +38,6 @@ func NewSmtpWriter() LoggerInterface { |
| 38 | // "level":LevelError | 38 | // "level":LevelError |
| 39 | // } | 39 | // } |
| 40 | func (s *SmtpWriter) Init(jsonconfig string) error { | 40 | func (s *SmtpWriter) Init(jsonconfig string) error { |
| 41 | if len(jsonconfig) == 0 { | ||
| 42 | return nil | ||
| 43 | } | ||
| 44 | err := json.Unmarshal([]byte(jsonconfig), s) | 41 | err := json.Unmarshal([]byte(jsonconfig), s) |
| 45 | if err != nil { | 42 | if err != nil { |
| 46 | return err | 43 | return err | ... | ... |
-
Please register or sign in to post a comment