From 31de651053f615275614c8207be36a97feceedd1 Mon Sep 17 00:00:00 2001 From: slene Date: Fri, 4 Apr 2014 07:33:13 +0800 Subject: [PATCH] beego: fix log output when SetLogger has error --- logs/conn.go | 3 +++ logs/file.go | 3 +++ logs/smtp.go | 3 +++ 3 files changed, 9 insertions(+) diff --git a/logs/conn.go b/logs/conn.go index eed9ae2f..77bf4de8 100644 --- a/logs/conn.go +++ b/logs/conn.go @@ -29,6 +29,9 @@ func NewConn() LoggerInterface { // init connection writer with json config. // json config only need key "level". func (c *ConnWriter) Init(jsonconfig string) error { + if len(jsonconfig) == 0 { + return nil + } err := json.Unmarshal([]byte(jsonconfig), c) if err != nil { return err diff --git a/logs/file.go b/logs/file.go index 9400e04d..c9f81df5 100644 --- a/logs/file.go +++ b/logs/file.go @@ -90,6 +90,9 @@ func NewFileWriter() LoggerInterface { // "rotate":true // } func (w *FileLogWriter) Init(jsonconfig string) error { + if len(jsonconfig) == 0 { + return nil + } err := json.Unmarshal([]byte(jsonconfig), w) if err != nil { return err diff --git a/logs/smtp.go b/logs/smtp.go index 19296887..ec1c61ca 100644 --- a/logs/smtp.go +++ b/logs/smtp.go @@ -38,6 +38,9 @@ func NewSmtpWriter() LoggerInterface { // "level":LevelError // } func (s *SmtpWriter) Init(jsonconfig string) error { + if len(jsonconfig) == 0 { + return nil + } err := json.Unmarshal([]byte(jsonconfig), s) if err != nil { return err