Skip to content

Commit

Permalink
when rotate by date ,there's no num after log file
Browse files Browse the repository at this point in the history
  • Loading branch information
JessonChan committed Feb 3, 2016
1 parent 304a5cc commit 6caa3ec
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions logs/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,13 @@ func (w *fileLogWriter) doRotate(logTime time.Time) error {
if suffix == "" {
suffix = ".log"
}
for ; err == nil && num <= 999; num++ {
fName = filenameOnly + fmt.Sprintf(".%s.%03d%s", logTime.Format("2006-01-02"), num, suffix)
if w.MaxLines > 0 || w.MaxSize > 0 {
for ; err == nil && num <= 999; num++ {
fName = filenameOnly + fmt.Sprintf(".%s.%03d%s", logTime.Format("2006-01-02"), num, suffix)
_, err = os.Lstat(fName)
}
} else {
fName = fmt.Sprintf("%s.%s.%s", filenameOnly, logTime.Format("2006-01-02"), suffix)
_, err = os.Lstat(fName)
}
// return error if the last file checked still existed
Expand Down

0 comments on commit 6caa3ec

Please sign in to comment.