aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core/src
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-01-12 19:55:58 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2012-01-12 19:58:08 +0100
commit7be3485cc15dc72c82790d8069b4c301a1aa5862 (patch)
tree46167c203801507e71bbd338d6c99e440300b858 /sonar-core/src
parentb974afb1e66f56fca8d94b6782e04964cb3fde05 (diff)
downloadsonarqube-7be3485cc15dc72c82790d8069b4c301a1aa5862.tar.gz
sonarqube-7be3485cc15dc72c82790d8069b4c301a1aa5862.zip
SONAR-2959 Add the property sonar.showSql
Diffstat (limited to 'sonar-core/src')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/config/Logback.java22
1 files changed, 15 insertions, 7 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/config/Logback.java b/sonar-core/src/main/java/org/sonar/core/config/Logback.java
index 2063a28935a..df2892ceaf4 100644
--- a/sonar-core/src/main/java/org/sonar/core/config/Logback.java
+++ b/sonar-core/src/main/java/org/sonar/core/config/Logback.java
@@ -31,6 +31,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Map;
/**
* Configure Logback
@@ -43,18 +44,18 @@ public final class Logback {
// only static methods
}
- public static void configure(String classloaderPath) {
+ public static void configure(String classloaderPath, Map<String, String> substitutionVariables) {
InputStream input = Logback.class.getResourceAsStream(classloaderPath);
if (input == null) {
throw new IllegalArgumentException("Logback configuration not found in classloader: " + classloaderPath);
}
- configure(input);
+ configure(input, substitutionVariables);
}
- public static void configure(File logbackFile) {
+ public static void configure(File logbackFile, Map<String, String> substitutionVariables) {
try {
FileInputStream input = FileUtils.openInputStream(logbackFile);
- configure(input);
+ configure(input, substitutionVariables);
} catch (IOException e) {
throw new IllegalArgumentException("Fail to load the Logback configuration: " + logbackFile, e);
}
@@ -63,12 +64,11 @@ public final class Logback {
/**
* Note that this method closes the input stream
*/
- private static void configure(InputStream input) {
+ private static void configure(InputStream input, Map<String, String> substitutionVariables) {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
try {
JoranConfigurator configurator = new JoranConfigurator();
- configurator.setContext(lc);
- lc.reset();
+ configurator.setContext(configureContext(lc, substitutionVariables));
configurator.doConfigure(input);
} catch (JoranException e) {
// StatusPrinter will handle this
@@ -77,4 +77,12 @@ public final class Logback {
}
StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
}
+
+ private static LoggerContext configureContext(LoggerContext context, Map<String, String> substitutionVariables) {
+ context.reset();
+ for (Map.Entry<String, String> entry : substitutionVariables.entrySet()) {
+ context.putProperty(entry.getKey(), entry.getValue());
+ }
+ return context;
+ }
}