Expose logPrefix in ClientResponse

This commit exposes the logPrefix field in the ClientResponse interface.

Closes gh-24146
This commit is contained in:
Arjen Poutsma 2019-12-13 10:59:33 +01:00
parent 63844c6d74
commit 09b6730f3d
3 changed files with 23 additions and 0 deletions

View File

@ -204,6 +204,19 @@ public interface ClientResponse {
*/
Mono<WebClientResponseException> createException();
/**
* Return a log message prefix to use to correlate messages for this response.
* The prefix is based on the {@linkplain ClientRequest#logPrefix() client
* log prefix}, which itself is based on the value of the request attribute
* {@link ClientRequest#LOG_ID_ATTRIBUTE} along with some extra formatting
* so that the prefix can be conveniently prepended with no further
* formatting no separators required.
* @return the log message prefix or an empty String if the
* {@link ClientRequest#LOG_ID_ATTRIBUTE} was not set.
* @since 5.2.3
*/
String logPrefix();
// Static builder methods

View File

@ -225,6 +225,11 @@ class DefaultClientResponse implements ClientResponse {
});
}
@Override
public String logPrefix() {
return this.logPrefix;
}
// Used by DefaultClientResponseBuilder
HttpRequest request() {
return this.requestSupplier.get();

View File

@ -153,6 +153,11 @@ public class ClientResponseWrapper implements ClientResponse {
return this.delegate.createException();
}
@Override
public String logPrefix() {
return this.delegate.logPrefix();
}
/**
* Implementation of the {@code Headers} interface that can be subclassed
* to adapt the headers in a