mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 09:10:55 +00:00
beego: fix log output when SetLogger has error
This commit is contained in:
parent
6497f29ed7
commit
9421a21037
@ -43,6 +43,9 @@ func NewConsole() LoggerInterface {
|
|||||||
// init console logger.
|
// init console logger.
|
||||||
// jsonconfig like '{"level":LevelTrace}'.
|
// jsonconfig like '{"level":LevelTrace}'.
|
||||||
func (c *ConsoleWriter) Init(jsonconfig string) error {
|
func (c *ConsoleWriter) 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
|
||||||
|
@ -79,14 +79,15 @@ func (bl *BeeLogger) SetLogger(adaptername string, config string) error {
|
|||||||
if log, ok := adapters[adaptername]; ok {
|
if log, ok := adapters[adaptername]; ok {
|
||||||
lg := log()
|
lg := log()
|
||||||
err := lg.Init(config)
|
err := lg.Init(config)
|
||||||
|
bl.outputs[adaptername] = lg
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("logs.BeeLogger.SetLogger: " + err.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
bl.outputs[adaptername] = lg
|
|
||||||
return nil
|
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("logs: unknown adaptername %q (forgotten Register?)", adaptername)
|
return fmt.Errorf("logs: unknown adaptername %q (forgotten Register?)", adaptername)
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove a logger adapter in BeeLogger.
|
// remove a logger adapter in BeeLogger.
|
||||||
|
Loading…
Reference in New Issue
Block a user