From 9c5ceb70ccf5dd004e3a8dfe5602504d75a6f5d9 Mon Sep 17 00:00:00 2001 From: "asta.xie" Date: Wed, 2 Apr 2014 23:43:37 +0800 Subject: [PATCH] Logs: modify StartLogger to private --- logs/file.go | 6 +++--- logs/log.go | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/logs/file.go b/logs/file.go index d61136c0..9400e04d 100644 --- a/logs/file.go +++ b/logs/file.go @@ -97,12 +97,12 @@ func (w *FileLogWriter) Init(jsonconfig string) error { if len(w.Filename) == 0 { return errors.New("jsonconfig must have filename") } - err = w.StartLogger() + err = w.startLogger() return err } // start file logger. create log file and set to locker-inside file writer. -func (w *FileLogWriter) StartLogger() error { +func (w *FileLogWriter) startLogger() error { fd, err := w.createLogFile() if err != nil { return err @@ -199,7 +199,7 @@ func (w *FileLogWriter) DoRotate() error { } // re-start logger - err = w.StartLogger() + err = w.startLogger() if err != nil { return fmt.Errorf("Rotate StartLogger: %s\n", err) } diff --git a/logs/log.go b/logs/log.go index 67eb1c79..c859c1e6 100644 --- a/logs/log.go +++ b/logs/log.go @@ -67,7 +67,7 @@ func NewLogger(channellen int64) *BeeLogger { bl.msg = make(chan *logMsg, channellen) bl.outputs = make(map[string]LoggerInterface) //bl.SetLogger("console", "") // default output to console - go bl.StartLogger() + go bl.startLogger() return bl } @@ -78,7 +78,10 @@ func (bl *BeeLogger) SetLogger(adaptername string, config string) error { defer bl.lock.Unlock() if log, ok := adapters[adaptername]; ok { lg := log() - lg.Init(config) + err := lg.Init(config) + if err != nil { + return err + } bl.outputs[adaptername] = lg return nil } else { @@ -138,7 +141,7 @@ func (bl *BeeLogger) EnableFuncCallDepth(b bool) { // start logger chan reading. // when chan is full, write logs. -func (bl *BeeLogger) StartLogger() { +func (bl *BeeLogger) startLogger() { for { select { case bm := <-bl.msg: