Source:
<code>private Mono<Void> logRequest(final ClientLogger logger, final HttpRequest request) { if (httpLogOptions.getLogLevel().shouldLogUrl()) { logger.info("--> {}", request.getHttpMethod(), request.getUrl()); } if (httpLogOptions.getLogLevel().shouldLogHeaders()) { formatAllowableHeaders(httpLogOptions.getAllowedHeaderNames(), request, logger); } if (httpLogOptions.getLogLevel().shouldLogQueryParams()) { formatAllowableQueryParams(httpLogOptions.getAllowedQueryParamNames(), request, logger); } Mono<Void> reqBodyLoggingMono = Mono.empty(); <START> if (httpLogOptions.getLogLevel().shouldLogBody()) { <END> if (request.getBody() == null) { logger.info("(empty body)"); logger.info("--> END {}", request.getHttpMethod()); } else { boolean isHumanReadableContentType = !"application/octet-stream".equalsIgnoreCase(request.getHeaders().getValue("Content-Type")); final long contentLength = getContentLength(request.getHeaders()); if (contentLength < MAX_BODY_LOG_SIZE && isHumanReadableContentType) { try { Mono<byte[]> collectedBytes = FluxUtil.collectBytesInByteBufferStream(request.getBody()); reqBodyLoggingMono = collectedBytes.flatMap(bytes -> { String bodyString = new String(bytes, StandardCharsets.UTF_8); bodyString = prettyPrintIfNeeded( logger, request.getHeaders().getValue("Content-Type"), bodyString); logger.info("{}-byte body:%n{}", contentLength, bodyString); logger.info("--> END {}", request.getHttpMethod()); return Mono.empty(); }); } catch (Exception e) { reqBodyLoggingMono = Mono.error(e); } } else { logger.info("{}-byte body: (content not logged)", contentLength); logger.info("--> END {}", request.getHttpMethod()); } } } return reqBodyLoggingMono; }</code><technical_language>I a method call (like getLogLevel()) multiple times I prefer referred in a local variable</technical_language>

Target:
private Mono<Void> logRequest(final ClientLogger logger, final HttpRequest request) { final HttpLogDetailLevel httpLogLevel = httpLogOptions.getLogLevel(); if (httpLogLevel.shouldLogUrl()) { logger.info("--> {}", request.getHttpMethod(), request.getUrl()); formatAllowableQueryParams(httpLogOptions.getAllowedQueryParamNames(), request.getUrl().getQuery(), logger); } if (httpLogLevel.shouldLogHeaders()) { formatAllowableHeaders(httpLogOptions.getAllowedHeaderNames(), request.getHeaders(), logger); } Mono<Void> reqBodyLoggingMono = Mono.empty(); if (httpLogLevel.shouldLogBody()) { if (request.getBody() == null) { logger.info("(empty body)"); logger.info("--> END {}", request.getHttpMethod()); } else { boolean isHumanReadableContentType = !"application/octet-stream".equalsIgnoreCase(request.getHeaders().getValue("Content-Type")); final long contentLength = getContentLength(request.getHeaders()); if (contentLength < MAX_BODY_LOG_SIZE && isHumanReadableContentType) { try { Mono<byte[]> collectedBytes = FluxUtil.collectBytesInByteBufferStream(request.getBody()); reqBodyLoggingMono = collectedBytes.flatMap(bytes -> { String bodyString = new String(bytes, StandardCharsets.UTF_8); bodyString = prettyPrintIfNeeded( logger, request.getHeaders().getValue("Content-Type"), bodyString); logger.info("{}-byte body:%n{}", contentLength, bodyString); logger.info("--> END {}", request.getHttpMethod()); return Mono.empty(); }); } catch (Exception e) { reqBodyLoggingMono = Mono.error(e); } } else { logger.info("{}-byte body: (content not logged)", contentLength); logger.info("--> END {}", request.getHttpMethod()); } } } return reqBodyLoggingMono; }