From f7f1f8813bf7a3d276aef0fea2afa2e1bfaea3d9 Mon Sep 17 00:00:00 2001 From: manuraf Date: Fri, 23 Feb 2024 09:29:28 +0100 Subject: [PATCH] logging response --- ... => CustomClientRequestLoggingFilter.java} | 4 +-- .../CustomClientResponseLoggingFilter.java | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) rename apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/filter/{CustomClientLoggingFilter.java => CustomClientRequestLoggingFilter.java} (87%) create mode 100644 apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/filter/CustomClientResponseLoggingFilter.java diff --git a/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/filter/CustomClientLoggingFilter.java b/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/filter/CustomClientRequestLoggingFilter.java similarity index 87% rename from apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/filter/CustomClientLoggingFilter.java rename to apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/filter/CustomClientRequestLoggingFilter.java index 20fcf42c9..4ecd5da78 100644 --- a/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/filter/CustomClientLoggingFilter.java +++ b/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/filter/CustomClientRequestLoggingFilter.java @@ -10,9 +10,9 @@ import java.io.IOException; @Provider -public class CustomClientLoggingFilter implements ResteasyReactiveClientRequestFilter { +public class CustomClientRequestLoggingFilter implements ResteasyReactiveClientRequestFilter { - private static final Logger LOG = Logger.getLogger(CustomClientLoggingFilter.class); + private static final Logger LOG = Logger.getLogger(CustomClientRequestLoggingFilter.class); @Override public void filter(ClientRequestContext requestContext) throws IOException { diff --git a/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/filter/CustomClientResponseLoggingFilter.java b/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/filter/CustomClientResponseLoggingFilter.java new file mode 100644 index 000000000..788f44d9e --- /dev/null +++ b/apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/filter/CustomClientResponseLoggingFilter.java @@ -0,0 +1,29 @@ +package it.pagopa.selfcare.onboarding.filter; + + +import jakarta.ws.rs.client.ClientRequestContext; +import jakarta.ws.rs.client.ClientResponseContext; +import jakarta.ws.rs.ext.Provider; +import org.jboss.logging.Logger; +import org.jboss.resteasy.reactive.client.spi.ResteasyReactiveClientRequestContext; +import org.jboss.resteasy.reactive.client.spi.ResteasyReactiveClientResponseFilter; + +@Provider +public class CustomClientResponseLoggingFilter implements ResteasyReactiveClientResponseFilter { + + private static final Logger LOG = Logger.getLogger(CustomClientResponseLoggingFilter.class); + + @Override + public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) { + ResteasyReactiveClientResponseFilter.super.filter(requestContext, responseContext); + } + + @Override + public void filter(ResteasyReactiveClientRequestContext requestContext, ClientResponseContext responseContext) { + String endpoint = requestContext.getUri().getPath(); + String method = requestContext.getMethod(); + int status = responseContext.getStatus(); + LOG.infof("Response: method: %s, endpoint: %s, status [%d]", method, endpoint, status); + + } +}