]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4925 Remove duplicate SQL logging code from batch
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Thu, 6 Feb 2014 15:22:09 +0000 (16:22 +0100)
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Thu, 6 Feb 2014 15:22:09 +0000 (16:22 +0100)
sonar-batch/src/main/java/org/sonar/batch/bootstrapper/LoggingConfiguration.java
sonar-batch/src/main/resources/org/sonar/batch/logback.xml
sonar-batch/src/test/java/org/sonar/batch/bootstrapper/LoggingConfigurationTest.java

index 95fbdbced5f18adc8c2a9b4ed6806c1edf029b33..2169e32a509ea8c1b882b5a7066b1876777946dc 100644 (file)
@@ -38,7 +38,6 @@ import java.util.Map;
 public final class LoggingConfiguration {
 
   public static final String PROPERTY_ROOT_LOGGER_LEVEL = "ROOT_LOGGER_LEVEL";
-  public static final String PROPERTY_SQL_LOGGER_LEVEL = "SQL_LOGGER_LEVEL";
   public static final String PROPERTY_SQL_RESULTS_LOGGER_LEVEL = "SQL_RESULTS_LOGGER_LEVEL";
   public static final String PROPERTY_FORMAT = "FORMAT";
 
@@ -58,7 +57,6 @@ public final class LoggingConfiguration {
 
   private LoggingConfiguration(@Nullable EnvironmentInformation environment) {
     setVerbose(false);
-    setShowSql(false);
     if (environment != null && "maven".equalsIgnoreCase(environment.getKey())) {
       setFormat(FORMAT_MAVEN);
     } else {
@@ -72,7 +70,6 @@ public final class LoggingConfiguration {
 
   public LoggingConfiguration setProperties(Map<String, String> properties) {
     Profiling.Level profilingLevel = Profiling.Level.fromConfigString(properties.get("sonar.log.profilingLevel"));
-    setShowSql(profilingLevel == Level.FULL);
     setShowSqlResults(profilingLevel == Level.FULL);
     setVerbose("true".equals(properties.get("sonar.verbose")));
     return this;
@@ -82,10 +79,6 @@ public final class LoggingConfiguration {
     return setRootLevel(verbose ? LEVEL_ROOT_VERBOSE : LEVEL_ROOT_DEFAULT);
   }
 
-  public LoggingConfiguration setShowSql(boolean showSql) {
-    return setSqlLevel(showSql ? LEVEL_SQL_VERBOSE : LEVEL_SQL_DEFAULT);
-  }
-
   public LoggingConfiguration setShowSqlResults(boolean showSqlResults) {
     return setSqlResultsLevel(showSqlResults ? LEVEL_SQL_RESULTS_VERBOSE : LEVEL_SQL_RESULTS_DEFAULT);
   }
@@ -94,10 +87,6 @@ public final class LoggingConfiguration {
     return addSubstitutionVariable(PROPERTY_ROOT_LOGGER_LEVEL, level);
   }
 
-  public LoggingConfiguration setSqlLevel(String level) {
-    return addSubstitutionVariable(PROPERTY_SQL_LOGGER_LEVEL, level);
-  }
-
   public LoggingConfiguration setSqlResultsLevel(String level) {
     return addSubstitutionVariable(PROPERTY_SQL_RESULTS_LOGGER_LEVEL, level);
   }
index 042b3ec145dbed31d9c559040632294b56f726b1..05ec301855543b0786f1839682c3a963701bf486 100644 (file)
   <!-- sonar.showSql -->
   <!-- see also org.sonar.core.persistence.MyBatis#configureLogback() -->
   <logger name="org.hibernate.SQL">
-    <level value="${SQL_LOGGER_LEVEL:-ERROR}"/>
+    <level value="ERROR"/>
   </logger>
   <logger name="org.apache.ibatis">
-    <level value="${SQL_LOGGER_LEVEL:-WARN}"/>
+    <level value="WARN"/>
   </logger>
   <logger name="org.mybatis">
-    <level value="${SQL_LOGGER_LEVEL:-WARN}"/>
+    <level value="WARN"/>
   </logger>
   <logger name="java.sql">
-    <level value="${SQL_LOGGER_LEVEL:-WARN}"/>
+    <level value="WARN"/>
   </logger>
   <logger name="java.sql.ResultSet">
     <level value="${SQL_RESULTS_LOGGER_LEVEL:-WARN}"/>
index 79a59642250b71d9c42febb69f2769a239eaa2e9..eea99443c22fb296c60ee9523e8a1229e2519d44 100644 (file)
@@ -28,24 +28,6 @@ import static org.fest.assertions.Assertions.assertThat;
 
 public class LoggingConfigurationTest {
 
-  @Test
-  public void testSqlLevel() {
-    assertThat(LoggingConfiguration.create(null).setShowSql(true)
-        .getSubstitutionVariable(LoggingConfiguration.PROPERTY_SQL_LOGGER_LEVEL)).isEqualTo(LoggingConfiguration.LEVEL_SQL_VERBOSE);
-
-    assertThat(LoggingConfiguration.create(null).setShowSql(false)
-        .getSubstitutionVariable(LoggingConfiguration.PROPERTY_SQL_LOGGER_LEVEL)).isEqualTo(LoggingConfiguration.LEVEL_SQL_DEFAULT);
-
-    assertThat(LoggingConfiguration.create(null).setSqlLevel("ERROR")
-        .getSubstitutionVariable(LoggingConfiguration.PROPERTY_SQL_LOGGER_LEVEL)).isEqualTo("ERROR");
-  }
-
-  @Test
-  public void shouldNotShowSqlByDefault() {
-    assertThat(LoggingConfiguration.create(null)
-        .getSubstitutionVariable(LoggingConfiguration.PROPERTY_SQL_LOGGER_LEVEL)).isEqualTo(LoggingConfiguration.LEVEL_SQL_DEFAULT);
-  }
-
   @Test
   public void testSetVerbose() {
     assertThat(LoggingConfiguration.create(null).setVerbose(true)
@@ -83,19 +65,19 @@ public class LoggingConfigurationTest {
   public void testSetShowSqlProperty() {
     Map<String, String> properties = Maps.newHashMap();
     assertThat(LoggingConfiguration.create(null).setProperties(properties)
-        .getSubstitutionVariable(LoggingConfiguration.PROPERTY_SQL_LOGGER_LEVEL)).isEqualTo(LoggingConfiguration.LEVEL_SQL_DEFAULT);
+        .getSubstitutionVariable(LoggingConfiguration.PROPERTY_SQL_RESULTS_LOGGER_LEVEL)).isEqualTo(LoggingConfiguration.LEVEL_SQL_DEFAULT);
 
     properties.put("sonar.log.profilingLevel", "FULL");
     assertThat(LoggingConfiguration.create(null).setProperties(properties)
-        .getSubstitutionVariable(LoggingConfiguration.PROPERTY_SQL_LOGGER_LEVEL)).isEqualTo(LoggingConfiguration.LEVEL_SQL_VERBOSE);
+        .getSubstitutionVariable(LoggingConfiguration.PROPERTY_SQL_RESULTS_LOGGER_LEVEL)).isEqualTo(LoggingConfiguration.LEVEL_SQL_VERBOSE);
 
     properties.put("sonar.log.profilingLevel", "BASIC");
     assertThat(LoggingConfiguration.create(null).setProperties(properties)
-        .getSubstitutionVariable(LoggingConfiguration.PROPERTY_SQL_LOGGER_LEVEL)).isEqualTo(LoggingConfiguration.LEVEL_SQL_DEFAULT);
+        .getSubstitutionVariable(LoggingConfiguration.PROPERTY_SQL_RESULTS_LOGGER_LEVEL)).isEqualTo(LoggingConfiguration.LEVEL_SQL_DEFAULT);
 
     properties.put("sonar.log.profilingLevel", "NONE");
     assertThat(LoggingConfiguration.create(null).setProperties(properties)
-        .getSubstitutionVariable(LoggingConfiguration.PROPERTY_SQL_LOGGER_LEVEL)).isEqualTo(LoggingConfiguration.LEVEL_SQL_DEFAULT);
+        .getSubstitutionVariable(LoggingConfiguration.PROPERTY_SQL_RESULTS_LOGGER_LEVEL)).isEqualTo(LoggingConfiguration.LEVEL_SQL_DEFAULT);
   }
 
   @Test