aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pkg/ext/log.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/pkg/ext/log.go b/pkg/ext/log.go
index a9d26a9..2439f19 100644
--- a/pkg/ext/log.go
+++ b/pkg/ext/log.go
@@ -8,6 +8,7 @@ import (
type statusWraper struct {
statusCode int
+ size int
innerWriter http.ResponseWriter
}
@@ -16,6 +17,7 @@ func (s *statusWraper) Header() http.Header {
}
func (s *statusWraper) Write(b []byte) (int, error) {
+ s.size += len(b)
return s.innerWriter.Write(b)
}
@@ -42,12 +44,15 @@ func Log(next http.HandlerFunc) http.HandlerFunc {
t := time.Now()
s := wrap(w)
next(s, r)
+ encoding := s.Header().Get("Content-Encoding")
slog.Info(
- "Http request",
+ "HTTP request",
"method", r.Method,
"code", s.StatusCode(),
"path", r.URL,
+ "encoding", encoding,
"elapsed", time.Since(t),
+ "body-size", s.size,
)
}
}