middleware/log: make {size} the length of the request (#449)

* middleware/log: make {size} the length of the request

{size} is the lenght of the request, {rsize} is the length of the
reply.

* Fix test
This commit is contained in:
Miek Gieben 2016-11-30 20:44:00 +00:00 committed by GitHub
parent b85c6788dd
commit b086e5f64d
4 changed files with 10 additions and 8 deletions

View file

@ -42,6 +42,7 @@ func New(r *dns.Msg, rr *dnsrecorder.Recorder, emptyValue string) Replacer {
"{when}": func() string {
return time.Now().Format(timeFormat)
}(),
"{size}": strconv.Itoa(req.Len()),
"{remote}": req.IP(),
"{port}": req.Port(),
},
@ -53,7 +54,7 @@ func New(r *dns.Msg, rr *dnsrecorder.Recorder, emptyValue string) Replacer {
rcode = strconv.Itoa(rr.Rcode)
}
rep.replacements["{rcode}"] = rcode
rep.replacements["{size}"] = strconv.Itoa(rr.Len)
rep.replacements["{rsize}"] = strconv.Itoa(rr.Len)
rep.replacements["{duration}"] = time.Since(rr.Start).String()
}