1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 08:20:55 +00:00

Logs: modify StartLogger to private

This commit is contained in:
asta.xie 2014-04-02 23:43:37 +08:00
parent bf0b1af64f
commit 9c5ceb70cc
2 changed files with 9 additions and 6 deletions

View File

@ -97,12 +97,12 @@ func (w *FileLogWriter) Init(jsonconfig string) error {
if len(w.Filename) == 0 { if len(w.Filename) == 0 {
return errors.New("jsonconfig must have filename") return errors.New("jsonconfig must have filename")
} }
err = w.StartLogger() err = w.startLogger()
return err return err
} }
// start file logger. create log file and set to locker-inside file writer. // 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() fd, err := w.createLogFile()
if err != nil { if err != nil {
return err return err
@ -199,7 +199,7 @@ func (w *FileLogWriter) DoRotate() error {
} }
// re-start logger // re-start logger
err = w.StartLogger() err = w.startLogger()
if err != nil { if err != nil {
return fmt.Errorf("Rotate StartLogger: %s\n", err) return fmt.Errorf("Rotate StartLogger: %s\n", err)
} }

View File

@ -67,7 +67,7 @@ func NewLogger(channellen int64) *BeeLogger {
bl.msg = make(chan *logMsg, channellen) bl.msg = make(chan *logMsg, channellen)
bl.outputs = make(map[string]LoggerInterface) bl.outputs = make(map[string]LoggerInterface)
//bl.SetLogger("console", "") // default output to console //bl.SetLogger("console", "") // default output to console
go bl.StartLogger() go bl.startLogger()
return bl return bl
} }
@ -78,7 +78,10 @@ func (bl *BeeLogger) SetLogger(adaptername string, config string) error {
defer bl.lock.Unlock() defer bl.lock.Unlock()
if log, ok := adapters[adaptername]; ok { if log, ok := adapters[adaptername]; ok {
lg := log() lg := log()
lg.Init(config) err := lg.Init(config)
if err != nil {
return err
}
bl.outputs[adaptername] = lg bl.outputs[adaptername] = lg
return nil return nil
} else { } else {
@ -138,7 +141,7 @@ func (bl *BeeLogger) EnableFuncCallDepth(b bool) {
// start logger chan reading. // start logger chan reading.
// when chan is full, write logs. // when chan is full, write logs.
func (bl *BeeLogger) StartLogger() { func (bl *BeeLogger) startLogger() {
for { for {
select { select {
case bm := <-bl.msg: case bm := <-bl.msg: