Refine logging in ExchangeFunctions
Notably do not log error signal since we are letting that propagate. Also improve logging messages vs relying on the log operator. Issue: SPR-16484
This commit is contained in:
parent
b089ded5b0
commit
73095955bf
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,10 +16,11 @@
|
|||
|
||||
package org.springframework.web.reactive.function.client;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.client.reactive.ClientHttpConnector;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
|
@ -29,10 +30,14 @@ import org.springframework.util.Assert;
|
|||
* {@code ClientHttpConnector}.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 5.0
|
||||
*/
|
||||
public abstract class ExchangeFunctions {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ExchangeFunctions.class);
|
||||
|
||||
|
||||
/**
|
||||
* Create a new {@link ExchangeFunction} with the given connector. This method uses
|
||||
* {@linkplain ExchangeStrategies#withDefaults() default strategies}.
|
||||
|
@ -73,9 +78,16 @@ public abstract class ExchangeFunctions {
|
|||
return this.connector
|
||||
.connect(request.method(), request.url(),
|
||||
clientHttpRequest -> request.writeTo(clientHttpRequest, this.strategies))
|
||||
.log("org.springframework.web.reactive.function.client", Level.FINE)
|
||||
.map(clientHttpResponse -> new DefaultClientResponse(clientHttpResponse,
|
||||
this.strategies));
|
||||
.doOnSubscribe(subscription -> logger.debug("Subscriber present"))
|
||||
.doOnRequest(n -> logger.debug("Demand signaled"))
|
||||
.doOnCancel(() -> logger.debug("Cancelling request"))
|
||||
.map(response -> {
|
||||
HttpStatus status = response.getStatusCode();
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Response received, status: " + status + " " + status.getReasonPhrase());
|
||||
}
|
||||
return new DefaultClientResponse(response, this.strategies);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue