Change duration output in query log to milliseconds (#836)

This commit is contained in:
Ferdinand Holzer 2019-05-26 21:53:15 +02:00 committed by Frank Denis
parent eab77ff871
commit da2e4b0b4b
1 changed files with 2 additions and 2 deletions

View File

@ -83,10 +83,10 @@ func (plugin *PluginQueryLog) Eval(pluginsState *PluginsState, msg *dns.Msg) err
year, month, day := now.Date()
hour, minute, second := now.Clock()
tsStr := fmt.Sprintf("[%d-%02d-%02d %02d:%02d:%02d]", year, int(month), day, hour, minute, second)
line = fmt.Sprintf("%s\t%s\t%s\t%s\t%s\t%v\t%v\n", tsStr, clientIPStr, StringQuote(qName), qType, returnCode, requestDuration, forwardDuration)
line = fmt.Sprintf("%s\t%s\t%s\t%s\t%s\t%d\t%d\n", tsStr, clientIPStr, StringQuote(qName), qType, returnCode, requestDuration/time.Millisecond, forwardDuration/time.Millisecond)
} else if plugin.format == "ltsv" {
line = fmt.Sprintf("time:%d\thost:%s\tmessage:%s\ttype:%s\treturn:%s\treqDuration:%d\tfwdDuration:%d\n",
time.Now().Unix(), clientIPStr, StringQuote(qName), qType, returnCode, requestDuration.Nanoseconds(), forwardDuration.Nanoseconds())
time.Now().Unix(), clientIPStr, StringQuote(qName), qType, returnCode, requestDuration/time.Millisecond, forwardDuration/time.Millisecond)
} else {
dlog.Fatalf("Unexpected log format: [%s]", plugin.format)
}