summaryrefslogtreecommitdiff
path: root/logging/middleware.go
diff options
context:
space:
mode:
authortjpcc <tjp@ctrl-c.club>2023-05-01 21:43:21 -0600
committertjpcc <tjp@ctrl-c.club>2023-05-01 21:43:21 -0600
commite4db6e1b99018bbcf70051adc15963751cb94215 (patch)
tree6b588e427bd8f797bfacad8bf01b950c787d0329 /logging/middleware.go
parent0d5e5589140bec6c8a834b7f896258d62e739bfe (diff)
still log requests for which we failed to find a handler
Diffstat (limited to 'logging/middleware.go')
-rw-r--r--logging/middleware.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/logging/middleware.go b/logging/middleware.go
index ffce1b7..b19c273 100644
--- a/logging/middleware.go
+++ b/logging/middleware.go
@@ -16,6 +16,15 @@ func LogRequests(logger Logger) sr.Middleware {
response := inner.Handle(ctx, request)
if response != nil {
response.Body = loggingBody(logger, request, response, start)
+ } else {
+ end := time.Now()
+ logger.Log(
+ "msg", "request",
+ "ts", end.UTC(),
+ "dur", end.Sub(start),
+ "url", request.URL,
+ "status", "(not found)",
+ )
}
return response