diff options
Diffstat (limited to 'internal/server/logging.go')
-rw-r--r-- | internal/server/logging.go | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/internal/server/logging.go b/internal/server/logging.go index 372972f..6e2f7c8 100644 --- a/internal/server/logging.go +++ b/internal/server/logging.go @@ -1,11 +1,10 @@ package server import ( - "fmt" - "io" "net/http" "github.com/pkg/errors" + "go.alanpearce.eu/x/log" ) type LoggingResponseWriter struct { @@ -42,7 +41,7 @@ func NewLoggingResponseWriter(w http.ResponseWriter) *LoggingResponseWriter { type wrappedHandlerOptions struct { defaultHostname string - logger io.Writer + logger *log.Logger } func wrapHandlerWithLogging(wrappedHandler http.Handler, opts wrappedHandlerOptions) http.Handler { @@ -54,13 +53,17 @@ func wrapHandlerWithLogging(wrappedHandler http.Handler, opts wrappedHandlerOpti lw := NewLoggingResponseWriter(w) wrappedHandler.ServeHTTP(lw, r) statusCode := lw.statusCode - fmt.Fprintf( - opts.logger, - "%s %s %d %s %s\n", + opts.logger.Info( + "http request", + "scheme", scheme, + "method", r.Method, + "code", statusCode, + "path", r.URL.Path, + "location", lw.Header().Get("Location"), ) }) |