Skip to content

Commit

Permalink
use global zerolog timestamp config
Browse files Browse the repository at this point in the history
  • Loading branch information
AmirAgassi committed Dec 18, 2024
1 parent d891094 commit d28a97c
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions backend/internal/middleware/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ import (
Logger Middleware
This middleware integrates with the SPUR backend's logging system to provide
structured request logging. It works in conjunction with the zerolog setup
in backend/main.go which configures:
- Unix timestamp format in production
- Human-readable timestamps (RFC3339) in development
- Console writer with pretty printing in development
structured request logging. It uses the global zerolog configuration from main.go
for timestamp formatting.
Key Features:
- Captures request ID for distributed tracing
Expand Down Expand Up @@ -47,7 +44,6 @@ func Logger() echo.MiddlewareFunc {
err := next(c)

// prepare log entry
latency := time.Since(start)
logger := log.Info()

// handle different types of errors
Expand Down Expand Up @@ -75,7 +71,7 @@ func Logger() echo.MiddlewareFunc {
Str("remote_ip", c.RealIP()).
Str("user_agent", req.UserAgent()).
Int("status", res.Status).
Dur("latency", latency).
Dur("latency", time.Since(start)).
Msg("request completed")

return err
Expand Down

0 comments on commit d28a97c

Please sign in to comment.