This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
The following commit(s) were added to refs/heads/master by this push:
new 1bfc514e07 [FIX] LOG JMAP errors
1bfc514e07 is described below
commit 1bfc514e074bd8c96020067739a1e4f19f152cc0
Author: Benoit TELLIER <[email protected]>
AuthorDate: Sun Feb 18 21:33:50 2024 +0100
[FIX] LOG JMAP errors
---
.../src/main/scala/org/apache/james/jmap/method/Method.scala | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git
a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/Method.scala
b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/Method.scala
index 0f4fb4bd5a..ff02533f92 100644
---
a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/Method.scala
+++
b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/Method.scala
@@ -28,9 +28,14 @@ import org.apache.james.jmap.routes.{ProcessingContext,
SessionSupplier}
import org.apache.james.mailbox.MailboxSession
import org.apache.james.mailbox.exception.MailboxNotFoundException
import org.apache.james.metrics.api.MetricFactory
+import org.apache.james.util.MDCStructuredLogger
import org.reactivestreams.Publisher
+import org.slf4j.LoggerFactory
import reactor.core.scala.publisher.SFlux
+object Method {
+ val LOGGER = LoggerFactory.getLogger(classOf[Method])
+}
case class AccountNotFoundException() extends IllegalArgumentException
case class ForbiddenException() extends RuntimeException
@@ -62,7 +67,12 @@ trait MethodRequiringAccountId[REQUEST <: WithAccountId]
extends Method {
translatedMailboxSession =
sessionTranslator.delegateIfNeeded(mailboxSession, request.accountId)
} yield {
translatedMailboxSession.flatMapMany(translatedSession =>
- SFlux(doProcess(capabilities, invocation, translatedSession, request)))
+ SFlux(doProcess(capabilities, invocation, translatedSession, request))
+ .doOnError(e => MDCStructuredLogger.forLogger(Method.LOGGER)
+ .field("protocol", "JMAP")
+ .field("username", mailboxSession.getUser.asString())
+ .field("method", invocation.invocation.methodName.value.value)
+ .log(logger => logger.error("Failed executing a JMAP method", e))))
}
val result: SFlux[InvocationWithContext] =
SFlux.fromPublisher(either.fold(e => SFlux.error[InvocationWithContext](e), r
=> r))
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]