Skip to content

Commit

Permalink
fix: remove duplicate time log field (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
Houtmann authored Oct 9, 2023
1 parent 69ec446 commit 7a7e2ad
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions middleware/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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),
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion server/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 7a7e2ad

Please sign in to comment.