1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-01 00:10:55 +00:00

beego: fix log output when SetLogger has error

This commit is contained in:
slene 2014-04-04 07:33:13 +08:00
parent d58e9e6e12
commit acbdeb62e8
2 changed files with 6 additions and 2 deletions

View File

@ -43,6 +43,9 @@ func NewConsole() LoggerInterface {
// init console logger.
// jsonconfig like '{"level":LevelTrace}'.
func (c *ConsoleWriter) Init(jsonconfig string) error {
if len(jsonconfig) == 0 {
return nil
}
err := json.Unmarshal([]byte(jsonconfig), c)
if err != nil {
return err

View File

@ -79,14 +79,15 @@ func (bl *BeeLogger) SetLogger(adaptername string, config string) error {
if log, ok := adapters[adaptername]; ok {
lg := log()
err := lg.Init(config)
bl.outputs[adaptername] = lg
if err != nil {
fmt.Println("logs.BeeLogger.SetLogger: " + err.Error())
return err
}
bl.outputs[adaptername] = lg
return nil
} else {
return fmt.Errorf("logs: unknown adaptername %q (forgotten Register?)", adaptername)
}
return nil
}
// remove a logger adapter in BeeLogger.