Commit d99ae3e3 authored by astaxie's avatar astaxie

add logrotate's setting for rotate

parent 4b09175d
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment