Skip to content

Commit d5425ca

Browse files
committed
fixup! feat: add debug-level request logging
1 parent ad86f37 commit d5425ca

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

coderd/coderd.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package coderd
22

33
import (
4+
"context"
5+
"fmt"
46
"net/http"
57
"net/url"
68
"sync"
@@ -56,7 +58,7 @@ func New(options *Options) (http.Handler, func()) {
5658
chitrace.Middleware(),
5759
// Specific routes can specify smaller limits.
5860
httpmw.RateLimitPerMinute(512),
59-
httpmw.DebugLogRequest(api.Logger),
61+
debugLogRequest(api.Logger),
6062
)
6163
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
6264
httpapi.Write(w, http.StatusOK, httpapi.Response{
@@ -232,3 +234,12 @@ type api struct {
232234
websocketWaitMutex sync.Mutex
233235
websocketWaitGroup sync.WaitGroup
234236
}
237+
238+
func debugLogRequest(log slog.Logger) func(http.Handler) http.Handler {
239+
return func(next http.Handler) http.Handler {
240+
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
241+
log.Debug(context.Background(), fmt.Sprintf("%s %s", r.Method, r.URL.Path))
242+
next.ServeHTTP(rw, r)
243+
})
244+
}
245+
}

coderd/httpmw/log.go

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)