Skip to content

Commit

Permalink
use the correct logger middleware (oops)
Browse files Browse the repository at this point in the history
  • Loading branch information
Southclaws committed Oct 21, 2023
1 parent 72bcfbb commit 67bbec9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
6 changes: 3 additions & 3 deletions app/transports/openapi/bindings/bindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)

Expand Down
16 changes: 0 additions & 16 deletions internal/logger/logger.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package logger

import (
"net/http"

"github.com/Southclaws/fault"
"github.com/Southclaws/fault/fmsg"
"go.uber.org/fx"
Expand Down Expand Up @@ -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)
})
}

1 comment on commit 67bbec9

@vercel
Copy link

@vercel vercel bot commented on 67bbec9 Oct 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.