Hid requests for output.css and favicon from logging
This commit is contained in:
@@ -2,6 +2,7 @@ package middleware
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
@@ -28,10 +29,13 @@ func Logging(logger *zerolog.Logger, next http.Handler) http.Handler {
|
|||||||
statusCode: http.StatusOK,
|
statusCode: http.StatusOK,
|
||||||
}
|
}
|
||||||
next.ServeHTTP(wrapped, r)
|
next.ServeHTTP(wrapped, r)
|
||||||
logger.Info().
|
if !strings.Contains(r.URL.Path, "favicon.ico") &&
|
||||||
Int("status", wrapped.statusCode).
|
!strings.Contains(r.URL.Path, "output.css") {
|
||||||
Str("method", r.Method).
|
logger.Info().
|
||||||
Str("resource", r.URL.Path).
|
Int("status", wrapped.statusCode).
|
||||||
Dur("time_elapsed", time.Since(start)).Msg("Served")
|
Str("method", r.Method).
|
||||||
|
Str("resource", r.URL.Path).
|
||||||
|
Dur("time_elapsed", time.Since(start)).Msg("Served")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user