use of com.ingenico.connect.gateway.sdk.java.logging.RequestLogMessageBuilder in project connect-sdk-java by Ingenico-ePayments.
the class DefaultConnection method logRequest.
// logging code
private void logRequest(final HttpRequest request, final String requestId, final CommunicatorLogger logger) {
try {
RequestLine requestLine = request.getRequestLine();
String method = requestLine.getMethod();
String uri = requestLine.getUri();
final RequestLogMessageBuilder logMessageBuilder = new RequestLogMessageBuilder(requestId, method, uri);
addHeaders(logMessageBuilder, request.getAllHeaders());
if (request instanceof HttpEntityEnclosingRequest) {
final HttpEntityEnclosingRequest entityEnclosingRequest = (HttpEntityEnclosingRequest) request;
HttpEntity entity = entityEnclosingRequest.getEntity();
if (entity != null && !entity.isRepeatable()) {
entity = new BufferedHttpEntity(entity);
entityEnclosingRequest.setEntity(entity);
}
setBody(logMessageBuilder, entity, request.getFirstHeader(HttpHeaders.CONTENT_TYPE));
}
logger.log(logMessageBuilder.getMessage());
} catch (Exception e) {
logger.log(String.format("An error occurred trying to log request '%s'", requestId), e);
return;
}
}
Aggregations