From 80fa51468cceb99d721bac50bb28ea72c1a4d276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=9F=B9=E8=BF=9C?= Date: Tue, 7 Nov 2017 22:58:39 +0800 Subject: [PATCH] avoid unnecessary read of large log file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If w.MaxLines is not set, there is no need to calc large log file’s lines. It may takes more than 10mins to calc a 10G file. --- logs/file.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logs/file.go b/logs/file.go index e8c1f37e..8e5117d2 100644 --- a/logs/file.go +++ b/logs/file.go @@ -182,7 +182,7 @@ func (w *fileLogWriter) initFd() error { if w.Daily { go w.dailyRotate(w.dailyOpenTime) } - if fInfo.Size() > 0 { + if fInfo.Size() > 0 && w.MaxLines > 0 { count, err := w.lines() if err != nil { return err