diff --git a/extensions/resteasy-reactive/rest-client-reactive/runtime/src/main/java/io/quarkus/rest/client/reactive/QuarkusRestClientBuilder.java b/extensions/resteasy-reactive/rest-client-reactive/runtime/src/main/java/io/quarkus/rest/client/reactive/QuarkusRestClientBuilder.java index 16fbd147b69b6..db7ca2d7525a7 100644 --- a/extensions/resteasy-reactive/rest-client-reactive/runtime/src/main/java/io/quarkus/rest/client/reactive/QuarkusRestClientBuilder.java +++ b/extensions/resteasy-reactive/rest-client-reactive/runtime/src/main/java/io/quarkus/rest/client/reactive/QuarkusRestClientBuilder.java @@ -17,6 +17,7 @@ import org.eclipse.microprofile.rest.client.ext.QueryParamStyle; import org.eclipse.microprofile.rest.client.spi.RestClientBuilderListener; import org.jboss.resteasy.reactive.client.api.ClientLogger; +import org.jboss.resteasy.reactive.client.api.LoggingScope; import io.quarkus.rest.client.reactive.runtime.QuarkusRestClientBuilderImpl; import io.quarkus.rest.client.reactive.runtime.RestClientBuilderImpl; @@ -259,6 +260,14 @@ static QuarkusRestClientBuilder newBuilder() { */ QuarkusRestClientBuilder clientLogger(ClientLogger clientLogger); + /** + * Specifies the client logger to use. + * + * @param loggingScope to use + * @return the current builder + */ + QuarkusRestClientBuilder loggingScope(LoggingScope loggingScope); + /** * Based on the configured QuarkusRestClientBuilder, creates a new instance of the given REST interface to invoke API calls * against. diff --git a/extensions/resteasy-reactive/rest-client-reactive/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/QuarkusRestClientBuilderImpl.java b/extensions/resteasy-reactive/rest-client-reactive/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/QuarkusRestClientBuilderImpl.java index 50bb3bfc17309..a47c4fba20124 100644 --- a/extensions/resteasy-reactive/rest-client-reactive/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/QuarkusRestClientBuilderImpl.java +++ b/extensions/resteasy-reactive/rest-client-reactive/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/QuarkusRestClientBuilderImpl.java @@ -15,6 +15,7 @@ import org.eclipse.microprofile.rest.client.ext.ClientHeadersFactory; import org.eclipse.microprofile.rest.client.ext.QueryParamStyle; import org.jboss.resteasy.reactive.client.api.ClientLogger; +import org.jboss.resteasy.reactive.client.api.LoggingScope; import io.quarkus.rest.client.reactive.QuarkusRestClientBuilder; import io.quarkus.rest.client.reactive.runtime.context.ClientHeadersFactoryContextResolver; @@ -224,6 +225,12 @@ public QuarkusRestClientBuilder clientLogger(ClientLogger clientLogger) { return this; } + @Override + public QuarkusRestClientBuilder loggingScope(LoggingScope loggingScope) { + proxy.loggingScope(loggingScope); + return this; + } + @Override public T build(Class clazz) throws IllegalStateException, RestClientDefinitionException { return proxy.build(clazz); diff --git a/extensions/resteasy-reactive/rest-client-reactive/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/RestClientBuilderImpl.java b/extensions/resteasy-reactive/rest-client-reactive/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/RestClientBuilderImpl.java index 680b9f0c89692..a6e1c152ec0a5 100644 --- a/extensions/resteasy-reactive/rest-client-reactive/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/RestClientBuilderImpl.java +++ b/extensions/resteasy-reactive/rest-client-reactive/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/RestClientBuilderImpl.java @@ -70,6 +70,7 @@ public class RestClientBuilderImpl implements RestClientBuilder { private String nonProxyHosts; private ClientLogger clientLogger; + private LoggingScope loggingScope; @Override public RestClientBuilderImpl baseUrl(URL url) { @@ -167,6 +168,11 @@ public RestClientBuilderImpl clientLogger(ClientLogger clientLogger) { return this; } + public RestClientBuilderImpl loggingScope(LoggingScope loggingScope) { + this.loggingScope = loggingScope; + return this; + } + @Override public RestClientBuilderImpl executorService(ExecutorService executor) { throw new IllegalArgumentException("Specifying executor service is not supported. " + @@ -333,10 +339,15 @@ public T build(Class aClass) throws IllegalStateException, RestClientDefi RestClientsConfig restClientsConfig = arcContainer.instance(RestClientsConfig.class).get(); RestClientLoggingConfig logging = restClientsConfig.logging; - LoggingScope loggingScope = logging != null ? logging.scope.map(LoggingScope::forName).orElse(LoggingScope.NONE) - : LoggingScope.NONE; + + LoggingScope effectiveLoggingScope = loggingScope; // if a scope was specified programmatically, it takes precedence + if (effectiveLoggingScope == null) { + effectiveLoggingScope = logging != null ? logging.scope.map(LoggingScope::forName).orElse(LoggingScope.NONE) + : LoggingScope.NONE; + } + Integer loggingBodySize = logging != null ? logging.bodyLimit : 100; - clientBuilder.loggingScope(loggingScope); + clientBuilder.loggingScope(effectiveLoggingScope); clientBuilder.loggingBodySize(loggingBodySize); if (clientLogger != null) { clientBuilder.clientLogger(clientLogger);