1
0
mirror of https://github.com/astaxie/beego.git synced 2024-06-23 03:34:12 +00:00

add logrotate's setting for rotate

This commit is contained in:
astaxie 2013-06-25 08:13:06 +08:00
parent 4b09175d27
commit d99ae3e3a2

24
log.go
View File

@ -46,6 +46,30 @@ func NewFileWriter(fname string, rotate bool) *FileLogWriter {
return w
}
// Set rotate at linecount (chainable). Must be called before call StartLogger
func (w *FileLogWriter) SetRotateLines(maxlines int) *FileLogWriter {
w.maxlines = maxlines
return w
}
// Set rotate at size (chainable). Must be called before call StartLogger
func (w *FileLogWriter) SetRotateSize(maxsize int) *FileLogWriter {
w.maxsize = maxsize
return w
}
// Set rotate daily (chainable). Must be called before call StartLogger
func (w *FileLogWriter) SetRotateDaily(daily bool) *FileLogWriter {
w.daily = daily
return w
}
// Set rotate daily's log keep for maxday,other will delete
func (w *FileLogWriter) SetRotateMaxDay(maxday int64) *FileLogWriter {
w.maxday = maxday
return w
}
func (w *FileLogWriter) StartLogger() error {
if err := w.DoRotate(false); err != nil {
return err