From 8807c327d1c611633300f426c3ccd139f220dbc4 Mon Sep 17 00:00:00 2001 From: astaxie Date: Sat, 29 Jun 2013 14:39:02 +0800 Subject: [PATCH] fix log delete --- log.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/log.go b/log.go index f46b9343..ef3bc958 100644 --- a/log.go +++ b/log.go @@ -202,7 +202,9 @@ func (w *FileLogWriter) deleteOldLog() { dir := path.Dir(w.filename) 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) { - os.Remove(path) + if strings.HasPrefix(filepath.Base(path), filepath.Base(w.filename)) { + os.Remove(path) + } } return nil })