From 3bcff77947c1f02dff9f179075810ea0dcedf498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dobros=C5=82aw=20=C5=BBybort?= Date: Tue, 25 Jun 2013 12:54:51 +0200 Subject: [PATCH] Change: SetRotateMaxDay => SetRotateMaxDays --- docs/zh/Quickstart.md | 2 +- log.go | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/zh/Quickstart.md b/docs/zh/Quickstart.md index dd1889fc..d859180b 100644 --- a/docs/zh/Quickstart.md +++ b/docs/zh/Quickstart.md @@ -787,7 +787,7 @@ beego默认有一个初始化的BeeLogger对象输出内容到stdout中,你可 - func (w *FileLogWriter) SetRotateDaily(daily bool) *FileLogWriter - func (w *FileLogWriter) SetRotateLines(maxlines int) *FileLogWriter -- func (w *FileLogWriter) SetRotateMaxDay(maxday int64) *FileLogWriter +- func (w *FileLogWriter) SetRotateMaxDays(maxdays int64) *FileLogWriter - func (w *FileLogWriter) SetRotateSize(maxsize int) *FileLogWriter 但是这些函数调用必须在调用`StartLogger`之前。 diff --git a/log.go b/log.go index bacec1a3..6020a89d 100644 --- a/log.go +++ b/log.go @@ -26,7 +26,7 @@ type FileLogWriter struct { // Rotate daily daily bool - maxday int64 + maxdays int64 daily_opendate int rotate bool @@ -40,7 +40,7 @@ func NewFileWriter(fname string, rotate bool) *FileLogWriter { maxlines: 1000000, maxsize: 1 << 28, //256 MB daily: true, - maxday: 7, + maxdays: 7, rotate: rotate, } return w @@ -64,9 +64,9 @@ func (w *FileLogWriter) SetRotateDaily(daily bool) *FileLogWriter { return w } -// Set rotate daily's log keep for maxday,other will delete -func (w *FileLogWriter) SetRotateMaxDay(maxday int64) *FileLogWriter { - w.maxday = maxday +// Set rotate daily's log keep for maxdays, other will delete +func (w *FileLogWriter) SetRotateMaxDays(maxdays int64) *FileLogWriter { + w.maxdays = maxdays return w } @@ -155,7 +155,7 @@ func (w *FileLogWriter) DoRotate(rotate bool) error { func (w *FileLogWriter) deleteOldLog() { dir := path.Dir(w.filename) filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { - if !info.IsDir() && info.ModTime().Unix() < (time.Now().Unix()-60*60*24*w.maxday) { + if !info.IsDir() && info.ModTime().Unix() < (time.Now().Unix()-60*60*24*w.maxdays) { os.Remove(path) } return nil