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