f48ca96a by slene Committed by astaxie

beego: fix log output when SetLogger has error

1 parent 9421a210
...@@ -29,6 +29,9 @@ func NewConn() LoggerInterface { ...@@ -29,6 +29,9 @@ 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 }
32 err := json.Unmarshal([]byte(jsonconfig), c) 35 err := json.Unmarshal([]byte(jsonconfig), c)
33 if err != nil { 36 if err != nil {
34 return err 37 return err
......
...@@ -90,6 +90,9 @@ func NewFileWriter() LoggerInterface { ...@@ -90,6 +90,9 @@ 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 }
93 err := json.Unmarshal([]byte(jsonconfig), w) 96 err := json.Unmarshal([]byte(jsonconfig), w)
94 if err != nil { 97 if err != nil {
95 return err 98 return err
......
...@@ -38,6 +38,9 @@ func NewSmtpWriter() LoggerInterface { ...@@ -38,6 +38,9 @@ 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 }
41 err := json.Unmarshal([]byte(jsonconfig), s) 44 err := json.Unmarshal([]byte(jsonconfig), s)
42 if err != nil { 45 if err != nil {
43 return err 46 return err
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!