From 7a7e2ad9a4759e19f8eb6324253a0b8d09fc8fa1 Mon Sep 17 00:00:00 2001 From: Had Date: Mon, 9 Oct 2023 09:11:53 +0200 Subject: [PATCH] fix: remove duplicate time log field (#180) --- middleware/log.go | 5 +---- server/http.go | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/middleware/log.go b/middleware/log.go index 62dd3e73..952a99b2 100644 --- a/middleware/log.go +++ b/middleware/log.go @@ -7,12 +7,11 @@ import ( "github.com/gin-gonic/gin" "github.com/google/uuid" - "github.com/thoas/picfit/config" "github.com/thoas/picfit/constants" loggerpkg "github.com/thoas/picfit/logger" ) -func NewLogger(cfg *config.Config, logger *slog.Logger) gin.HandlerFunc { +func NewLogger(logger *slog.Logger) gin.HandlerFunc { return func(c *gin.Context) { var ( ctx = c.Request.Context() @@ -27,7 +26,6 @@ func NewLogger(cfg *config.Config, logger *slog.Logger) gin.HandlerFunc { c.Next() - end := time.Now() attributes := []slog.Attr{ slog.Int("status", c.Writer.Status()), slog.String("method", c.Request.Method), @@ -36,7 +34,6 @@ func NewLogger(cfg *config.Config, logger *slog.Logger) gin.HandlerFunc { slog.String("ip", c.ClientIP()), slog.Duration("duration", time.Since(start)), slog.String("user-agent", c.Request.UserAgent()), - slog.Time("time", end.UTC()), } if len(c.Errors) > 0 { diff --git a/server/http.go b/server/http.go index ecaf40fb..21da73d5 100644 --- a/server/http.go +++ b/server/http.go @@ -76,7 +76,7 @@ func (s *HTTPServer) Init() error { router.Use(middleware.Recover) } - router.Use(middleware.NewLogger(s.config, s.processor.Logger)) + router.Use(middleware.NewLogger(s.processor.Logger)) router.Use(middleware.Metrics) if s.config.Sentry != nil {