We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1858c2c commit c1103b5Copy full SHA for c1103b5
pkg/api/middleware/logger.go
@@ -4,18 +4,21 @@ import (
4
"log/slog"
5
"net/http"
6
"sync"
7
+ "time"
8
)
9
10
func RequestLogger(h http.Handler) http.Handler {
11
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
12
+ start := time.Now()
13
lw := &loggingResponseWriter{w: w}
14
defer func() {
- slog.DebugContext(r.Context(), "request complete",
15
+ slog.InfoContext(r.Context(), "request complete",
16
"method", r.Method,
17
"mux_pattern", r.Pattern,
18
"uri", r.URL,
19
"status", lw.statusCode,
- "status_text", http.StatusText(lw.statusCode))
20
+ "status_text", http.StatusText(lw.statusCode),
21
+ "duration", time.Since(start))
22
}()
23
h.ServeHTTP(lw, r)
24
})
0 commit comments