From e3565408728d622e7d9b2f9bdc1419561b7dc549 Mon Sep 17 00:00:00 2001 From: Andrey Meshkov Date: Fri, 12 Oct 2018 20:36:57 +0300 Subject: [PATCH] fix crash --- coredns_plugin/querylog_file.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/coredns_plugin/querylog_file.go b/coredns_plugin/querylog_file.go index b9078ef2..2f23bfa5 100644 --- a/coredns_plugin/querylog_file.go +++ b/coredns_plugin/querylog_file.go @@ -232,7 +232,11 @@ func genericLoader(onEntry func(entry *logEntry) error, needMore func() bool, ti } } elapsed := time.Since(now) - log.Printf("file \"%s\": read %d entries in %v, %v/entry", file, i, elapsed, elapsed/time.Duration(i)) + var perunit time.Duration + if i > 0 { + perunit = elapsed / time.Duration(i) + } + log.Printf("file \"%s\": read %d entries in %v, %v/entry", file, i, elapsed, perunit) } return nil }