~jan0sch/smederee

Showing details for patch 1d9dcd34e28da0176abc60c91a12a57cd7e5728b.
2024-06-10 (Mon), 5:05 PM - Jens Grassel - 1d9dcd34e28da0176abc60c91a12a57cd7e5728b

Hub: Cleanup logErrors function.

If no request id is found in the headers, simply use an empty string to not
clutter up the logs with "null" values.
Summary of changes
1 files modified with 3 lines added and 3 lines removed
  • modules/hub/src/main/scala/de/smederee/hub/HubServer.scala with 3 added and 3 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 15:01:25.274647324 +0000
+++ new-smederee/modules/hub/src/main/scala/de/smederee/hub/HubServer.scala	2025-01-11 15:01:25.274647324 +0000
@@ -140,12 +140,12 @@
       *   The error (exception) thrown during the request.
       */
     private def logErrors(request: Request[IO], error: Throwable): IO[Unit] =
-        IO(request.headers.get(ci"X-Request-ID").fold("null")(_.head.value)).map { reqId =>
+        IO(request.headers.get(ci"X-Request-ID").fold("")(_.head.value)).map { reqId =>
             val message = (request, error) match {
-                case (req, _: MessageFailure) =>
+                case (_, _: MessageFailure) =>
                     s"""Message failure handling request $reqId: ${request.method} ${request.pathInfo} from ${request.remoteAddr
                             .getOrElse("<unknown>")}"""
-                case (req, _) =>
+                case (_, _) =>
                     s"""Error servicing request $reqId: ${request.method} ${request.pathInfo} from ${request.remoteAddr
                             .getOrElse("<unknown>")}"""
             }