mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 20:40:54 +00:00
when rotate by date ,there's no num after log file
This commit is contained in:
parent
304a5ccea0
commit
6caa3ecd91
@ -210,10 +210,15 @@ func (w *fileLogWriter) doRotate(logTime time.Time) error {
|
|||||||
if suffix == "" {
|
if suffix == "" {
|
||||||
suffix = ".log"
|
suffix = ".log"
|
||||||
}
|
}
|
||||||
|
if w.MaxLines > 0 || w.MaxSize > 0 {
|
||||||
for ; err == nil && num <= 999; num++ {
|
for ; err == nil && num <= 999; num++ {
|
||||||
fName = filenameOnly + fmt.Sprintf(".%s.%03d%s", logTime.Format("2006-01-02"), num, suffix)
|
fName = filenameOnly + fmt.Sprintf(".%s.%03d%s", logTime.Format("2006-01-02"), num, suffix)
|
||||||
_, err = os.Lstat(fName)
|
_, 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
|
// return error if the last file checked still existed
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return fmt.Errorf("Rotate: Cannot find free log number to rename %s\n", w.Filename)
|
return fmt.Errorf("Rotate: Cannot find free log number to rename %s\n", w.Filename)
|
||||||
|
Loading…
Reference in New Issue
Block a user