logging.changeLevel(level);
return newFixedLengthResponse(OK, MIME_PLAINTEXT, null);
} catch (IllegalArgumentException e) {
- Loggers.get(ChangeLogLevelHttpAction.class).debug("Value '{}' for parameter '{}' is invalid", levelStr, PARAM_LEVEL, e);
+ Loggers.get(ChangeLogLevelHttpAction.class).debug("Value '{}' for parameter '" + PARAM_LEVEL + "' is invalid: {}", levelStr, e);
return newFixedLengthResponse(BAD_REQUEST, MIME_PLAINTEXT, format("Value '%s' for parameter '%s' is invalid", levelStr, PARAM_LEVEL));
}
}
try {
Thread.sleep(200L);
} catch (InterruptedException e) {
- LOG.debug("Graceful stop period has been interrupted", e);
+ LOG.debug("Graceful stop period has been interrupted: {}", e);
Thread.currentThread().interrupt();
break;
}
checkState(!((boolean) f.get(sqlSession)), "Autocommit must be false");
}
} catch (NoSuchFieldException | IllegalAccessException e) {
- LOG.debug("Failed to check the autocommit status of SqlSession", e);
+ LOG.debug("Failed to check the autocommit status of SqlSession: {}", e);
}
}
try (DbSession dbSession = dbClient.openSession(false)) {
return dbSession.getMapper(IsAliveMapper.class).isAlive() == IsAliveMapper.IS_ALIVE_RETURNED_VALUE;
} catch (RuntimeException e) {
- LOGGER.trace("DB connection is down", e);
+ LOGGER.trace("DB connection is down: {}", e);
return false;
}
}
emailMessage.setMessage(message);
send(emailMessage);
} catch (EmailException e) {
- LOG.debug("Fail to send test email to: " + toAddress, e);
+ LOG.debug("Fail to send test email to {}: {}", toAddress, e);
throw e;
}
}
} catch (Exception e) {
String message = String.format("Fail to download the plugin (%s, version %s) from %s (error is : %s)",
release.getArtifact().getKey(), release.getVersion().getName(), release.getDownloadUrl(), e.getMessage());
- LOG.debug(message, e);
+ LOG.debug(message);
throw new SonarException(message, e);
}
}
silentlySendError(response, SC_NOT_FOUND);
}
} catch (ClientAbortException e) {
- LOG.trace(format("Client canceled loading resource [%s] from plugin [%s]", resource, pluginKey), e);
+ LOG.trace("Client canceled loading resource [{}] from plugin [{}]: {}", resource, pluginKey, e);
} catch (Exception e) {
LOG.error(format("Unable to load resource [%s] from plugin [%s]", resource, pluginKey), e);
silentlySendError(response, SC_INTERNAL_SERVER_ERROR);
try {
response.sendError(error);
} catch (IOException e) {
- LOG.trace(format("Failed to send error code %s", error), e);
+ LOG.trace("Failed to send error code {}: {}", error, e);
}
}
underTest.doGet(request, response);
assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty();
- assertThat(logTester.logs(LoggerLevel.TRACE)).containsOnly("Failed to send error code 404");
+ assertThat(logTester.logs(LoggerLevel.TRACE)).containsOnly("Failed to send error code 404: java.io.IOException: Simulating sendError throwing IOException");
}
private void mockPluginForResourceDoesNotExist() {
underTest.doGet(request, response);
assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty();
- assertThat(logTester.logs(LoggerLevel.TRACE)).containsOnly("Failed to send error code 404");
+ assertThat(logTester.logs(LoggerLevel.TRACE)).containsOnly("Failed to send error code 404: java.io.IOException: Simulating sendError throwing IOException");
}
private void mockPluginExistsButNoResource() {
underTest.doGet(request, response);
assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty();
- assertThat(logTester.logs(LoggerLevel.TRACE)).containsOnly("Client canceled loading resource [static/foo.txt] from plugin [myplugin]");
+ assertThat(logTester.logs(LoggerLevel.TRACE)).containsOnly("Client canceled loading resource [static/foo.txt] from plugin [myplugin]: org.apache.catalina.connector.ClientAbortException: Simulating ClientAbortException");
verify(response, times(0)).sendError(anyInt());
}