Maint: pass only single strings to logger methods

- Do not assume formatting from logger's interface
- Allow to change golibs in the future to accept only strings for logger methods
This commit is contained in:
Quentin McGaw (desktop)
2021-07-23 17:36:08 +00:00
parent 21f4cf7ab5
commit 3c44214d01
34 changed files with 134 additions and 127 deletions

View File

@@ -2,6 +2,7 @@ package server
import (
"net/http"
"strconv"
"sync"
"time"
@@ -34,8 +35,10 @@ func (m *logMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request) {
statefulWriter := &statefulResponseWriter{httpWriter: w}
m.childHandler.ServeHTTP(statefulWriter, r)
duration := m.timeNow().Sub(tStart)
m.logger.Info("%d %s %s wrote %dB to %s in %s",
statefulWriter.statusCode, r.Method, r.RequestURI, statefulWriter.length, r.RemoteAddr, duration)
m.logger.Info(strconv.Itoa(statefulWriter.statusCode) + " " +
r.Method + " " + r.RequestURI +
" wrote " + strconv.Itoa(statefulWriter.length) + "B to " +
r.RemoteAddr + " in " + duration.String())
}
func (m *logMiddleware) setEnabled(enabled bool) {