-
Notifications
You must be signed in to change notification settings - Fork 939
feat: add debug-level request logging #923
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## main #923 +/- ##
==========================================
- Coverage 65.78% 56.10% -9.68%
==========================================
Files 226 227 +1
Lines 13991 13998 +7
Branches 105 105
==========================================
- Hits 9204 7854 -1350
- Misses 3848 5275 +1427
+ Partials 939 869 -70
Continue to review full report at Codecov.
|
coderd/httpmw/log.go
Outdated
func DebugLogRequest(log slog.Logger) func(http.Handler) http.Handler { | ||
return func(next http.Handler) http.Handler { | ||
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { | ||
log.Debug(context.Background(), fmt.Sprintf("%s %s", r.Method, r.URL.Path)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish there was a level trace in slog
! Seems reasonable regardless, because we'll want customers to have a way to enable this debuggability too.
I really like the simplicity of this.
coderd/httpmw/log.go
Outdated
"cdr.dev/slog" | ||
) | ||
|
||
func DebugLogRequest(log slog.Logger) func(http.Handler) http.Handler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could it be too jank to put this inline inside coderd.go
? I ask because then we'd display code coverage on it (I know we technically already have it), and it'd just add ~4 lines into that file anyhow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that.
Usually http access logs are INFO level because you want them on in production monitoring but don't want all the spam from debug logs. Could we bump it up to INFO? |
Logger level could be a configuration knob we could expose in |
Logs all requests at DEBUG level.
I found it useful, so I figured you all might also.