~jan0sch/smederee

Showing details for patch 4f1041ee78722baec63b533c8e1adca903ed0e05.
2024-06-10 (Mon), 5:01 PM - Jens Grassel - 4f1041ee78722baec63b533c8e1adca903ed0e05

Hub: Enable logging of requests on the trace level.

Include the RequestLogger middleware and log all requests with their id on the
trace level to allow detailed debugging/tracing.
Summary of changes
1 files modified with 17 lines added and 10 lines removed
  • modules/hub/src/main/scala/de/smederee/hub/HubServer.scala with 17 added and 10 removed lines
diff -rN -u old-smederee/modules/hub/src/main/scala/de/smederee/hub/HubServer.scala new-smederee/modules/hub/src/main/scala/de/smederee/hub/HubServer.scala
--- old-smederee/modules/hub/src/main/scala/de/smederee/hub/HubServer.scala	2025-01-11 14:41:03.893252939 +0000
+++ new-smederee/modules/hub/src/main/scala/de/smederee/hub/HubServer.scala	2025-01-11 14:41:03.897252941 +0000
@@ -45,6 +45,7 @@
 import org.http4s.server.middleware.ErrorAction
 import org.http4s.server.middleware.ErrorHandling
 import org.http4s.server.middleware.RequestId
+import org.http4s.server.middleware.RequestLogger
 import org.http4s.server.staticcontent.resourceServiceBuilder
 import org.slf4j.LoggerFactory
 import org.typelevel.ci.CIStringSyntax
@@ -537,16 +538,22 @@
                     hubWebService = Router(
                         Constants.assetsPath.path.toAbsolute.toString -> assetsRoutes,
                         "/" -> RequestId.httpRoutes(
-                            protectedRoutesWithFallThrough <+>
-                                authenticationRoutes.routes <+>
-                                resetPasswordRoutes.routes <+>
-                                accountManagementRoutes.routes <+>
-                                signUpRoutes.routes <+>
-                                ticketLabelRoutes.routes <+>
-                                ticketMilestoneRoutes.routes <+>
-                                ticketRoutes.routes <+>
-                                vcsRepoRoutes.routes <+>
-                                landingPages.routes
+                            RequestLogger.httpRoutes(
+                                logHeaders = true,
+                                logBody = true,
+                                logAction = Option((msg: String) => IO(log.trace(msg)))
+                            )(
+                                protectedRoutesWithFallThrough <+>
+                                    authenticationRoutes.routes <+>
+                                    resetPasswordRoutes.routes <+>
+                                    accountManagementRoutes.routes <+>
+                                    signUpRoutes.routes <+>
+                                    ticketLabelRoutes.routes <+>
+                                    ticketMilestoneRoutes.routes <+>
+                                    ticketRoutes.routes <+>
+                                    vcsRepoRoutes.routes <+>
+                                    landingPages.routes
+                            )
                         )
                     ).orNotFound
                     // Create our ssh server fiber (or a dummy one if disabled).