logging: add error to udp logs

This also makes the format of UDP and HTTP logs a little more similar.
This commit is contained in:
Jimmy Zelinskie
2015-06-26 21:07:29 -04:00
parent 9a0d86610c
commit 0741df3575
3 changed files with 26 additions and 16 deletions
+3 -4
View File
@@ -34,12 +34,11 @@ type Server struct {
// stats, logging, and handling errors.
func makeHandler(handler ResponseHandler) httprouter.Handle {
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
var msg string
start := time.Now()
httpCode, err := handler(w, r, p)
duration := time.Since(start)
var msg string
if err != nil {
msg = err.Error()
} else if httpCode != http.StatusOK {
@@ -58,9 +57,9 @@ func makeHandler(handler ResponseHandler) httprouter.Handle {
}
if len(msg) > 0 {
glog.Errorf("[%d - %9s] %s (%s)", httpCode, duration, reqString, msg)
glog.Errorf("[HTTP - %9s] %s (%d - %s)", duration, reqString, httpCode, msg)
} else {
glog.Infof("[%d - %9s] %s", httpCode, duration, reqString)
glog.Infof("[HTTP - %9s] %s (%d)", duration, reqString, httpCode)
}
}