about summary refs log tree commit diff stats
path: root/internal/server/logging.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/server/logging.go')
-rw-r--r--internal/server/logging.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/internal/server/logging.go b/internal/server/logging.go
index 5d607bb..f744931 100644
--- a/internal/server/logging.go
+++ b/internal/server/logging.go
@@ -2,7 +2,8 @@ package server
 
 import (
 	"net/http"
-	"website/internal/log"
+
+	"go.alanpearce.eu/x/log"
 )
 
 type LoggingResponseWriter struct {
@@ -22,20 +23,18 @@ func NewLoggingResponseWriter(w http.ResponseWriter) *LoggingResponseWriter {
 	return &LoggingResponseWriter{w, http.StatusOK}
 }
 
-func wrapHandlerWithLogging(wrappedHandler http.Handler) http.Handler {
+func wrapHandlerWithLogging(wrappedHandler http.Handler, log *log.Logger) http.Handler {
 	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
-		host := r.Host
 		lw := NewLoggingResponseWriter(w)
 		wrappedHandler.ServeHTTP(lw, r)
 		if r.URL.Path == "/health" {
 			return
 		}
-		statusCode := lw.statusCode
 		log.Info(
 			"http request",
 			"method", r.Method,
-			"status", statusCode,
-			"host", host,
+			"status", lw.statusCode,
+			"host", r.Host,
 			"path", r.URL.Path,
 			"location", lw.Header().Get("Location"),
 		)