From 3379a2b7ed6381eac5a2b5fcfb22f0a3c02dc613 Mon Sep 17 00:00:00 2001 From: JessonChan Date: Fri, 4 Mar 2016 10:43:57 +0800 Subject: [PATCH] remove file bug fixed remove file by filename and file suffix --- logs/file.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/logs/file.go b/logs/file.go index cdea1457..9d3f78a0 100644 --- a/logs/file.go +++ b/logs/file.go @@ -256,7 +256,8 @@ func (w *fileLogWriter) deleteOldLog() { }() if !info.IsDir() && info.ModTime().Unix() < (time.Now().Unix()-60*60*24*w.MaxDays) { - if strings.HasPrefix(filepath.Base(path), filepath.Base(w.Filename)) { + if strings.HasPrefix(filepath.Base(path), w.fileNameOnly) && + strings.HasSuffix(filepath.Base(path), w.suffix) { os.Remove(path) } }