package server import ( "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" "time" ) func Logger() echo.MiddlewareFunc { return func(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) (err error) { req := c.Request() res := c.Response() start := time.Now() if err = next(c); err != nil { c.Error(err) } stop := time.Now() log.Info(). Str("remote_ip", c.RealIP()). Str("host", req.Host). Str("uri", req.RequestURI). Str("method", req.Method). Str("path", req.URL.Path). Str("user_agent", req.UserAgent()). Int("status", res.Status). Str("latency", stop.Sub(start).String()). Msg("Request") return } } }