Skip to content

Commit

Permalink
Disable log message creation when not debugging (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-mcgoldrick authored Apr 1, 2024
1 parent 3699680 commit 12fe186
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ private void sendRequest(BaseRequest request, @Nonnull HttpMethod method, String

try {
uri = method.getURI().toString();
LOG.debug(request.getLogUtil().getLogMessage("About to " + method.getName() + " request to " + uri + " with requestBody " + requestBody, LogEventType.Informational));
if (LOG.isDebugEnabled()) LOG.debug(request.getLogUtil().getLogMessage(
"About to " + method.getName() + " request to " + uri + " with requestBody " + requestBody, LogEventType.Informational));
List<String> cookies = new ArrayList<String>();
if (httpclient != null && httpclient.getState() != null && httpclient.getState().getCookies() != null) {
cookies = Arrays.stream(httpclient.getState().getCookies()).map(cookie -> "REQUEST COOKIE: " + cookie.toExternalForm() + " (domain=" + cookie.getDomain() + " : path=" + cookie.getPath() + ")").collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ public void setProxy(String proxyhost, int proxyport) {
private void sendRequest(BaseRequest request, @Nonnull HttpRequestBase method, String requestBody) {
long waitTime = 0L;
String uri = method.getURI().toString();
LOG.debug(request.getLogUtil().getLogMessage("About to " + method.getMethod() + " request to " + uri + " with requestBody " + requestBody, LogEventType.Informational));
if (LOG.isDebugEnabled()) LOG.debug(request.getLogUtil().getLogMessage(
"About to " + method.getMethod() + " request to " + uri + " with requestBody " + requestBody, LogEventType.Informational));
List<String> cookies = new ArrayList<String>();
if (context.getCookieStore().getCookies() != null) {
cookies = context.getCookieStore().getCookies().stream().map(cookie -> "REQUEST COOKIE: " + cookie.toString()).collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ public void setProxy(String proxyhost, int proxyport) {
}

private void sendRequest(BaseRequest request, @Nonnull SimpleHttpRequest method) {
LOG.debug(request.getLogUtil().getLogMessage("About to " + method.getMethod() + " request to " + method.getRequestUri() + " with requestBody " + method.getBody(), LogEventType.Informational));
if (LOG.isDebugEnabled()) LOG.debug(request.getLogUtil().getLogMessage(
"About to " + method.getMethod() + " request to " + method.getRequestUri() + " with requestBody " + method.getBody(), LogEventType.Informational));
List<String> cookies = new ArrayList<String>();
if (context.getCookieStore().getCookies() != null) {
cookies = context.getCookieStore().getCookies().stream()
Expand Down

0 comments on commit 12fe186

Please sign in to comment.