1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-25 03:10: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 {
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)
}

View File

@ -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: