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:
parent
d58e9e6e12
commit
acbdeb62e8
@ -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
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user