From 748ee52aa7405ea5536b111ab113b0003d638592 Mon Sep 17 00:00:00 2001 From: Benjamin Cavy Date: Sat, 18 Jan 2025 20:23:48 +0100 Subject: [PATCH] chore: separate client & server error loggers --- app/fr/maif/izanami/errors/IzanamiHttpErrorHandler.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/fr/maif/izanami/errors/IzanamiHttpErrorHandler.scala b/app/fr/maif/izanami/errors/IzanamiHttpErrorHandler.scala index f6571121..4026ca68 100644 --- a/app/fr/maif/izanami/errors/IzanamiHttpErrorHandler.scala +++ b/app/fr/maif/izanami/errors/IzanamiHttpErrorHandler.scala @@ -15,7 +15,8 @@ class IzanamiHttpErrorHandler(env: Env) extends HttpErrorHandler { implicit val ec: ExecutionContext = env.executionContext - lazy val logger = Logger("izanami-error-handler") + lazy val clientErrorLogger = Logger("izanami-client-error-handler") + lazy val serverErrorLogger = Logger("izanami-seerver-error-handler") override def onClientError(request: mvc.RequestHeader, statusCode: Int, message: String): Future[Result] = { val uuid = @@ -25,7 +26,7 @@ class IzanamiHttpErrorHandler(env: Env) extends HttpErrorHandler { val errorMessage = s"Client Error [$uuid]: $msg on ${request.uri} ($statusCode)" - logger.error(errorMessage) + clientErrorLogger.error(errorMessage) Future.successful(Status(statusCode)(Json.obj("message" -> msg))) } @@ -33,7 +34,7 @@ class IzanamiHttpErrorHandler(env: Env) extends HttpErrorHandler { val uuid = java.util.UUID.nameUUIDFromBytes(new SecureRandom().generateSeed(16)) - logger.error( + serverErrorLogger.error( s"Server Error [$uuid]: ${exception.getMessage} on ${request.uri}", exception) Future.successful(Status(INTERNAL_SERVER_ERROR)(Json.obj("message" -> exception.getMessage)).withHeaders(("content-type", "application/json")))