]> source.dussan.org Git - sonarqube.git/commitdiff
Fix some logger calls
authorDaniel Trebbien <dtrebbien@gmail.com>
Thu, 19 Oct 2017 18:16:19 +0000 (13:16 -0500)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 19 Oct 2017 18:16:19 +0000 (20:16 +0200)
server/sonar-ce/src/main/java/org/sonar/ce/logging/ChangeLogLevelHttpAction.java
server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImpl.java
server/sonar-db-dao/src/main/java/org/sonar/db/DBSessionsImpl.java
server/sonar-server/src/main/java/org/sonar/server/health/DbConnectionNodeCheck.java
server/sonar-server/src/main/java/org/sonar/server/notification/email/EmailNotificationChannel.java
server/sonar-server/src/main/java/org/sonar/server/plugins/PluginDownloader.java
server/sonar-server/src/main/java/org/sonar/server/plugins/StaticResourcesServlet.java
server/sonar-server/src/test/java/org/sonar/server/plugins/StaticResourcesServletTest.java

index aa67614d5885ec1e2ac8984ed3e21be7b0458f57..51e6cbbbf198353d948b561c3b06857a3a53fbc9 100644 (file)
@@ -63,7 +63,7 @@ public class ChangeLogLevelHttpAction implements HttpAction {
       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));
     }
   }
index 4792bd27ed4504fcb07043a743b655bd5fef81fc..6dec30bfdc85054f6710fcd133faabd30f220558 100644 (file)
@@ -87,7 +87,7 @@ public class CeProcessingSchedulerImpl implements CeProcessingScheduler {
       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;
       }
index cbfdd9c92d16d140a189427f7841522f6b80605e..96832a52d39bff1a5e35652b7f03235c5ae50b8c 100644 (file)
@@ -69,7 +69,7 @@ public class DBSessionsImpl implements DBSessions {
         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);
     }
   }
 
index 671e96e199365b97bd7d1dcf5006120b4566b68a..1d8295f9c502862ed92ffd4ec709cc5844d29801 100644 (file)
@@ -52,7 +52,7 @@ public class DbConnectionNodeCheck implements NodeHealthCheck {
     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;
     }
   }
index c532511382c8daec598916086cbcb8134aa36285..fe4b126ba37d5af7c6041bac71859fa21d2df57c 100644 (file)
@@ -217,7 +217,7 @@ public class EmailNotificationChannel extends NotificationChannel {
       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;
     }
   }
index 9c1d7317695a1cbf31519834c23ebd9715d6ca9a..1a6fa83b6fed85a89ca5fa5670beb119dd9a3537 100644 (file)
@@ -132,7 +132,7 @@ public class PluginDownloader implements Startable {
         } 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);
         }
       }
index 70a53afaf9ba501591156c07427f6641aa594470..e644d6a60550a882886cd183cd230831297728a8 100644 (file)
@@ -69,7 +69,7 @@ public class StaticResourcesServlet extends HttpServlet {
         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);
@@ -92,7 +92,7 @@ public class StaticResourcesServlet extends HttpServlet {
     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);
     }
   }
 
index 08b8124cacc64f7b8a610edbc9676340cc5f82b9..e4e258ed15767f1be0025d08cd37ff99f6d12311 100644 (file)
@@ -106,7 +106,7 @@ public class StaticResourcesServletTest {
     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() {
@@ -135,7 +135,7 @@ public class StaticResourcesServletTest {
     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() {
@@ -158,7 +158,7 @@ public class StaticResourcesServletTest {
     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());
   }