d99ae3e3 by astaxie

add logrotate's setting for rotate

1 parent 4b09175d
Showing 1 changed file with 24 additions and 0 deletions
...@@ -46,6 +46,30 @@ func NewFileWriter(fname string, rotate bool) *FileLogWriter { ...@@ -46,6 +46,30 @@ func NewFileWriter(fname string, rotate bool) *FileLogWriter {
46 return w 46 return w
47 } 47 }
48 48
49 // Set rotate at linecount (chainable). Must be called before call StartLogger
50 func (w *FileLogWriter) SetRotateLines(maxlines int) *FileLogWriter {
51 w.maxlines = maxlines
52 return w
53 }
54
55 // Set rotate at size (chainable). Must be called before call StartLogger
56 func (w *FileLogWriter) SetRotateSize(maxsize int) *FileLogWriter {
57 w.maxsize = maxsize
58 return w
59 }
60
61 // Set rotate daily (chainable). Must be called before call StartLogger
62 func (w *FileLogWriter) SetRotateDaily(daily bool) *FileLogWriter {
63 w.daily = daily
64 return w
65 }
66
67 // Set rotate daily's log keep for maxday,other will delete
68 func (w *FileLogWriter) SetRotateMaxDay(maxday int64) *FileLogWriter {
69 w.maxday = maxday
70 return w
71 }
72
49 func (w *FileLogWriter) StartLogger() error { 73 func (w *FileLogWriter) StartLogger() error {
50 if err := w.DoRotate(false); err != nil { 74 if err := w.DoRotate(false); err != nil {
51 return err 75 return err
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!