Skip to content
Snippets Groups Projects
Commit ea40fcfb authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

optimize debug log

parent 51db3502
No related branches found
No related tags found
No related merge requests found
Pipeline #4331 passed
...@@ -309,14 +309,14 @@ public class HttpServiceImpl implements HttpService, Closeable, InitializingBean ...@@ -309,14 +309,14 @@ public class HttpServiceImpl implements HttpService, Closeable, InitializingBean
HttpClientContext clientContext = HttpClientContext.adapt(context); HttpClientContext clientContext = HttpClientContext.adapt(context);
HttpRequest request = clientContext.getRequest(); HttpRequest request = clientContext.getRequest();
if (!retrying) { if (!retrying) {
log.debug("Failed request to " + request.getRequestLine() + ": " + exception.getMessage()); if (debug) log.debug("Failed request to " + request.getRequestLine() + ": " + exception.getMessage());
return false; return false;
} }
boolean idempotent = !(request instanceof HttpEntityEnclosingRequest); boolean idempotent = !(request instanceof HttpEntityEnclosingRequest);
if (idempotent) { if (idempotent) {
// Retry if the request is considered idempotent // Retry if the request is considered idempotent
log.debug("Failed (but will retry) request to " + request.getRequestLine() + ": " + exception.getMessage()); if (debug) log.debug("Failed (but will retry) request to " + request.getRequestLine() + ": " + exception.getMessage());
return true; return true;
} }
return false; return false;
...@@ -429,7 +429,7 @@ public class HttpServiceImpl implements HttpService, Closeable, InitializingBean ...@@ -429,7 +429,7 @@ public class HttpServiceImpl implements HttpService, Closeable, InitializingBean
// HTTP requests limit exceed, retry when possible // HTTP requests limit exceed, retry when possible
if (retry) { if (retry) {
if (retryCount > 0) { if (retryCount > 0) {
log.debug(String.format("Service unavailable: waiting [%s ms] before retrying...", Constants.Config.TOO_MANY_REQUEST_RETRY_TIME)); if (debug) log.debug(String.format("Service unavailable: waiting [%s ms] before retrying...", Constants.Config.TOO_MANY_REQUEST_RETRY_TIME));
try { try {
Thread.sleep(Constants.Config.TOO_MANY_REQUEST_RETRY_TIME); Thread.sleep(Constants.Config.TOO_MANY_REQUEST_RETRY_TIME);
} catch (InterruptedException e) { } catch (InterruptedException e) {
...@@ -464,7 +464,7 @@ public class HttpServiceImpl implements HttpService, Closeable, InitializingBean ...@@ -464,7 +464,7 @@ public class HttpServiceImpl implements HttpService, Closeable, InitializingBean
try { try {
String stringContent = getContentAsString(content); String stringContent = getContentAsString(content);
// Add a debug before returning the result // Add a debug before returning the result
if (log.isDebugEnabled()) { if (debug) {
log.debug("Parsing response:\n" + stringContent); log.debug("Parsing response:\n" + stringContent);
} }
return stringContent; return stringContent;
...@@ -529,7 +529,7 @@ public class HttpServiceImpl implements HttpService, Closeable, InitializingBean ...@@ -529,7 +529,7 @@ public class HttpServiceImpl implements HttpService, Closeable, InitializingBean
protected boolean executeRequest(HttpClient httpClient, HttpUriRequest request) { protected boolean executeRequest(HttpClient httpClient, HttpUriRequest request) {
if (log.isDebugEnabled()) { if (debug) {
log.debug("Executing request : " + request.getRequestLine()); log.debug("Executing request : " + request.getRequestLine());
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment