use of com.ingenico.connect.gateway.sdk.java.logging.ResponseLogMessageBuilder in project connect-sdk-java by Ingenico-ePayments.
the class DefaultConnection method logResponse.
private void logResponse(final HttpResponse response, final String requestId, final long startTime, final CommunicatorLogger logger) {
final long endTime = System.currentTimeMillis();
final long duration = endTime - startTime;
try {
final int statusCode = response.getStatusLine().getStatusCode();
final ResponseLogMessageBuilder logMessageBuilder = new ResponseLogMessageBuilder(requestId, statusCode, duration);
addHeaders(logMessageBuilder, response.getAllHeaders());
HttpEntity entity = response.getEntity();
if (entity != null && !entity.isRepeatable()) {
entity = new BufferedHttpEntity(entity);
response.setEntity(entity);
}
setBody(logMessageBuilder, entity, response.getFirstHeader(HttpHeaders.CONTENT_TYPE));
logger.log(logMessageBuilder.getMessage());
} catch (Exception e) {
logger.log(String.format("An error occurred trying to log response '%s'", requestId), e);
return;
}
}
Aggregations