Change: SetRotateMaxDay => SetRotateMaxDays
Showing
2 changed files
with
7 additions
and
7 deletions
| ... | @@ -787,7 +787,7 @@ beego默认有一个初始化的BeeLogger对象输出内容到stdout中,你可 | ... | @@ -787,7 +787,7 @@ beego默认有一个初始化的BeeLogger对象输出内容到stdout中,你可 |
| 787 | 787 | ||
| 788 | - func (w *FileLogWriter) SetRotateDaily(daily bool) *FileLogWriter | 788 | - func (w *FileLogWriter) SetRotateDaily(daily bool) *FileLogWriter |
| 789 | - func (w *FileLogWriter) SetRotateLines(maxlines int) *FileLogWriter | 789 | - func (w *FileLogWriter) SetRotateLines(maxlines int) *FileLogWriter |
| 790 | - func (w *FileLogWriter) SetRotateMaxDay(maxday int64) *FileLogWriter | 790 | - func (w *FileLogWriter) SetRotateMaxDays(maxdays int64) *FileLogWriter |
| 791 | - func (w *FileLogWriter) SetRotateSize(maxsize int) *FileLogWriter | 791 | - func (w *FileLogWriter) SetRotateSize(maxsize int) *FileLogWriter |
| 792 | 792 | ||
| 793 | 但是这些函数调用必须在调用`StartLogger`之前。 | 793 | 但是这些函数调用必须在调用`StartLogger`之前。 | ... | ... |
| ... | @@ -26,7 +26,7 @@ type FileLogWriter struct { | ... | @@ -26,7 +26,7 @@ type FileLogWriter struct { |
| 26 | 26 | ||
| 27 | // Rotate daily | 27 | // Rotate daily |
| 28 | daily bool | 28 | daily bool |
| 29 | maxday int64 | 29 | maxdays int64 |
| 30 | daily_opendate int | 30 | daily_opendate int |
| 31 | 31 | ||
| 32 | rotate bool | 32 | rotate bool |
| ... | @@ -40,7 +40,7 @@ func NewFileWriter(fname string, rotate bool) *FileLogWriter { | ... | @@ -40,7 +40,7 @@ func NewFileWriter(fname string, rotate bool) *FileLogWriter { |
| 40 | maxlines: 1000000, | 40 | maxlines: 1000000, |
| 41 | maxsize: 1 << 28, //256 MB | 41 | maxsize: 1 << 28, //256 MB |
| 42 | daily: true, | 42 | daily: true, |
| 43 | maxday: 7, | 43 | maxdays: 7, |
| 44 | rotate: rotate, | 44 | rotate: rotate, |
| 45 | } | 45 | } |
| 46 | return w | 46 | return w |
| ... | @@ -64,9 +64,9 @@ func (w *FileLogWriter) SetRotateDaily(daily bool) *FileLogWriter { | ... | @@ -64,9 +64,9 @@ func (w *FileLogWriter) SetRotateDaily(daily bool) *FileLogWriter { |
| 64 | return w | 64 | return w |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | // Set rotate daily's log keep for maxday,other will delete | 67 | // Set rotate daily's log keep for maxdays, other will delete |
| 68 | func (w *FileLogWriter) SetRotateMaxDay(maxday int64) *FileLogWriter { | 68 | func (w *FileLogWriter) SetRotateMaxDays(maxdays int64) *FileLogWriter { |
| 69 | w.maxday = maxday | 69 | w.maxdays = maxdays |
| 70 | return w | 70 | return w |
| 71 | } | 71 | } |
| 72 | 72 | ||
| ... | @@ -155,7 +155,7 @@ func (w *FileLogWriter) DoRotate(rotate bool) error { | ... | @@ -155,7 +155,7 @@ func (w *FileLogWriter) DoRotate(rotate bool) error { |
| 155 | func (w *FileLogWriter) deleteOldLog() { | 155 | func (w *FileLogWriter) deleteOldLog() { |
| 156 | dir := path.Dir(w.filename) | 156 | dir := path.Dir(w.filename) |
| 157 | filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { | 157 | filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { |
| 158 | if !info.IsDir() && info.ModTime().Unix() < (time.Now().Unix()-60*60*24*w.maxday) { | 158 | if !info.IsDir() && info.ModTime().Unix() < (time.Now().Unix()-60*60*24*w.maxdays) { |
| 159 | os.Remove(path) | 159 | os.Remove(path) |
| 160 | } | 160 | } |
| 161 | return nil | 161 | return nil | ... | ... |
-
Please register or sign in to post a comment