1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-25 22:11:29 +00:00

fix log delete

This commit is contained in:
astaxie 2013-06-29 14:39:02 +08:00
parent d627ec013e
commit 8807c327d1

2
log.go
View File

@ -202,8 +202,10 @@ func (w *FileLogWriter) deleteOldLog() {
dir := path.Dir(w.filename) dir := path.Dir(w.filename)
filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
if !info.IsDir() && info.ModTime().Unix() < (time.Now().Unix()-60*60*24*w.maxdays) { if !info.IsDir() && info.ModTime().Unix() < (time.Now().Unix()-60*60*24*w.maxdays) {
if strings.HasPrefix(filepath.Base(path), filepath.Base(w.filename)) {
os.Remove(path) os.Remove(path)
} }
}
return nil return nil
}) })
} }