rotate closes the current file, moves it aside with a timestamp in the name, (if it exists), opens a new file with the original filename, and then runs post-rotation processing and removal.
()
| 193 | // (if it exists), opens a new file with the original filename, and then runs |
| 194 | // post-rotation processing and removal. |
| 195 | func (l *Logger) rotate() error { |
| 196 | if err := l.close(); err != nil { |
| 197 | return err |
| 198 | } |
| 199 | if err := l.openNew(); err != nil { |
| 200 | return err |
| 201 | } |
| 202 | l.mill() |
| 203 | return nil |
| 204 | } |
| 205 | |
| 206 | // openNew opens a new log file for writing, moving any old log file out of the |
| 207 | // way. This methods assumes the file has already been closed. |