From 67bbec9c20f270ef0bdaec48545f2009c0fed790 Mon Sep 17 00:00:00 2001 From: Barnaby Keene Date: Sat, 21 Oct 2023 13:48:42 +0100 Subject: [PATCH] use the correct logger middleware (oops) --- app/transports/openapi/bindings/bindings.go | 6 +++--- internal/logger/logger.go | 16 ---------------- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/app/transports/openapi/bindings/bindings.go b/app/transports/openapi/bindings/bindings.go index 3ae819dcd..9e6a775c8 100644 --- a/app/transports/openapi/bindings/bindings.go +++ b/app/transports/openapi/bindings/bindings.go @@ -162,11 +162,11 @@ func addMiddleware(cfg config.Config, l *zap.Logger, router *echo.Echo, cj *Cook return func(c echo.Context) error { r := c.Request() - l.Info( - "request", + zap.L().Info( + r.URL.Path, zap.String("method", r.Method), - zap.String("path", r.URL.Path), zap.Any("query", r.URL.Query()), + zap.Any("headers", r.Header), zap.Int64("body", r.ContentLength), ) diff --git a/internal/logger/logger.go b/internal/logger/logger.go index eb027e5ae..89dbf5951 100644 --- a/internal/logger/logger.go +++ b/internal/logger/logger.go @@ -1,8 +1,6 @@ package logger import ( - "net/http" - "github.com/Southclaws/fault" "github.com/Southclaws/fault/fmsg" "go.uber.org/fx" @@ -49,17 +47,3 @@ func replaceGlobals(c config.Config, l *zap.Logger) { l.Debug("logger configured in development mode") } } - -// WithLogger is simple Zap logger HTTP middleware -func WithLogger(next http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - zap.L().Info( - r.URL.Path, - zap.String("method", r.Method), - zap.Any("query", r.URL.Query()), - zap.Any("headers", r.Header), - zap.Int64("body", r.ContentLength), - ) - next.ServeHTTP(w, r) - }) -}