avoid unnecessary read of large log file

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.
This commit is contained in:
陈培远 2017-11-07 22:58:39 +08:00
parent e211e4839c
commit 80fa51468c
1 changed files with 1 additions and 1 deletions

View File

@ -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