aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-09-28 15:37:17 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-09-29 11:16:15 +0200
commit1067fc0a3adb177489c261b955b7ef3fe623a1be (patch)
treefe38a02af4ccccb53c2310bb6d5ee8d7b027029f /sonar-core
parentd5dd60152c3408a1440e1ba6f6b1ce262ed2d488 (diff)
downloadsonarqube-1067fc0a3adb177489c261b955b7ef3fe623a1be.tar.gz
sonarqube-1067fc0a3adb177489c261b955b7ef3fe623a1be.zip
Add to sonar.log the beginning and end of CE tasks
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/util/logs/DefaultProfiler.java7
-rw-r--r--sonar-core/src/main/java/org/sonar/core/util/logs/NullProfiler.java5
-rw-r--r--sonar-core/src/main/java/org/sonar/core/util/logs/Profiler.java3
-rw-r--r--sonar-core/src/test/java/org/sonar/core/util/logs/NullProfilerTest.java1
4 files changed, 14 insertions, 2 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/util/logs/DefaultProfiler.java b/sonar-core/src/main/java/org/sonar/core/util/logs/DefaultProfiler.java
index fbfce14c40f..9709521ae16 100644
--- a/sonar-core/src/main/java/org/sonar/core/util/logs/DefaultProfiler.java
+++ b/sonar-core/src/main/java/org/sonar/core/util/logs/DefaultProfiler.java
@@ -135,6 +135,11 @@ class DefaultProfiler extends Profiler {
return doStop(LoggerLevel.INFO, message, args, "");
}
+ @Override
+ public long stopError(String message, Object... args) {
+ return doStop(LoggerLevel.ERROR, message, args, "");
+ }
+
private Profiler doStart(LoggerLevel logLevel, String message, Object... args) {
init(message, args);
logStartMessage(logLevel, message, args);
@@ -159,7 +164,7 @@ class DefaultProfiler extends Profiler {
StringBuilder sb = new StringBuilder();
sb.append(message);
appendContext(sb);
- logger.trace(sb.toString(), args);
+ log(loggerLevel, sb.toString(), args);
}
}
diff --git a/sonar-core/src/main/java/org/sonar/core/util/logs/NullProfiler.java b/sonar-core/src/main/java/org/sonar/core/util/logs/NullProfiler.java
index eec8190f4db..fc17f498206 100644
--- a/sonar-core/src/main/java/org/sonar/core/util/logs/NullProfiler.java
+++ b/sonar-core/src/main/java/org/sonar/core/util/logs/NullProfiler.java
@@ -119,6 +119,11 @@ class NullProfiler extends Profiler {
}
@Override
+ public long stopError(String message, Object... args) {
+ return 0;
+ }
+
+ @Override
public Profiler addContext(String key, @Nullable Object value) {
// nothing to do
return this;
diff --git a/sonar-core/src/main/java/org/sonar/core/util/logs/Profiler.java b/sonar-core/src/main/java/org/sonar/core/util/logs/Profiler.java
index ee1487e54dd..15148450f3e 100644
--- a/sonar-core/src/main/java/org/sonar/core/util/logs/Profiler.java
+++ b/sonar-core/src/main/java/org/sonar/core/util/logs/Profiler.java
@@ -85,9 +85,10 @@ public abstract class Profiler {
public abstract long stopInfo(String message, Object... args);
+ public abstract long stopError(String message, Object... args);
+
/**
* Context information is removed if value is <code>null</code>.
*/
public abstract Profiler addContext(String key, @Nullable Object value);
-
}
diff --git a/sonar-core/src/test/java/org/sonar/core/util/logs/NullProfilerTest.java b/sonar-core/src/test/java/org/sonar/core/util/logs/NullProfilerTest.java
index 6572d4956d9..b9b404efce6 100644
--- a/sonar-core/src/test/java/org/sonar/core/util/logs/NullProfilerTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/util/logs/NullProfilerTest.java
@@ -48,6 +48,7 @@ public class NullProfilerTest {
assertThat(underTest.stopDebug("msg")).isEqualTo(0);
assertThat(underTest.stopTrace()).isEqualTo(0);
assertThat(underTest.stopTrace("msg")).isEqualTo(0);
+ assertThat(underTest.stopError("msg")).isEqualTo(0);
}
}