aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Trebbien <dtrebbien@gmail.com>2017-10-09 10:14:34 -0500
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-10-10 13:28:44 +0200
commit0c4ab610218ff4b7532cd6483dee150f78c1fd3e (patch)
tree4a30a5b3c92702544b09ac7e909e566f988710cc
parent1719abc62d33568dfc1a1d8d90262062211c5f39 (diff)
downloadsonarqube-0c4ab610218ff4b7532cd6483dee150f78c1fd3e.tar.gz
sonarqube-0c4ab610218ff4b7532cd6483dee150f78c1fd3e.zip
Utilize parameterized logging
As suggested in the SLF4J FAQ: https://www.slf4j.org/faq.html#logging_performance .. parameterized logging can improve the efficiency of logger calls when logging at the specified level is disabled. In addition, per the FAQ: https://www.slf4j.org/faq.html#paramException since SLF4J 1.6.0 it is possible to use parameterized logging and also log an exception/throwable. These changes were suggested by SLF4J Helper for NetBeans IDE: http://plugins.netbeans.org/plugin/72557/
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/SchedulerImpl.java2
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/process/ProcessLauncherImpl.java2
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/process/SQProcess.java2
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/Jmx.java2
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/ProcessEntryPoint.java4
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/TimeProfiler.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/phases/CoverageExclusions.java2
7 files changed, 8 insertions, 8 deletions
diff --git a/server/sonar-main/src/main/java/org/sonar/application/SchedulerImpl.java b/server/sonar-main/src/main/java/org/sonar/application/SchedulerImpl.java
index 943f5de6efa..abe37386b64 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/SchedulerImpl.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/SchedulerImpl.java
@@ -130,7 +130,7 @@ public class SchedulerImpl implements Scheduler, ProcessEventListener, ProcessLi
} else {
Optional<String> leader = appState.getLeaderHostName();
if (leader.isPresent()) {
- LOG.info("Waiting for initialization from " + leader.get());
+ LOG.info("Waiting for initialization from {}", leader.get());
} else {
LOG.error("Initialization failed. All nodes must be restarted");
}
diff --git a/server/sonar-main/src/main/java/org/sonar/application/process/ProcessLauncherImpl.java b/server/sonar-main/src/main/java/org/sonar/application/process/ProcessLauncherImpl.java
index 802d53bdf16..f067cc15c76 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/process/ProcessLauncherImpl.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/process/ProcessLauncherImpl.java
@@ -98,7 +98,7 @@ public class ProcessLauncherImpl implements ProcessLauncher {
try {
FileUtils.deleteDirectory(outdatedDir);
} catch (IOException e) {
- LOG.info("Failed to delete outdated search index data directory " + outdatedDir.getAbsolutePath(), e);
+ LOG.info("Failed to delete outdated search index data directory {}", outdatedDir.getAbsolutePath(), e);
}
}
});
diff --git a/server/sonar-main/src/main/java/org/sonar/application/process/SQProcess.java b/server/sonar-main/src/main/java/org/sonar/application/process/SQProcess.java
index 6aa7a29bac1..18f6d192d6c 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/process/SQProcess.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/process/SQProcess.java
@@ -134,7 +134,7 @@ public class SQProcess {
LOG.warn(format("Interrupted while stopping process %s", processId), e);
Thread.currentThread().interrupt();
} catch (Throwable e) {
- LOG.error("Can not ask for graceful stop of process " + processId, e);
+ LOG.error("Can not ask for graceful stop of process {}", processId, e);
}
}
diff --git a/server/sonar-process/src/main/java/org/sonar/process/Jmx.java b/server/sonar-process/src/main/java/org/sonar/process/Jmx.java
index 5324be1955e..ddad31ea7f1 100644
--- a/server/sonar-process/src/main/java/org/sonar/process/Jmx.java
+++ b/server/sonar-process/src/main/java/org/sonar/process/Jmx.java
@@ -80,7 +80,7 @@ public class Jmx {
try {
ManagementFactory.getPlatformMBeanServer().unregisterMBean(new ObjectName(name));
} catch (Exception e) {
- LoggerFactory.getLogger(Jmx.class).warn("Can not unregister MBean [" + name + "]", e);
+ LoggerFactory.getLogger(Jmx.class).warn("Can not unregister MBean [{}]", name, e);
}
}
}
diff --git a/server/sonar-process/src/main/java/org/sonar/process/ProcessEntryPoint.java b/server/sonar-process/src/main/java/org/sonar/process/ProcessEntryPoint.java
index 76b89a007f9..1ee6df0864b 100644
--- a/server/sonar-process/src/main/java/org/sonar/process/ProcessEntryPoint.java
+++ b/server/sonar-process/src/main/java/org/sonar/process/ProcessEntryPoint.java
@@ -99,14 +99,14 @@ public class ProcessEntryPoint implements Stoppable {
try {
launch(logger);
} catch (Exception e) {
- logger.warn("Fail to start " + getKey(), e);
+ logger.warn("Fail to start {}", getKey(), e);
} finally {
stop();
}
}
private void launch(Logger logger) throws InterruptedException {
- logger.info("Starting " + getKey());
+ logger.info("Starting {}", getKey());
Runtime.getRuntime().addShutdownHook(shutdownHook);
stopWatcher.start();
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/TimeProfiler.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/TimeProfiler.java
index 7de4c84994d..efe9fc38e73 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/TimeProfiler.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/TimeProfiler.java
@@ -57,7 +57,7 @@ public class TimeProfiler {
if (debug) {
logger.debug("%s ...", name);
} else {
- logger.info(name + "...");
+ logger.info("{}...", name);
}
return this;
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/phases/CoverageExclusions.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/phases/CoverageExclusions.java
index f0f3ba39895..65a195faa9d 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/phases/CoverageExclusions.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/phases/CoverageExclusions.java
@@ -62,7 +62,7 @@ public class CoverageExclusions {
if (!patterns.isEmpty()) {
LOG.info(title);
for (WildcardPattern pattern : patterns) {
- LOG.info(" " + pattern);
+ LOG.info(" {}", pattern);
}
}
}