@@ -0,0 +1,79 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* SonarQube is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.microbenchmark; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.openjdk.jmh.annotations.Benchmark; | |||
import org.openjdk.jmh.annotations.BenchmarkMode; | |||
import org.openjdk.jmh.annotations.Fork; | |||
import org.openjdk.jmh.annotations.Measurement; | |||
import org.openjdk.jmh.annotations.Mode; | |||
import org.openjdk.jmh.annotations.OutputTimeUnit; | |||
import org.openjdk.jmh.annotations.Scope; | |||
import org.openjdk.jmh.annotations.State; | |||
import org.openjdk.jmh.annotations.Warmup; | |||
import org.openjdk.jmh.runner.Runner; | |||
import org.openjdk.jmh.runner.RunnerException; | |||
import org.openjdk.jmh.runner.options.Options; | |||
import org.openjdk.jmh.runner.options.OptionsBuilder; | |||
import org.slf4j.Logger; | |||
import java.util.Date; | |||
import java.util.concurrent.TimeUnit; | |||
@OutputTimeUnit(TimeUnit.MILLISECONDS) | |||
@State(Scope.Thread) | |||
@Fork(1) | |||
@Warmup(iterations = 3) | |||
@Measurement(iterations = 3) | |||
@BenchmarkMode(Mode.Throughput) | |||
public class LoggingBenchmark { | |||
private Logger logger1 = org.slf4j.LoggerFactory.getLogger("microbenchmark1"); | |||
private Logger logger2 = org.slf4j.LoggerFactory.getLogger("microbenchmark2"); | |||
@Benchmark | |||
public void logback_converters() throws Exception { | |||
logger1.warn("many arguments {} {} {} {} {} {}", "foo", 7, 4.5, 1234567890L, true, new Date()); | |||
} | |||
@Benchmark | |||
public void string_converters() throws Exception { | |||
logger2.warn(String.format("many arguments %s %d %f %d %b %tc", "foo", 7, 4.5, 1234567890L, true, new Date())); | |||
} | |||
@Benchmark | |||
public void logback_no_args() throws Exception { | |||
logger1.warn("no args"); | |||
StringUtils.replaceOnce() | |||
} | |||
/** | |||
* You can this benchmark with maven command-line (see run.sh) or by executing this method | |||
* in IDE | |||
*/ | |||
public static void main(String[] args) throws RunnerException { | |||
Options opt = new OptionsBuilder() | |||
.include(LoggingBenchmark.class.getSimpleName()) | |||
.build(); | |||
new Runner(opt).run(); | |||
} | |||
} |
@@ -22,14 +22,14 @@ package org.sonar.plugins.emailnotifications; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.apache.commons.mail.EmailException; | |||
import org.apache.commons.mail.SimpleEmail; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.config.EmailSettings; | |||
import org.sonar.api.database.model.User; | |||
import org.sonar.api.notifications.Notification; | |||
import org.sonar.api.notifications.NotificationChannel; | |||
import org.sonar.api.security.UserFinder; | |||
import org.sonar.api.utils.SonarException; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.plugins.emailnotifications.api.EmailMessage; | |||
import org.sonar.plugins.emailnotifications.api.EmailTemplate; | |||
@@ -48,7 +48,7 @@ import java.net.URL; | |||
*/ | |||
public class EmailNotificationChannel extends NotificationChannel { | |||
private static final Logger LOG = LoggerFactory.getLogger(EmailNotificationChannel.class); | |||
private static final Logger LOG = Loggers.get(EmailNotificationChannel.class); | |||
/** | |||
* @see org.apache.commons.mail.Email#setSocketConnectionTimeout(int) |
@@ -22,14 +22,14 @@ package org.sonar.xoo.lang; | |||
import com.google.common.base.Splitter; | |||
import org.apache.commons.io.FileUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.batch.fs.FilePredicates; | |||
import org.sonar.api.batch.fs.FileSystem; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.sensor.Sensor; | |||
import org.sonar.api.batch.sensor.SensorContext; | |||
import org.sonar.api.batch.sensor.SensorDescriptor; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.xoo.Xoo; | |||
import java.io.File; | |||
@@ -43,7 +43,7 @@ import java.util.List; | |||
*/ | |||
public class CoveragePerTestSensor implements Sensor { | |||
private static final Logger LOG = LoggerFactory.getLogger(CoveragePerTestSensor.class); | |||
private static final Logger LOG = Loggers.get(CoveragePerTestSensor.class); | |||
private static final String COVER_PER_TEST_EXTENSION = ".coveragePerTest"; | |||
@@ -22,14 +22,14 @@ package org.sonar.xoo.lang; | |||
import com.google.common.base.Splitter; | |||
import org.apache.commons.io.FileUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.batch.fs.FilePredicates; | |||
import org.sonar.api.batch.fs.FileSystem; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.sensor.Sensor; | |||
import org.sonar.api.batch.sensor.SensorContext; | |||
import org.sonar.api.batch.sensor.SensorDescriptor; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.xoo.Xoo; | |||
import java.io.File; | |||
@@ -42,7 +42,7 @@ import java.util.List; | |||
*/ | |||
public class DependencySensor implements Sensor { | |||
private static final Logger LOG = LoggerFactory.getLogger(DependencySensor.class); | |||
private static final Logger LOG = Loggers.get(DependencySensor.class); | |||
private static final String DEPS_EXTENSION = ".deps"; | |||
@@ -21,14 +21,14 @@ package org.sonar.xoo.lang; | |||
import org.apache.commons.io.FileUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.measure.MetricFinder; | |||
import org.sonar.api.batch.sensor.Sensor; | |||
import org.sonar.api.batch.sensor.SensorContext; | |||
import org.sonar.api.batch.sensor.SensorDescriptor; | |||
import org.sonar.api.batch.sensor.measure.NewMeasure; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.xoo.Xoo; | |||
import java.io.File; | |||
@@ -41,7 +41,7 @@ import java.util.List; | |||
*/ | |||
public class MeasureSensor implements Sensor { | |||
private static final Logger LOG = LoggerFactory.getLogger(MeasureSensor.class); | |||
private static final Logger LOG = Loggers.get(MeasureSensor.class); | |||
private static final String MEASURES_EXTENSION = ".measures"; | |||
@@ -22,14 +22,14 @@ package org.sonar.xoo.lang; | |||
import com.google.common.base.Splitter; | |||
import org.apache.commons.io.FileUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.sensor.Sensor; | |||
import org.sonar.api.batch.sensor.SensorContext; | |||
import org.sonar.api.batch.sensor.SensorDescriptor; | |||
import org.sonar.api.batch.sensor.symbol.Symbol; | |||
import org.sonar.api.batch.sensor.symbol.SymbolTableBuilder; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.xoo.Xoo; | |||
import java.io.File; | |||
@@ -42,7 +42,7 @@ import java.util.List; | |||
*/ | |||
public class SymbolReferencesSensor implements Sensor { | |||
private static final Logger LOG = LoggerFactory.getLogger(SymbolReferencesSensor.class); | |||
private static final Logger LOG = Loggers.get(SymbolReferencesSensor.class); | |||
private static final String SYMBOL_EXTENSION = ".symbol"; | |||
@@ -22,14 +22,14 @@ package org.sonar.xoo.lang; | |||
import com.google.common.base.Splitter; | |||
import org.apache.commons.io.FileUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.sensor.Sensor; | |||
import org.sonar.api.batch.sensor.SensorContext; | |||
import org.sonar.api.batch.sensor.SensorDescriptor; | |||
import org.sonar.api.batch.sensor.highlighting.HighlightingBuilder; | |||
import org.sonar.api.batch.sensor.highlighting.TypeOfText; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.xoo.Xoo; | |||
import java.io.File; | |||
@@ -42,7 +42,7 @@ import java.util.List; | |||
*/ | |||
public class SyntaxHighlightingSensor implements Sensor { | |||
private static final Logger LOG = LoggerFactory.getLogger(SyntaxHighlightingSensor.class); | |||
private static final Logger LOG = Loggers.get(SyntaxHighlightingSensor.class); | |||
private static final String HIGHLIGHTING_EXTENSION = ".highlighting"; | |||
@@ -22,8 +22,6 @@ package org.sonar.xoo.lang; | |||
import com.google.common.base.Splitter; | |||
import org.apache.commons.io.FileUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.batch.fs.FilePredicates; | |||
import org.sonar.api.batch.fs.FileSystem; | |||
import org.sonar.api.batch.fs.InputFile; | |||
@@ -31,6 +29,8 @@ import org.sonar.api.batch.sensor.Sensor; | |||
import org.sonar.api.batch.sensor.SensorContext; | |||
import org.sonar.api.batch.sensor.SensorDescriptor; | |||
import org.sonar.api.batch.sensor.test.TestCaseExecution; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.xoo.Xoo; | |||
import java.io.File; | |||
@@ -43,7 +43,7 @@ import java.util.List; | |||
*/ | |||
public class TestCaseSensor implements Sensor { | |||
private static final Logger LOG = LoggerFactory.getLogger(TestCaseSensor.class); | |||
private static final Logger LOG = Loggers.get(TestCaseSensor.class); | |||
private static final String TESTPLAN_EXTENSION = ".testplan"; | |||
@@ -37,12 +37,10 @@ | |||
<dependency> | |||
<groupId>ch.qos.logback</groupId> | |||
<artifactId>logback-classic</artifactId> | |||
<scope>provided</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>ch.qos.logback</groupId> | |||
<artifactId>logback-core</artifactId> | |||
<scope>provided</scope> | |||
</dependency> | |||
<!-- testing --> |
@@ -15,6 +15,18 @@ | |||
</properties> | |||
<dependencies> | |||
<dependency> | |||
<groupId>org.slf4j</groupId> | |||
<artifactId>slf4j-api</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.slf4j</groupId> | |||
<artifactId>jcl-over-slf4j</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.slf4j</groupId> | |||
<artifactId>log4j-over-slf4j</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.slf4j</groupId> | |||
<artifactId>jul-to-slf4j</artifactId> |
@@ -20,12 +20,12 @@ | |||
package org.sonar.core.computation.dbcleaner; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.ServerComponent; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.api.utils.TimeUtils; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.computation.dbcleaner.period.DefaultPeriodCleaner; | |||
import org.sonar.core.persistence.DbSession; | |||
import org.sonar.core.purge.IdUuidPair; | |||
@@ -37,12 +37,13 @@ import org.sonar.server.issue.index.IssueIndex; | |||
import org.sonar.server.properties.ProjectSettingsFactory; | |||
import javax.annotation.Nullable; | |||
import java.util.Date; | |||
import static org.sonar.core.purge.PurgeConfiguration.newDefaultPurgeConfiguration; | |||
public class ProjectCleaner implements ServerComponent { | |||
private static final Logger LOG = LoggerFactory.getLogger(ProjectCleaner.class); | |||
private static final Logger LOG = Loggers.get(ProjectCleaner.class); | |||
private final PurgeProfiler profiler; | |||
private final PurgeListener purgeListener; |
@@ -24,7 +24,7 @@ import org.apache.catalina.LifecycleException; | |||
import org.apache.catalina.core.StandardContext; | |||
import org.apache.catalina.startup.Tomcat; | |||
import org.apache.commons.io.FileUtils; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.process.ProcessConstants; | |||
import org.sonar.process.Props; | |||
@@ -60,7 +60,7 @@ class EmbeddedTomcat { | |||
webappContext = Webapp.configure(tomcat, props); | |||
try { | |||
tomcat.start(); | |||
new StartupLogs(props, LoggerFactory.getLogger(getClass())).log(tomcat); | |||
new StartupLogs(props, Loggers.get(getClass())).log(tomcat); | |||
} catch (LifecycleException e) { | |||
Throwables.propagate(e); | |||
} | |||
@@ -95,7 +95,7 @@ class EmbeddedTomcat { | |||
tomcat.stop(); | |||
tomcat.destroy(); | |||
} catch (Exception e) { | |||
LoggerFactory.getLogger(EmbeddedTomcat.class).error("Fail to stop web server", e); | |||
Loggers.get(EmbeddedTomcat.class).error("Fail to stop web server", e); | |||
} | |||
} | |||
FileUtils.deleteQuietly(tomcatBasedir()); |
@@ -23,7 +23,7 @@ import org.apache.catalina.connector.Connector; | |||
import org.apache.catalina.startup.Tomcat; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.apache.coyote.http11.AbstractHttp11JsseProtocol; | |||
import org.slf4j.Logger; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.process.Props; | |||
class StartupLogs { |
@@ -24,8 +24,8 @@ import ch.qos.logback.core.FileAppender; | |||
import org.apache.catalina.LifecycleEvent; | |||
import org.apache.catalina.LifecycleListener; | |||
import org.apache.catalina.startup.Tomcat; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.process.LogbackHelper; | |||
import org.sonar.process.Props; | |||
@@ -36,7 +36,7 @@ class TomcatAccessLog { | |||
void configure(Tomcat tomcat, Props props) { | |||
tomcat.setSilent(true); | |||
tomcat.getService().addLifecycleListener(new LifecycleLogger(LoggerFactory.getLogger(TomcatAccessLog.class))); | |||
tomcat.getService().addLifecycleListener(new LifecycleLogger(Loggers.get(TomcatAccessLog.class))); | |||
configureLogbackAccess(tomcat, props); | |||
} | |||
@@ -23,7 +23,7 @@ import org.apache.catalina.Context; | |||
import org.apache.catalina.core.StandardContext; | |||
import org.apache.catalina.startup.Tomcat; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.process.ProcessConstants; | |||
import org.sonar.process.Props; | |||
@@ -90,7 +90,7 @@ class Webapp { | |||
if (props.valueAsBoolean("sonar.web.dev", false)) { | |||
context.addParameter(RAILS_ENV, "development"); | |||
context.addParameter(JRUBY_MAX_RUNTIMES, "3"); | |||
LoggerFactory.getLogger(Webapp.class).warn("WEB DEVELOPMENT MODE IS ENABLED - DO NOT USE FOR PRODUCTION USAGE"); | |||
Loggers.get(Webapp.class).warn("WEB DEVELOPMENT MODE IS ENABLED - DO NOT USE FOR PRODUCTION USAGE"); | |||
} else { | |||
context.addParameter(RAILS_ENV, "production"); | |||
context.addParameter(JRUBY_MAX_RUNTIMES, "1"); | |||
@@ -102,7 +102,7 @@ class Webapp { | |||
if (StringUtils.isEmpty(webDir)) { | |||
webDir = new File(props.value(ProcessConstants.PATH_HOME), "web").getAbsolutePath(); | |||
} | |||
LoggerFactory.getLogger(Webapp.class).info(String.format("Webapp directory: %s", webDir)); | |||
Loggers.get(Webapp.class).info(String.format("Webapp directory: %s", webDir)); | |||
return webDir; | |||
} | |||
} |
@@ -20,16 +20,17 @@ | |||
package org.sonar.server.charts; | |||
import com.google.common.collect.Maps; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.ServerComponent; | |||
import org.sonar.api.charts.Chart; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import javax.annotation.CheckForNull; | |||
import java.util.Map; | |||
public final class ChartFactory implements ServerComponent { | |||
private static final Logger LOG = LoggerFactory.getLogger(ChartFactory.class); | |||
private static final Logger LOG = Loggers.get(ChartFactory.class); | |||
private final Map<String, Chart> chartsByKey = Maps.newHashMap(); | |||
@@ -22,10 +22,10 @@ package org.sonar.server.charts; | |||
import com.google.common.collect.Maps; | |||
import com.google.common.io.Closeables; | |||
import org.jfree.chart.encoders.KeypointPNGEncoderAdapter; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.charts.Chart; | |||
import org.sonar.api.charts.ChartParameters; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.server.charts.deprecated.BarChart; | |||
import org.sonar.server.charts.deprecated.BaseChartWeb; | |||
import org.sonar.server.charts.deprecated.CustomBarChart; | |||
@@ -47,7 +47,7 @@ import java.util.Map; | |||
public class ChartsServlet extends HttpServlet { | |||
private static final Logger LOG = LoggerFactory.getLogger(ChartsServlet.class); | |||
private static final Logger LOG = Loggers.get(ChartsServlet.class); | |||
private static final long serialVersionUID = 669857447198433893L; | |||
@Override |
@@ -22,10 +22,10 @@ package org.sonar.server.component; | |||
import com.google.common.base.Predicate; | |||
import com.google.common.collect.Iterables; | |||
import com.google.common.collect.Sets; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.component.Component; | |||
import org.sonar.api.utils.Paging; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import java.util.Collection; | |||
import java.util.List; | |||
@@ -38,7 +38,7 @@ import static com.google.common.collect.Lists.newArrayList; | |||
*/ | |||
public class DefaultComponentFinder { | |||
private static final Logger LOG = LoggerFactory.getLogger(DefaultComponentFinder.class); | |||
private static final Logger LOG = Loggers.get(DefaultComponentFinder.class); | |||
public DefaultComponentQueryResult find(ComponentQuery query, List<Component> allComponents) { | |||
LOG.debug("ComponentQuery : {}", query); |
@@ -22,11 +22,11 @@ package org.sonar.server.computation; | |||
import com.google.common.base.Throwables; | |||
import org.apache.commons.lang.ArrayUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.ServerComponent; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.api.utils.TimeProfiler; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.activity.Activity; | |||
import org.sonar.core.component.ComponentDto; | |||
import org.sonar.core.computation.db.AnalysisReportDto; | |||
@@ -39,7 +39,7 @@ import org.sonar.server.db.DbClient; | |||
public class ComputationService implements ServerComponent { | |||
private static final Logger LOG = LoggerFactory.getLogger(ComputationService.class); | |||
private static final Logger LOG = Loggers.get(ComputationService.class); | |||
private final DbClient dbClient; | |||
private final ComputationSteps steps; |
@@ -20,9 +20,10 @@ | |||
package org.sonar.server.computation; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.platform.ComponentContainer; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.computation.db.AnalysisReportDto; | |||
import org.sonar.server.computation.step.ComputationSteps; | |||
import org.sonar.server.platform.Platform; | |||
@@ -31,7 +32,7 @@ import org.sonar.server.platform.Platform; | |||
* This thread pops queue of reports and processes the report if present | |||
*/ | |||
public class ComputationThread implements Runnable { | |||
private static final Logger LOG = LoggerFactory.getLogger(ComputationThread.class); | |||
private static final Logger LOG = Loggers.get(ComputationThread.class); | |||
private final AnalysisReportQueue queue; | |||
@@ -45,7 +45,7 @@ public class ComputationThreadLauncher implements Startable, ServerComponent, Se | |||
public ComputationThreadLauncher(AnalysisReportQueue queue) { | |||
this.queue = queue; | |||
this.executorService = Executors.newSingleThreadScheduledExecutor(threadFactoryWithSpecificNameForLogging()); | |||
this.executorService = Executors.newSingleThreadScheduledExecutor(newThreadFactory()); | |||
this.delayBetweenTasks = 10; | |||
this.delayForFirstStart = 0; | |||
@@ -55,7 +55,7 @@ public class ComputationThreadLauncher implements Startable, ServerComponent, Se | |||
@VisibleForTesting | |||
ComputationThreadLauncher(AnalysisReportQueue queue, long delayForFirstStart, long delayBetweenTasks, TimeUnit timeUnit) { | |||
this.queue = queue; | |||
this.executorService = Executors.newSingleThreadScheduledExecutor(threadFactoryWithSpecificNameForLogging()); | |||
this.executorService = Executors.newSingleThreadScheduledExecutor(newThreadFactory()); | |||
this.delayBetweenTasks = delayBetweenTasks; | |||
this.delayForFirstStart = delayForFirstStart; | |||
@@ -81,10 +81,7 @@ public class ComputationThreadLauncher implements Startable, ServerComponent, Se | |||
executorService.scheduleAtFixedRate(new ComputationThread(queue), delayForFirstStart, delayBetweenTasks, timeUnit); | |||
} | |||
/** | |||
* @see org.sonar.server.platform.SwitchLogbackAppender | |||
*/ | |||
private ThreadFactory threadFactoryWithSpecificNameForLogging() { | |||
private ThreadFactory newThreadFactory() { | |||
return new ThreadFactoryBuilder() | |||
.setNameFormat(THREAD_NAME_PREFIX + "%d").setPriority(Thread.MIN_PRIORITY).build(); | |||
} |
@@ -23,8 +23,8 @@ import com.google.common.annotations.VisibleForTesting; | |||
import com.google.common.base.Function; | |||
import com.google.common.base.Joiner; | |||
import com.google.common.collect.Collections2; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.server.user.index.UserDoc; | |||
import org.sonar.server.user.index.UserIndex; | |||
import org.sonar.server.util.cache.CacheLoader; | |||
@@ -42,7 +42,7 @@ public class ScmAccountCacheLoader implements CacheLoader<String, String> { | |||
private final UserIndex index; | |||
public ScmAccountCacheLoader(UserIndex index) { | |||
this(index, LoggerFactory.getLogger(ScmAccountCacheLoader.class)); | |||
this(index, Loggers.get(ScmAccountCacheLoader.class)); | |||
} | |||
@VisibleForTesting |
@@ -21,10 +21,10 @@ | |||
package org.sonar.server.computation.step; | |||
import org.apache.commons.io.FileUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.resources.Qualifiers; | |||
import org.sonar.api.utils.TempFolder; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.batch.protocol.output.BatchOutputReader; | |||
import org.sonar.batch.protocol.output.BatchReport; | |||
import org.sonar.core.computation.db.AnalysisReportDto; | |||
@@ -38,7 +38,7 @@ import java.io.File; | |||
public class ParseReportStep implements ComputationStep { | |||
private static final Logger LOG = LoggerFactory.getLogger(ParseReportStep.class); | |||
private static final Logger LOG = Loggers.get(ParseReportStep.class); | |||
private final IssueComputation issueComputation; | |||
private final DbClient dbClient; |
@@ -24,23 +24,32 @@ import com.google.common.base.Preconditions; | |||
import com.google.common.collect.ImmutableList; | |||
import com.google.common.collect.Lists; | |||
import org.apache.ibatis.session.ResultContext; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.persistence.DaoComponent; | |||
import org.sonar.core.persistence.DbSession; | |||
import org.sonar.core.persistence.Dto; | |||
import org.sonar.server.exceptions.NotFoundException; | |||
import org.sonar.server.search.DbSynchronizationHandler; | |||
import org.sonar.server.search.IndexDefinition; | |||
import org.sonar.server.search.action.*; | |||
import org.sonar.server.search.action.DeleteKey; | |||
import org.sonar.server.search.action.DeleteNestedItem; | |||
import org.sonar.server.search.action.InsertDto; | |||
import org.sonar.server.search.action.RefreshIndex; | |||
import org.sonar.server.search.action.UpsertDto; | |||
import org.sonar.server.search.action.UpsertNestedItem; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import java.io.Serializable; | |||
import java.sql.Timestamp; | |||
import java.util.*; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.Date; | |||
import java.util.List; | |||
import java.util.Map; | |||
import static com.google.common.collect.Lists.newArrayList; | |||
import static com.google.common.collect.Maps.newHashMap; | |||
@@ -115,7 +124,7 @@ import static com.google.common.collect.Maps.newHashMap; | |||
*/ | |||
public abstract class BaseDao<MAPPER, DTO extends Dto<KEY>, KEY extends Serializable> implements Dao<DTO, KEY>, DaoComponent { | |||
private static final Logger LOGGER = LoggerFactory.getLogger(BaseDao.class); | |||
private static final Logger LOGGER = Loggers.get(BaseDao.class); | |||
protected IndexDefinition indexDefinition; | |||
private Class<MAPPER> mapperClass; |
@@ -23,7 +23,7 @@ import com.google.common.base.Throwables; | |||
import org.apache.commons.dbutils.DbUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.picocontainer.Startable; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.api.ServerComponent; | |||
import org.sonar.core.persistence.Database; | |||
import org.sonar.core.persistence.dialect.H2; | |||
@@ -44,7 +44,7 @@ public class DatabaseChecker implements ServerComponent, Startable { | |||
public void start() { | |||
try { | |||
if (H2.ID.equals(db.getDialect().getId())) { | |||
LoggerFactory.getLogger(DatabaseChecker.class).warn("H2 database should be used for evaluation purpose only"); | |||
Loggers.get(DatabaseChecker.class).warn("H2 database should be used for evaluation purpose only"); | |||
} else if (Oracle.ID.equals(db.getDialect().getId())) { | |||
checkOracleDriverVersion(); | |||
} |
@@ -24,11 +24,11 @@ import org.apache.commons.lang.StringUtils; | |||
import org.h2.Driver; | |||
import org.h2.tools.Server; | |||
import org.picocontainer.Startable; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.api.database.DatabaseProperties; | |||
import org.sonar.api.utils.SonarException; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.process.ProcessConstants; | |||
import java.io.File; | |||
@@ -36,7 +36,7 @@ import java.sql.DriverManager; | |||
import java.sql.SQLException; | |||
public class EmbeddedDatabase implements Startable { | |||
private static final Logger LOG = LoggerFactory.getLogger(EmbeddedDatabase.class); | |||
private static final Logger LOG = Loggers.get(EmbeddedDatabase.class); | |||
private final Settings settings; | |||
private Server server; | |||
@@ -23,7 +23,7 @@ import com.google.common.annotations.VisibleForTesting; | |||
import org.apache.commons.dbutils.DbUtils; | |||
import org.apache.ibatis.session.SqlSession; | |||
import org.picocontainer.Startable; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.api.ServerComponent; | |||
import org.sonar.api.platform.ServerUpgradeStatus; | |||
import org.sonar.core.persistence.DdlUtils; | |||
@@ -70,7 +70,7 @@ public class DatabaseMigrator implements ServerComponent, Startable { | |||
@VisibleForTesting | |||
boolean createDatabase() { | |||
if (DdlUtils.supportsDialect(dbClient.database().getDialect().getId()) && serverUpgradeStatus.isFreshInstall()) { | |||
LoggerFactory.getLogger(getClass()).info("Create database"); | |||
Loggers.get(getClass()).info("Create database"); | |||
SqlSession session = dbClient.openSession(false); | |||
Connection connection = null; | |||
try { | |||
@@ -96,7 +96,7 @@ public class DatabaseMigrator implements ServerComponent, Startable { | |||
} catch (Exception e) { | |||
// duplication between log and exception because webapp does not correctly log initial stacktrace | |||
String msg = "Fail to execute database migration: " + className; | |||
LoggerFactory.getLogger(getClass()).error(msg, e); | |||
Loggers.get(getClass()).error(msg, e); | |||
throw new IllegalStateException(msg, e); | |||
} | |||
} |
@@ -19,7 +19,8 @@ | |||
*/ | |||
package org.sonar.server.db.migrations; | |||
import org.slf4j.Logger; | |||
import org.sonar.api.utils.log.Logger; | |||
import javax.annotation.CheckForNull; | |||
@@ -19,8 +19,9 @@ | |||
*/ | |||
package org.sonar.server.db.migrations.v36; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import java.util.TimerTask; | |||
import java.util.concurrent.atomic.AtomicLong; | |||
@@ -46,7 +47,7 @@ class Progress extends TimerTask { | |||
} | |||
Progress(long totalViolations) { | |||
this(totalViolations, LoggerFactory.getLogger(Progress.class), System.currentTimeMillis()); | |||
this(totalViolations, Loggers.get(Progress.class), System.currentTimeMillis()); | |||
} | |||
void increment(int delta) { |
@@ -19,10 +19,11 @@ | |||
*/ | |||
package org.sonar.server.db.migrations.v36; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.api.utils.MessageException; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.persistence.Database; | |||
import org.sonar.server.db.migrations.DatabaseMigration; | |||
import org.sonar.server.db.migrations.SqlUtil; | |||
@@ -34,7 +35,7 @@ import java.sql.SQLException; | |||
*/ | |||
public class ViolationMigration implements DatabaseMigration { | |||
private static final Logger LOGGER = LoggerFactory.getLogger(ViolationMigration.class); | |||
private static final Logger LOGGER = Loggers.get(ViolationMigration.class); | |||
private static final String FAILURE_MESSAGE = "Fail to convert violations to issues"; | |||
@@ -24,8 +24,6 @@ import com.google.common.base.Predicate; | |||
import com.google.common.collect.Iterables; | |||
import org.apache.commons.io.IOUtils; | |||
import org.apache.commons.lang.ObjectUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.ServerComponent; | |||
import org.sonar.api.rule.RuleKey; | |||
import org.sonar.api.server.debt.DebtCharacteristic; | |||
@@ -34,6 +32,8 @@ import org.sonar.api.server.debt.internal.DefaultDebtCharacteristic; | |||
import org.sonar.api.server.rule.RulesDefinition; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.api.utils.ValidationMessages; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.permission.GlobalPermissions; | |||
import org.sonar.core.persistence.DbSession; | |||
import org.sonar.core.persistence.MyBatis; | |||
@@ -58,7 +58,7 @@ import static com.google.common.collect.Lists.newArrayList; | |||
public class DebtModelBackup implements ServerComponent { | |||
private static final Logger LOG = LoggerFactory.getLogger(DebtModelBackup.class); | |||
private static final Logger LOG = Loggers.get(DebtModelBackup.class); | |||
private final DbClient dbClient; | |||
private final DebtModelOperations debtModelOperations; |
@@ -32,8 +32,8 @@ import org.elasticsearch.cluster.metadata.IndexMetaData; | |||
import org.elasticsearch.common.unit.ByteSizeUnit; | |||
import org.elasticsearch.common.unit.ByteSizeValue; | |||
import org.picocontainer.Startable; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.server.util.ProgressLogger; | |||
import java.util.List; | |||
@@ -49,7 +49,7 @@ import java.util.concurrent.atomic.AtomicLong; | |||
* </ul> | |||
*/ | |||
public class BulkIndexer implements Startable { | |||
private static final Logger LOGGER = LoggerFactory.getLogger(BulkIndexer.class); | |||
private static final Logger LOGGER = Loggers.get(BulkIndexer.class); | |||
private static final long FLUSH_BYTE_SIZE = new ByteSizeValue(5, ByteSizeUnit.MB).bytes(); | |||
private static final String REFRESH_INTERVAL_SETTING = "index.refresh_interval"; | |||
private static final String ALREADY_STARTED_MESSAGE = "Bulk indexing is already started"; |
@@ -25,9 +25,9 @@ import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; | |||
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse; | |||
import org.elasticsearch.common.settings.ImmutableSettings; | |||
import org.picocontainer.Startable; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.ServerComponent; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import java.util.Map; | |||
@@ -36,7 +36,7 @@ import java.util.Map; | |||
*/ | |||
public class IndexCreator implements ServerComponent, Startable { | |||
private static final Logger LOGGER = LoggerFactory.getLogger(IndexCreator.class); | |||
private static final Logger LOGGER = Loggers.get(IndexCreator.class); | |||
/** | |||
* Internal setting stored on index to know its version. It's used to re-create index |
@@ -25,14 +25,14 @@ import com.google.common.base.Predicate; | |||
import com.google.common.collect.Collections2; | |||
import com.google.common.collect.Iterables; | |||
import com.google.common.collect.Lists; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.issue.Issue; | |||
import org.sonar.api.issue.internal.DefaultIssue; | |||
import org.sonar.api.issue.internal.IssueChangeContext; | |||
import org.sonar.api.notifications.NotificationManager; | |||
import org.sonar.api.rule.RuleKey; | |||
import org.sonar.api.rules.Rule; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.component.ComponentDto; | |||
import org.sonar.core.issue.db.IssueDto; | |||
import org.sonar.core.issue.db.IssueStorage; | |||
@@ -63,7 +63,7 @@ import static com.google.common.collect.Sets.newHashSet; | |||
public class IssueBulkChangeService { | |||
private static final Logger LOG = LoggerFactory.getLogger(IssueBulkChangeService.class); | |||
private static final Logger LOG = Loggers.get(IssueBulkChangeService.class); | |||
private final DbClient dbClient; | |||
private final IssueService issueService; |
@@ -21,9 +21,9 @@ package org.sonar.server.measure; | |||
import com.google.common.base.Joiner; | |||
import org.apache.commons.lang.SystemUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.ServerComponent; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.profiling.Profiling; | |||
import org.sonar.core.profiling.Profiling.Level; | |||
import org.sonar.core.profiling.StopWatch; | |||
@@ -35,7 +35,7 @@ import java.util.Map; | |||
public class MeasureFilterEngine implements ServerComponent { | |||
private static final Logger LOG = LoggerFactory.getLogger("org.sonar.MEASURE_FILTER"); | |||
private static final Logger LOG = Loggers.get("org.sonar.MEASURE_FILTER"); | |||
private final MeasureFilterFactory factory; | |||
private final MeasureFilterExecutor executor; |
@@ -20,13 +20,14 @@ | |||
package org.sonar.server.notifications; | |||
import com.google.common.collect.Lists; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.ServerComponent; | |||
import org.sonar.api.notifications.NotificationChannel; | |||
import org.sonar.api.notifications.NotificationDispatcherMetadata; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import javax.annotation.Nullable; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
@@ -35,7 +36,7 @@ import java.util.List; | |||
*/ | |||
public class NotificationCenter implements ServerComponent { | |||
private static final Logger LOG = LoggerFactory.getLogger(NotificationCenter.class); | |||
private static final Logger LOG = Loggers.get(NotificationCenter.class); | |||
private final NotificationDispatcherMetadata[] dispatchersMetadata; | |||
private final NotificationChannel[] channels; |
@@ -24,8 +24,6 @@ import com.google.common.collect.HashMultimap; | |||
import com.google.common.collect.ImmutableList; | |||
import com.google.common.collect.SetMultimap; | |||
import org.picocontainer.Startable; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.Properties; | |||
import org.sonar.api.Property; | |||
import org.sonar.api.ServerComponent; | |||
@@ -34,6 +32,8 @@ import org.sonar.api.notifications.Notification; | |||
import org.sonar.api.notifications.NotificationChannel; | |||
import org.sonar.api.notifications.NotificationDispatcher; | |||
import org.sonar.api.utils.TimeProfiler; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.notification.DefaultNotificationManager; | |||
import org.sonar.server.db.DbClient; | |||
@@ -65,7 +65,7 @@ import java.util.concurrent.TimeUnit; | |||
}) | |||
public class NotificationService implements ServerComponent, Startable { | |||
private static final Logger LOG = LoggerFactory.getLogger(NotificationService.class); | |||
private static final Logger LOG = Loggers.get(NotificationService.class); | |||
public static final String PROPERTY_DELAY = "sonar.notifications.delay"; | |||
public static final String PROPERTY_DELAY_BEFORE_REPORTING_STATUS = "sonar.notifications.runningDelayBeforeReportingStatus"; |
@@ -21,7 +21,7 @@ package org.sonar.server.platform; | |||
import org.apache.commons.dbutils.DbUtils; | |||
import org.elasticsearch.index.query.QueryBuilders; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.api.ServerComponent; | |||
import org.sonar.core.persistence.DatabaseVersion; | |||
import org.sonar.core.persistence.DbSession; | |||
@@ -79,7 +79,7 @@ public class BackendCleanup implements ServerComponent { | |||
} | |||
public void clearIndexes() { | |||
LoggerFactory.getLogger(getClass()).info("Truncate Elasticsearch indices"); | |||
Loggers.get(getClass()).info("Truncate Elasticsearch indices"); | |||
try { | |||
esClient.prepareClearCache() | |||
.get(); |
@@ -24,7 +24,7 @@ import com.google.common.collect.Lists; | |||
import org.apache.commons.io.FileUtils; | |||
import org.apache.commons.lang.CharEncoding; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Loggers; | |||
import javax.annotation.Nullable; | |||
@@ -128,7 +128,7 @@ class ClassLoaderUtils { | |||
try { | |||
jar.close(); | |||
} catch (Exception e) { | |||
LoggerFactory.getLogger(ClassLoaderUtils.class).error("Fail to close JAR file: " + jarPath, e); | |||
Loggers.get(ClassLoaderUtils.class).error("Fail to close JAR file: " + jarPath, e); | |||
} | |||
} | |||
} |
@@ -20,7 +20,7 @@ | |||
package org.sonar.server.platform; | |||
import org.picocontainer.Startable; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.api.utils.MessageException; | |||
import org.sonar.core.persistence.DatabaseVersion; | |||
@@ -39,7 +39,7 @@ public class DatabaseServerCompatibility implements Startable { | |||
throw MessageException.of("Database relates to a more recent version of sonar. Please check your settings."); | |||
} | |||
if (status == DatabaseVersion.Status.REQUIRES_UPGRADE) { | |||
LoggerFactory.getLogger(DatabaseServerCompatibility.class).warn("Database must be upgraded. Please browse /setup"); | |||
Loggers.get(DatabaseServerCompatibility.class).warn("Database must be upgraded. Please browse /setup"); | |||
} | |||
} | |||
@@ -22,11 +22,11 @@ package org.sonar.server.platform; | |||
import org.apache.commons.io.FileUtils; | |||
import org.apache.commons.io.filefilter.FileFilterUtils; | |||
import org.picocontainer.Startable; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.api.platform.Server; | |||
import org.sonar.api.platform.ServerFileSystem; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.process.ProcessConstants; | |||
import java.io.File; | |||
@@ -43,7 +43,7 @@ import java.util.List; | |||
*/ | |||
public class DefaultServerFileSystem implements ServerFileSystem, Startable { | |||
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultServerFileSystem.class); | |||
private static final Logger LOGGER = Loggers.get(DefaultServerFileSystem.class); | |||
private final Server server; | |||
private File homeDir; |
@@ -22,7 +22,7 @@ package org.sonar.server.platform; | |||
import com.google.common.annotations.VisibleForTesting; | |||
import com.google.common.base.Preconditions; | |||
import com.google.common.collect.Lists; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.api.web.ServletFilter; | |||
import javax.servlet.*; | |||
@@ -63,7 +63,7 @@ public class MasterServletFilter implements Filter { | |||
List<Filter> filterList = Lists.newArrayList(); | |||
for (ServletFilter extension : filterExtensions) { | |||
try { | |||
LoggerFactory.getLogger(MasterServletFilter.class).info(String.format("Initializing servlet filter %s [pattern=%s]", extension, extension.doGetPattern())); | |||
Loggers.get(MasterServletFilter.class).info(String.format("Initializing servlet filter %s [pattern=%s]", extension, extension.doGetPattern())); | |||
extension.init(config); | |||
filterList.add(extension); | |||
} catch (Exception e) { |
@@ -19,7 +19,7 @@ | |||
*/ | |||
package org.sonar.server.platform; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.api.platform.ComponentContainer; | |||
import org.sonar.api.platform.Server; | |||
import org.sonar.core.persistence.DatabaseVersion; | |||
@@ -151,7 +151,7 @@ public class Platform { | |||
dbConnected = false; | |||
started = false; | |||
} catch (Exception e) { | |||
LoggerFactory.getLogger(getClass()).debug("Fail to stop server - ignored", e); | |||
Loggers.get(getClass()).debug("Fail to stop server - ignored", e); | |||
} | |||
} | |||
} |
@@ -24,14 +24,15 @@ import com.google.common.base.Function; | |||
import org.apache.commons.io.FileUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.picocontainer.Startable; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.Plugin; | |||
import org.sonar.api.platform.PluginMetadata; | |||
import org.sonar.api.platform.PluginRepository; | |||
import org.sonar.api.platform.ServerFileSystem; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import javax.annotation.Nullable; | |||
import java.io.File; | |||
import java.io.IOException; | |||
@@ -43,7 +44,7 @@ import java.io.IOException; | |||
*/ | |||
public class RailsAppsDeployer implements Startable { | |||
private static final Logger LOG = LoggerFactory.getLogger(RailsAppsDeployer.class); | |||
private static final Logger LOG = Loggers.get(RailsAppsDeployer.class); | |||
private static final String ROR_PATH = "org/sonar/ror/"; | |||
private final ServerFileSystem fileSystem; |
@@ -22,7 +22,7 @@ package org.sonar.server.platform; | |||
import com.google.common.collect.Lists; | |||
import org.apache.commons.codec.digest.DigestUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Loggers; | |||
import java.io.UnsupportedEncodingException; | |||
import java.net.InetAddress; | |||
@@ -121,7 +121,7 @@ public class ServerIdGenerator { | |||
} | |||
} | |||
} catch (SocketException e) { | |||
LoggerFactory.getLogger(ServerIdGenerator.class).error("Fail to browse network interfaces", e); | |||
Loggers.get(ServerIdGenerator.class).error("Fail to browse network interfaces", e); | |||
} | |||
return result; | |||
} |
@@ -26,11 +26,11 @@ import com.google.common.io.Resources; | |||
import org.apache.commons.io.IOUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.picocontainer.Startable; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.api.platform.Server; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.process.ProcessConstants; | |||
import java.io.File; | |||
@@ -42,7 +42,7 @@ import java.util.Date; | |||
import java.util.Properties; | |||
public final class ServerImpl extends Server implements Startable { | |||
private static final Logger LOG = LoggerFactory.getLogger(ServerImpl.class); | |||
private static final Logger LOG = Loggers.get(ServerImpl.class); | |||
private final Settings settings; | |||
private final Date startedAt; |
@@ -20,7 +20,7 @@ | |||
package org.sonar.server.platform; | |||
import org.picocontainer.Startable; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.api.platform.Server; | |||
import org.sonar.api.platform.ServerStartHandler; | |||
import org.sonar.api.platform.ServerStopHandler; | |||
@@ -62,7 +62,7 @@ public class ServerLifecycleNotifier implements Startable { | |||
} | |||
public void notifyStart() { | |||
LoggerFactory.getLogger(ServerLifecycleNotifier.class).debug("Notify " + ServerStartHandler.class.getSimpleName() + " handlers..."); | |||
Loggers.get(ServerLifecycleNotifier.class).debug("Notify " + ServerStartHandler.class.getSimpleName() + " handlers..."); | |||
for (ServerStartHandler handler : startHandlers) { | |||
handler.onServerStart(server); | |||
} | |||
@@ -70,7 +70,7 @@ public class ServerLifecycleNotifier implements Startable { | |||
@Override | |||
public void stop() { | |||
LoggerFactory.getLogger(ServerLifecycleNotifier.class).debug("Notify " + ServerStopHandler.class.getSimpleName() + " handlers..."); | |||
Loggers.get(ServerLifecycleNotifier.class).debug("Notify " + ServerStopHandler.class.getSimpleName() + " handlers..."); | |||
for (ServerStopHandler handler : stopHandlers) { | |||
handler.onServerStop(server); | |||
} |
@@ -1,93 +0,0 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* SonarQube is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.platform; | |||
import ch.qos.logback.classic.Level; | |||
import ch.qos.logback.classic.spi.ILoggingEvent; | |||
import ch.qos.logback.core.Appender; | |||
import ch.qos.logback.core.AppenderBase; | |||
import ch.qos.logback.core.spi.AppenderAttachable; | |||
import ch.qos.logback.core.spi.AppenderAttachableImpl; | |||
import org.sonar.server.computation.ComputationThreadLauncher; | |||
import java.util.Iterator; | |||
public class SwitchLogbackAppender extends AppenderBase<ILoggingEvent> implements AppenderAttachable<ILoggingEvent> { | |||
private AppenderAttachableImpl<ILoggingEvent> attachedAppenders = new AppenderAttachableImpl<>(); | |||
private Appender<ILoggingEvent> console = null; | |||
private Appender<ILoggingEvent> analysisReports = null; | |||
@Override | |||
protected void append(ILoggingEvent event) { | |||
if (Thread.currentThread().getName().startsWith(ComputationThreadLauncher.THREAD_NAME_PREFIX)) { | |||
analysisReports.doAppend(event); | |||
if (event.getLevel().isGreaterOrEqual(Level.WARN)) { | |||
console.doAppend(event); | |||
} | |||
} else { | |||
console.doAppend(event); | |||
} | |||
} | |||
@Override | |||
public void addAppender(Appender<ILoggingEvent> newAppender) { | |||
attachedAppenders.addAppender(newAppender); | |||
if ("CONSOLE".equals(newAppender.getName())) { | |||
console = newAppender; | |||
} else if ("ANALYSIS_REPORTS".equals(newAppender.getName())) { | |||
analysisReports = newAppender; | |||
} else { | |||
throw new IllegalArgumentException("Invalid appender name: " + newAppender.getName()); | |||
} | |||
} | |||
@Override | |||
public Iterator<Appender<ILoggingEvent>> iteratorForAppenders() { | |||
return attachedAppenders.iteratorForAppenders(); | |||
} | |||
@Override | |||
public Appender<ILoggingEvent> getAppender(String name) { | |||
return attachedAppenders.getAppender(name); | |||
} | |||
@Override | |||
public boolean isAttached(Appender<ILoggingEvent> appender) { | |||
return attachedAppenders.isAttached(appender); | |||
} | |||
@Override | |||
public void detachAndStopAllAppenders() { | |||
attachedAppenders.detachAndStopAllAppenders(); | |||
} | |||
@Override | |||
public boolean detachAppender(Appender<ILoggingEvent> appender) { | |||
return attachedAppenders.detachAppender(appender); | |||
} | |||
@Override | |||
public boolean detachAppender(String name) { | |||
return attachedAppenders.detachAppender(name); | |||
} | |||
} |
@@ -19,14 +19,15 @@ | |||
*/ | |||
package org.sonar.server.platform.ws; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.api.server.ws.Request; | |||
import org.sonar.api.server.ws.RequestHandler; | |||
import org.sonar.api.server.ws.Response; | |||
import org.sonar.api.server.ws.WebService; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.server.exceptions.ForbiddenException; | |||
import org.sonar.server.platform.Platform; | |||
@@ -54,7 +55,7 @@ public class RestartHandler implements RequestHandler { | |||
@Override | |||
public void handle(Request request, Response response) { | |||
if (canRestart()) { | |||
Logger logger = LoggerFactory.getLogger(getClass()); | |||
Logger logger = Loggers.get(getClass()); | |||
logger.info("Restart server"); | |||
platform.restart(); | |||
logger.info("Server restarted"); |
@@ -22,10 +22,10 @@ package org.sonar.server.plugins; | |||
import org.apache.commons.io.FileUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.picocontainer.Startable; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.HttpDownloader; | |||
import org.sonar.api.utils.SonarException; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.server.platform.DefaultServerFileSystem; | |||
import org.sonar.updatecenter.common.Release; | |||
import org.sonar.updatecenter.common.Version; | |||
@@ -40,7 +40,7 @@ import java.util.List; | |||
public class PluginDownloader implements Startable { | |||
private static final Logger LOG = LoggerFactory.getLogger(PluginDownloader.class); | |||
private static final Logger LOG = Loggers.get(PluginDownloader.class); | |||
private static final String TMP_SUFFIX = "tmp"; | |||
private static final String PLUGIN_EXTENSION = "jar"; | |||
@@ -24,13 +24,13 @@ import com.google.common.collect.Lists; | |||
import com.google.common.collect.Maps; | |||
import org.apache.commons.io.FileUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.platform.PluginMetadata; | |||
import org.sonar.api.platform.Server; | |||
import org.sonar.api.platform.ServerUpgradeStatus; | |||
import org.sonar.api.utils.MessageException; | |||
import org.sonar.api.utils.TimeProfiler; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.plugins.DefaultPluginMetadata; | |||
import org.sonar.server.platform.DefaultServerFileSystem; | |||
import org.sonar.updatecenter.common.PluginReferential; | |||
@@ -46,7 +46,7 @@ import java.util.Set; | |||
public class ServerPluginJarsInstaller { | |||
private static final Logger LOG = LoggerFactory.getLogger(ServerPluginJarsInstaller.class); | |||
private static final Logger LOG = Loggers.get(ServerPluginJarsInstaller.class); | |||
private final Server server; | |||
private final DefaultServerFileSystem fs; |
@@ -20,7 +20,7 @@ | |||
package org.sonar.server.plugins; | |||
import org.picocontainer.Startable; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.api.Plugin; | |||
import org.sonar.api.platform.PluginMetadata; | |||
import org.sonar.api.platform.PluginRepository; | |||
@@ -75,7 +75,7 @@ public class ServerPluginRepository implements PluginRepository, Startable { | |||
clazz = classloader.loadClass(classname); | |||
} catch (ClassNotFoundException e) { | |||
LoggerFactory.getLogger(getClass()).warn("Class not found in plugin " + pluginKey + ": " + classname, e); | |||
Loggers.get(getClass()).warn("Class not found in plugin " + pluginKey + ": " + classname, e); | |||
} | |||
} | |||
return clazz; |
@@ -22,21 +22,22 @@ package org.sonar.server.plugins; | |||
import com.google.common.annotations.VisibleForTesting; | |||
import org.apache.commons.io.IOUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.server.platform.Platform; | |||
import javax.servlet.ServletException; | |||
import javax.servlet.http.HttpServlet; | |||
import javax.servlet.http.HttpServletRequest; | |||
import javax.servlet.http.HttpServletResponse; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.io.OutputStream; | |||
public class StaticResourcesServlet extends HttpServlet { | |||
private static final Logger LOG = LoggerFactory.getLogger(StaticResourcesServlet.class); | |||
private static final Logger LOG = Loggers.get(StaticResourcesServlet.class); | |||
private static final long serialVersionUID = -2577454614650178426L; | |||
@Override |
@@ -21,7 +21,7 @@ package org.sonar.server.plugins; | |||
import com.google.common.base.Charsets; | |||
import org.apache.commons.io.IOUtils; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.api.Properties; | |||
import org.sonar.api.Property; | |||
import org.sonar.api.PropertyType; | |||
@@ -73,7 +73,7 @@ public class UpdateCenterClient { | |||
public UpdateCenterClient(UriReader uriReader, Settings settings) throws URISyntaxException { | |||
this.uriReader = uriReader; | |||
this.uri = new URI(settings.getString(URL_PROPERTY)); | |||
LoggerFactory.getLogger(getClass()).info("Update center: " + uriReader.description(uri)); | |||
Loggers.get(getClass()).info("Update center: " + uriReader.description(uri)); | |||
} | |||
public UpdateCenter getUpdateCenter() { | |||
@@ -106,7 +106,7 @@ public class UpdateCenterClient { | |||
return new UpdateCenterDeserializer(Mode.PROD, true).fromProperties(properties); | |||
} catch (Exception e) { | |||
LoggerFactory.getLogger(getClass()).error("Fail to connect to update center", e); | |||
Loggers.get(getClass()).error("Fail to connect to update center", e); | |||
return null; | |||
} finally { |
@@ -25,8 +25,6 @@ import com.google.common.collect.ListMultimap; | |||
import com.google.common.collect.Multimaps; | |||
import com.google.common.collect.Sets; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.ServerComponent; | |||
import org.sonar.api.profiles.ProfileDefinition; | |||
import org.sonar.api.profiles.RulesProfile; | |||
@@ -35,6 +33,8 @@ import org.sonar.api.rule.RuleKey; | |||
import org.sonar.api.rules.ActiveRuleParam; | |||
import org.sonar.api.utils.TimeProfiler; | |||
import org.sonar.api.utils.ValidationMessages; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.persistence.DbSession; | |||
import org.sonar.core.qualityprofile.db.QualityProfileDto; | |||
import org.sonar.core.template.LoadedTemplateDto; | |||
@@ -54,7 +54,7 @@ import java.util.Set; | |||
*/ | |||
public class RegisterQualityProfiles implements ServerComponent { | |||
private static final Logger LOGGER = LoggerFactory.getLogger(RegisterQualityProfiles.class); | |||
private static final Logger LOGGER = Loggers.get(RegisterQualityProfiles.class); | |||
private static final String DEFAULT_PROFILE_NAME = "Sonar way"; | |||
private final PersistentSettings settings; |
@@ -23,8 +23,6 @@ import com.google.common.base.Predicate; | |||
import com.google.common.collect.Iterables; | |||
import org.apache.commons.io.IOUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.ServerComponent; | |||
import org.sonar.api.rule.RuleKey; | |||
import org.sonar.api.rule.RuleStatus; | |||
@@ -34,6 +32,8 @@ import org.sonar.api.server.debt.DebtRemediationFunction; | |||
import org.sonar.api.server.rule.RuleParamType; | |||
import org.sonar.api.server.rule.RulesDefinition; | |||
import org.sonar.api.utils.ValidationMessages; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.i18n.RuleI18nManager; | |||
import org.sonar.server.debt.DebtModelPluginRepository; | |||
import org.sonar.server.debt.DebtModelXMLExporter; | |||
@@ -54,7 +54,7 @@ import static org.sonar.server.debt.DebtModelXMLExporter.RuleDebt; | |||
*/ | |||
public class DeprecatedRulesDefinitionLoader implements ServerComponent { | |||
private static final Logger LOG = LoggerFactory.getLogger(DeprecatedRulesDefinitionLoader.class); | |||
private static final Logger LOG = Loggers.get(DeprecatedRulesDefinitionLoader.class); | |||
private final RuleI18nManager i18n; | |||
private final RuleRepository[] repositories; |
@@ -28,8 +28,6 @@ import com.google.common.collect.Sets; | |||
import org.apache.commons.lang.ObjectUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.picocontainer.Startable; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.resources.Languages; | |||
import org.sonar.api.rule.RuleKey; | |||
import org.sonar.api.rule.RuleStatus; | |||
@@ -37,6 +35,8 @@ import org.sonar.api.server.debt.DebtRemediationFunction; | |||
import org.sonar.api.server.rule.RulesDefinition; | |||
import org.sonar.api.utils.MessageException; | |||
import org.sonar.api.utils.TimeProfiler; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.persistence.DbSession; | |||
import org.sonar.core.qualityprofile.db.ActiveRuleDto; | |||
import org.sonar.core.qualityprofile.db.ActiveRuleParamDto; | |||
@@ -52,7 +52,12 @@ import org.sonar.server.startup.RegisterDebtModel; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import java.util.*; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import static com.google.common.collect.Lists.newArrayList; | |||
@@ -61,7 +66,7 @@ import static com.google.common.collect.Lists.newArrayList; | |||
*/ | |||
public class RegisterRules implements Startable { | |||
private static final Logger LOG = LoggerFactory.getLogger(RegisterRules.class); | |||
private static final Logger LOG = Loggers.get(RegisterRules.class); | |||
private final RuleDefinitionsLoader defLoader; | |||
private final RuleActivator ruleActivator; |
@@ -21,12 +21,12 @@ package org.sonar.server.rule.ws; | |||
import com.google.common.collect.Maps; | |||
import com.google.common.collect.Sets; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.ServerComponent; | |||
import org.sonar.api.resources.Language; | |||
import org.sonar.api.resources.Languages; | |||
import org.sonar.api.rule.RuleKey; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.api.utils.text.JsonWriter; | |||
import org.sonar.core.qualityprofile.db.ActiveRuleKey; | |||
import org.sonar.core.qualityprofile.db.QualityProfileDto; | |||
@@ -47,7 +47,7 @@ import java.util.Map; | |||
*/ | |||
public class ActiveRuleCompleter implements ServerComponent { | |||
private static final Logger LOG = LoggerFactory.getLogger(ActiveRuleCompleter.class); | |||
private static final Logger LOG = Loggers.get(ActiveRuleCompleter.class); | |||
private final QProfileLoader loader; | |||
private final Languages languages; |
@@ -26,14 +26,23 @@ import com.google.common.collect.Multimap; | |||
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse; | |||
import org.elasticsearch.action.count.CountRequestBuilder; | |||
import org.elasticsearch.action.count.CountResponse; | |||
import org.elasticsearch.action.get.*; | |||
import org.elasticsearch.action.get.GetRequestBuilder; | |||
import org.elasticsearch.action.get.GetResponse; | |||
import org.elasticsearch.action.get.MultiGetItemResponse; | |||
import org.elasticsearch.action.get.MultiGetRequest; | |||
import org.elasticsearch.action.get.MultiGetRequestBuilder; | |||
import org.elasticsearch.action.get.MultiGetResponse; | |||
import org.elasticsearch.action.search.SearchRequestBuilder; | |||
import org.elasticsearch.action.search.SearchResponse; | |||
import org.elasticsearch.action.search.SearchScrollRequestBuilder; | |||
import org.elasticsearch.common.settings.ImmutableSettings; | |||
import org.elasticsearch.common.settings.Settings; | |||
import org.elasticsearch.common.unit.TimeValue; | |||
import org.elasticsearch.index.query.*; | |||
import org.elasticsearch.index.query.BoolFilterBuilder; | |||
import org.elasticsearch.index.query.FilterBuilder; | |||
import org.elasticsearch.index.query.FilterBuilders; | |||
import org.elasticsearch.index.query.QueryBuilder; | |||
import org.elasticsearch.index.query.QueryBuilders; | |||
import org.elasticsearch.search.SearchHit; | |||
import org.elasticsearch.search.aggregations.Aggregation; | |||
import org.elasticsearch.search.aggregations.AggregationBuilders; | |||
@@ -44,8 +53,8 @@ import org.elasticsearch.search.aggregations.metrics.max.Max; | |||
import org.elasticsearch.search.aggregations.metrics.valuecount.InternalValueCount; | |||
import org.elasticsearch.search.fetch.source.FetchSourceContext; | |||
import org.joda.time.DateTime; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.persistence.Dto; | |||
import org.sonar.server.exceptions.NotFoundException; | |||
@@ -53,12 +62,22 @@ import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import java.io.Serializable; | |||
import java.util.*; | |||
import java.util.ArrayDeque; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.Date; | |||
import java.util.HashMap; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.NoSuchElementException; | |||
import java.util.Queue; | |||
public abstract class BaseIndex<DOMAIN, DTO extends Dto<KEY>, KEY extends Serializable> | |||
implements Index<DOMAIN, DTO, KEY> { | |||
private static final Logger LOG = LoggerFactory.getLogger(BaseIndex.class); | |||
private static final Logger LOG = Loggers.get(BaseIndex.class); | |||
private final SearchClient client; | |||
private final BaseNormalizer<DTO, KEY> normalizer; |
@@ -29,8 +29,8 @@ import org.elasticsearch.search.aggregations.HasAggregations; | |||
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogram; | |||
import org.elasticsearch.search.aggregations.bucket.missing.Missing; | |||
import org.elasticsearch.search.aggregations.bucket.terms.Terms; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
@@ -39,7 +39,7 @@ import java.util.Map; | |||
class Facets { | |||
private static final Logger LOGGER = LoggerFactory.getLogger(Facets.class); | |||
private static final Logger LOGGER = Loggers.get(Facets.class); | |||
private final Multimap<String, FacetValue> facetValues; | |||
@@ -28,14 +28,18 @@ import org.elasticsearch.action.bulk.BulkResponse; | |||
import org.elasticsearch.action.delete.DeleteRequest; | |||
import org.elasticsearch.action.index.IndexRequest; | |||
import org.elasticsearch.action.update.UpdateRequest; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.ServerComponent; | |||
import org.sonar.api.platform.ComponentContainer; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.cluster.WorkQueue; | |||
import org.sonar.server.search.action.IndexAction; | |||
import java.util.*; | |||
import java.util.HashMap; | |||
import java.util.HashSet; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Set; | |||
import java.util.concurrent.ExecutorService; | |||
import java.util.concurrent.Executors; | |||
import java.util.concurrent.Future; | |||
@@ -46,7 +50,7 @@ public class IndexQueue implements ServerComponent, WorkQueue<IndexAction<?>> { | |||
private final SearchClient searchClient; | |||
private final ComponentContainer container; | |||
private static final Logger LOGGER = LoggerFactory.getLogger(IndexQueue.class); | |||
private static final Logger LOGGER = Loggers.get(IndexQueue.class); | |||
private static final Integer CONCURRENT_NORMALIZATION_FACTOR = 1; | |||
@@ -19,8 +19,9 @@ | |||
*/ | |||
package org.sonar.server.search; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.persistence.DbSession; | |||
import org.sonar.server.activity.index.ActivityIndex; | |||
import org.sonar.server.db.Dao; | |||
@@ -37,7 +38,7 @@ import java.util.Date; | |||
public class IndexSynchronizer { | |||
private static final Logger LOG = LoggerFactory.getLogger(IndexSynchronizer.class); | |||
private static final Logger LOG = Loggers.get(IndexSynchronizer.class); | |||
private final DbClient db; | |||
private final IndexClient index; |
@@ -20,7 +20,7 @@ | |||
package org.sonar.server.source; | |||
import com.google.common.io.Closeables; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Loggers; | |||
import javax.annotation.Nullable; | |||
@@ -89,7 +89,7 @@ class HtmlTextDecorator { | |||
} catch (IOException exception) { | |||
String errorMsg = "An exception occurred while highlighting the syntax of one of the project's files"; | |||
LoggerFactory.getLogger(HtmlTextDecorator.class).error(errorMsg); | |||
Loggers.get(HtmlTextDecorator.class).error(errorMsg); | |||
throw new IllegalStateException(errorMsg, exception); | |||
} finally { | |||
Closeables.closeQuietly(stringBuffer); |
@@ -26,12 +26,12 @@ import com.google.common.collect.ArrayListMultimap; | |||
import com.google.common.collect.Iterables; | |||
import com.google.common.collect.Multimap; | |||
import org.apache.commons.lang.builder.EqualsBuilder; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.ServerComponent; | |||
import org.sonar.api.rule.RuleStatus; | |||
import org.sonar.api.server.debt.DebtRemediationFunction; | |||
import org.sonar.api.utils.Duration; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.persistence.DbSession; | |||
import org.sonar.core.persistence.MyBatis; | |||
import org.sonar.core.rule.RuleDto; | |||
@@ -59,7 +59,7 @@ import java.util.List; | |||
*/ | |||
public class CopyRequirementsFromCharacteristicsToRules implements ServerComponent { | |||
private static final Logger LOGGER = LoggerFactory.getLogger(CopyRequirementsFromCharacteristicsToRules.class); | |||
private static final Logger LOGGER = Loggers.get(CopyRequirementsFromCharacteristicsToRules.class); | |||
private static final String TEMPLATE_KEY = "CopyRequirementsFromCharacteristicsToRules"; | |||
@@ -20,9 +20,9 @@ | |||
package org.sonar.server.startup; | |||
import com.google.common.annotations.VisibleForTesting; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.properties.PropertiesDao; | |||
import org.sonar.core.properties.PropertyDto; | |||
@@ -38,7 +38,7 @@ public final class LogServerId { | |||
} | |||
public void start() { | |||
logServerId(LoggerFactory.getLogger(LogServerId.class)); | |||
logServerId(Loggers.get(LogServerId.class)); | |||
} | |||
@VisibleForTesting |
@@ -22,9 +22,9 @@ package org.sonar.server.startup; | |||
import com.google.common.collect.Lists; | |||
import com.google.common.collect.Ordering; | |||
import org.picocontainer.Startable; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.TimeProfiler; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.api.web.Dashboard; | |||
import org.sonar.api.web.DashboardTemplate; | |||
import org.sonar.core.dashboard.ActiveDashboardDao; | |||
@@ -45,7 +45,7 @@ import java.util.Map.Entry; | |||
* @since 2.13 | |||
*/ | |||
public class RegisterDashboards implements Startable { | |||
private static final Logger LOG = LoggerFactory.getLogger(RegisterDashboards.class); | |||
private static final Logger LOG = Loggers.get(RegisterDashboards.class); | |||
static final String DEFAULT_DASHBOARD_NAME = "Dashboard"; | |||
@@ -20,15 +20,16 @@ | |||
package org.sonar.server.startup; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.TimeProfiler; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.technicaldebt.db.CharacteristicDao; | |||
import org.sonar.server.debt.DebtModelBackup; | |||
public class RegisterDebtModel { | |||
private static final Logger LOGGER = LoggerFactory.getLogger(RegisterDebtModel.class); | |||
private static final Logger LOGGER = Loggers.get(RegisterDebtModel.class); | |||
private final CharacteristicDao dao; | |||
private final DebtModelBackup debtModelBackup; |
@@ -23,12 +23,12 @@ import com.google.common.annotations.VisibleForTesting; | |||
import com.google.common.base.Predicate; | |||
import com.google.common.collect.Iterables; | |||
import com.google.common.collect.Maps; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.measures.CoreMetrics; | |||
import org.sonar.api.measures.Metric; | |||
import org.sonar.api.measures.Metrics; | |||
import org.sonar.api.utils.TimeProfiler; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.qualitygate.db.QualityGateConditionDao; | |||
import org.sonar.jpa.dao.MeasuresDao; | |||
@@ -39,7 +39,7 @@ import static com.google.common.collect.Lists.newArrayList; | |||
public class RegisterMetrics { | |||
private static final Logger LOG = LoggerFactory.getLogger(RegisterMetrics.class); | |||
private static final Logger LOG = Loggers.get(RegisterMetrics.class); | |||
private final MeasuresDao measuresDao; | |||
private final Metrics[] metricsRepositories; |
@@ -23,9 +23,9 @@ import com.google.common.base.Joiner; | |||
import com.google.common.collect.ImmutableList; | |||
import com.google.common.collect.Lists; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.TimeProfiler; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.api.web.Criterion; | |||
import org.sonar.api.web.Filter; | |||
import org.sonar.api.web.FilterColumn; | |||
@@ -42,7 +42,7 @@ import java.util.List; | |||
* @since 3.1 | |||
*/ | |||
public final class RegisterNewMeasureFilters { | |||
private static final Logger LOG = LoggerFactory.getLogger(RegisterNewMeasureFilters.class); | |||
private static final Logger LOG = Loggers.get(RegisterNewMeasureFilters.class); | |||
private final List<FilterTemplate> filterTemplates; | |||
private final MeasureFilterDao filterDao; |
@@ -20,10 +20,11 @@ | |||
package org.sonar.server.startup; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.security.DefaultGroups; | |||
import org.sonar.api.utils.TimeProfiler; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.api.web.UserRole; | |||
import org.sonar.core.permission.PermissionTemplateDao; | |||
import org.sonar.core.permission.PermissionTemplateDto; | |||
@@ -38,7 +39,7 @@ public class RegisterPermissionTemplates { | |||
public static final String DEFAULT_TEMPLATE_PROPERTY = "sonar.permission.template.default"; | |||
public static final String DEFAULT_PROJECTS_TEMPLATE_PROPERTY = "sonar.permission.template.TRK.default"; | |||
private static final Logger LOG = LoggerFactory.getLogger(RegisterPermissionTemplates.class); | |||
private static final Logger LOG = Loggers.get(RegisterPermissionTemplates.class); | |||
private final LoadedTemplateDao loadedTemplateDao; | |||
private final PermissionTemplateDao permissionTemplateDao; |
@@ -20,7 +20,7 @@ | |||
package org.sonar.server.startup; | |||
import com.google.common.base.Strings; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.api.config.PropertyDefinition; | |||
import org.sonar.api.config.PropertyDefinitions; | |||
import org.sonar.core.properties.PropertiesDao; | |||
@@ -39,7 +39,7 @@ public class RenameDeprecatedPropertyKeys { | |||
} | |||
public void start() { | |||
LoggerFactory.getLogger(RenameDeprecatedPropertyKeys.class).info("Rename deprecated property keys"); | |||
Loggers.get(RenameDeprecatedPropertyKeys.class).info("Rename deprecated property keys"); | |||
for (PropertyDefinition definition : definitions.getAll()) { | |||
if (!Strings.isNullOrEmpty(definition.deprecatedKey())) { | |||
dao.renamePropertyKey(definition.deprecatedKey(), definition.key()); |
@@ -21,7 +21,7 @@ package org.sonar.server.startup; | |||
import com.google.common.collect.ImmutableMap; | |||
import org.picocontainer.Startable; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.platform.Server; | |||
import org.sonar.server.platform.PersistentSettings; | |||
@@ -40,7 +40,7 @@ public final class ServerMetadataPersister implements Startable { | |||
@Override | |||
public void start() { | |||
LoggerFactory.getLogger(getClass()).debug("Persisting server metadata"); | |||
Loggers.get(getClass()).debug("Persisting server metadata"); | |||
persistentSettings.saveProperties(ImmutableMap.of( | |||
CoreProperties.SERVER_ID, server.getId(), | |||
CoreProperties.SERVER_VERSION, server.getVersion(), |
@@ -19,7 +19,7 @@ | |||
*/ | |||
package org.sonar.server.ui; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.api.config.License; | |||
import org.sonar.api.config.PropertyDefinitions; | |||
import org.sonar.api.config.Settings; | |||
@@ -279,7 +279,7 @@ public final class JRubyFacade { | |||
try { | |||
return get(Class.forName(className)); | |||
} catch (ClassNotFoundException e) { | |||
LoggerFactory.getLogger(getClass()).error("Component not found: " + className, e); | |||
Loggers.get(getClass()).error("Component not found: " + className, e); | |||
return null; | |||
} | |||
} | |||
@@ -313,13 +313,13 @@ public final class JRubyFacade { | |||
try { | |||
get(ComponentCleanerService.class).delete(projectKey); | |||
} catch (RuntimeException e) { | |||
LoggerFactory.getLogger(JRubyFacade.class).error("Fail to delete resource with key: " + projectKey, e); | |||
Loggers.get(JRubyFacade.class).error("Fail to delete resource with key: " + projectKey, e); | |||
throw e; | |||
} | |||
} | |||
public void logError(String message) { | |||
LoggerFactory.getLogger(getClass()).error(message); | |||
Loggers.get(getClass()).error(message); | |||
} | |||
public boolean hasSecretKey() { |
@@ -20,8 +20,9 @@ | |||
package org.sonar.server.ui; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.profiling.Profiling; | |||
import org.sonar.core.profiling.Profiling.Level; | |||
import org.sonar.core.profiling.StopWatch; | |||
@@ -31,7 +32,7 @@ import org.sonar.core.profiling.StopWatch; | |||
*/ | |||
public class JRubyProfiling { | |||
private static final Logger LOG = LoggerFactory.getLogger(JRubyProfiling.class); | |||
private static final Logger LOG = Loggers.get(JRubyProfiling.class); | |||
private Profiling profiling; | |||
@@ -19,7 +19,7 @@ | |||
*/ | |||
package org.sonar.server.user; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.api.ServerComponent; | |||
import org.sonar.api.platform.NewUserHandler; | |||
@@ -39,7 +39,7 @@ public class NewUserNotifier implements ServerComponent { | |||
} | |||
public void onNewUser(NewUserHandler.Context context) { | |||
LoggerFactory.getLogger(NewUserNotifier.class).debug("User created: " + context.getLogin() + ". Notifying " + NewUserHandler.class.getSimpleName() + " handlers..."); | |||
Loggers.get(NewUserNotifier.class).debug("User created: " + context.getLogin() + ". Notifying " + NewUserHandler.class.getSimpleName() + " handlers..."); | |||
for (NewUserHandler handler : handlers) { | |||
handler.doOnNewUser(context); | |||
} |
@@ -21,14 +21,14 @@ package org.sonar.server.user; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.picocontainer.Startable; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.ServerComponent; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.api.security.LoginPasswordAuthenticator; | |||
import org.sonar.api.security.SecurityRealm; | |||
import org.sonar.api.utils.SonarException; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
/** | |||
* @since 2.14 | |||
@@ -76,7 +76,7 @@ public class SecurityRealmFactory implements ServerComponent, Startable { | |||
@Override | |||
public void start() { | |||
if (realm != null) { | |||
Logger logger = LoggerFactory.getLogger("org.sonar.INFO"); | |||
Logger logger = Loggers.get("org.sonar.INFO"); | |||
try { | |||
logger.info("Security realm: " + realm.getName()); | |||
realm.init(); |
@@ -22,9 +22,9 @@ package org.sonar.server.user; | |||
import com.google.common.base.Objects; | |||
import com.google.common.base.Strings; | |||
import com.google.common.collect.HashMultimap; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.security.DefaultGroups; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.permission.GlobalPermissions; | |||
import org.sonar.core.resource.ResourceDao; | |||
import org.sonar.core.resource.ResourceDto; | |||
@@ -36,7 +36,13 @@ import org.sonar.server.platform.Platform; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import java.util.*; | |||
import java.util.ArrayList; | |||
import java.util.Arrays; | |||
import java.util.Collection; | |||
import java.util.List; | |||
import java.util.Locale; | |||
import java.util.Map; | |||
import java.util.Set; | |||
import static com.google.common.collect.Lists.newArrayList; | |||
import static com.google.common.collect.Maps.newHashMap; | |||
@@ -50,7 +56,7 @@ public class UserSession { | |||
public static final UserSession ANONYMOUS = new UserSession(); | |||
private static final ThreadLocal<UserSession> THREAD_LOCAL = new ThreadLocal<UserSession>(); | |||
private static final Logger LOG = LoggerFactory.getLogger(UserSession.class); | |||
private static final Logger LOG = Loggers.get(UserSession.class); | |||
private static final String INSUFFICIENT_PRIVILEGES_MESSAGE = "Insufficient privileges"; | |||
private Integer userId; |
@@ -19,8 +19,9 @@ | |||
*/ | |||
package org.sonar.server.util; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import java.util.Timer; | |||
import java.util.TimerTask; | |||
@@ -44,7 +45,7 @@ public class ProgressLogger { | |||
public static ProgressLogger create(Class clazz, AtomicLong counter) { | |||
String threadName = String.format("ProgressLogger[%s]", clazz.getSimpleName()); | |||
Logger logger = LoggerFactory.getLogger(clazz); | |||
Logger logger = Loggers.get(clazz); | |||
return new ProgressLogger(threadName, counter, logger); | |||
} | |||
@@ -21,7 +21,7 @@ package org.sonar.server.ws; | |||
import com.google.common.base.Charsets; | |||
import org.picocontainer.Startable; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.api.ServerComponent; | |||
import org.sonar.api.i18n.I18n; | |||
import org.sonar.api.server.ws.Request; | |||
@@ -91,7 +91,8 @@ public class WebServiceEngine implements ServerComponent, Startable { | |||
} catch (ServerException e) { | |||
sendErrors(response, e.httpCode(), new Errors().add(Message.of(e.getMessage()))); | |||
} catch (Exception e) { | |||
LoggerFactory.getLogger(getClass()).error("Fail to process request " + request, e); | |||
// TODO implement Request.toString() | |||
Loggers.get(getClass()).error("Fail to process request " + request, e); | |||
sendErrors(response, 500, new Errors().add(Message.of(e.getMessage()))); | |||
} | |||
} |
@@ -22,9 +22,9 @@ package org.sonar.core.computation.dbcleaner; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import org.slf4j.Logger; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.core.computation.dbcleaner.period.DefaultPeriodCleaner; | |||
import org.sonar.core.persistence.DbSession; | |||
import org.sonar.core.purge.IdUuidPair; |
@@ -24,7 +24,7 @@ import org.apache.catalina.startup.Tomcat; | |||
import org.apache.coyote.http11.AbstractHttp11JsseProtocol; | |||
import org.junit.Test; | |||
import org.mockito.Mockito; | |||
import org.slf4j.Logger; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.process.Props; | |||
import java.util.Properties; |
@@ -27,7 +27,7 @@ import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.mockito.Mockito; | |||
import org.slf4j.Logger; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.process.ProcessConstants; | |||
import org.sonar.process.Props; | |||
@@ -22,8 +22,8 @@ package org.sonar.server.computation.issue; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Test; | |||
import org.slf4j.Logger; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.server.es.EsTester; | |||
import org.sonar.server.user.index.UserIndex; | |||
import org.sonar.server.user.index.UserIndexDefinition; |
@@ -20,7 +20,7 @@ | |||
package org.sonar.server.db.migrations; | |||
import org.junit.Test; | |||
import org.slf4j.Logger; | |||
import org.sonar.api.utils.log.Logger; | |||
import java.sql.SQLException; | |||
@@ -21,12 +21,10 @@ package org.sonar.server.db.migrations.v36; | |||
import org.junit.Test; | |||
import org.mockito.ArgumentCaptor; | |||
import org.slf4j.Logger; | |||
import org.sonar.api.utils.log.Logger; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.times; | |||
import static org.mockito.Mockito.verify; | |||
import static org.mockito.Mockito.*; | |||
public class ProgressTest { | |||
@Test |
@@ -1,127 +0,0 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* SonarQube is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.platform; | |||
import ch.qos.logback.classic.Logger; | |||
import ch.qos.logback.classic.LoggerContext; | |||
import ch.qos.logback.classic.joran.JoranConfigurator; | |||
import ch.qos.logback.classic.spi.ILoggingEvent; | |||
import ch.qos.logback.core.joran.spi.JoranException; | |||
import ch.qos.logback.core.read.ListAppender; | |||
import ch.qos.logback.core.status.Status; | |||
import ch.qos.logback.core.util.StatusPrinter; | |||
import org.junit.Test; | |||
import org.sonar.server.computation.ComputationThreadLauncher; | |||
import java.net.URL; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
public class SwitchLogbackAppenderTest { | |||
LoggerContext loggerContext = new LoggerContext(); | |||
Logger logger = loggerContext.getLogger(this.getClass().getName()); | |||
SwitchLogbackAppender switchAppender; | |||
ListAppender<ILoggingEvent> console, analyisReports; | |||
protected void configure(URL file) throws JoranException { | |||
JoranConfigurator jc = new JoranConfigurator(); | |||
jc.setContext(loggerContext); | |||
jc.doConfigure(file); | |||
Logger root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); | |||
switchAppender = (SwitchLogbackAppender) root.getAppender("SWITCH"); | |||
console = (ListAppender<ILoggingEvent>) switchAppender.getAppender("CONSOLE"); | |||
analyisReports = (ListAppender<ILoggingEvent>) switchAppender.getAppender("ANALYSIS_REPORTS"); | |||
} | |||
/** | |||
* Standard log goes to console only | |||
*/ | |||
@Test | |||
public void standard_log() throws JoranException { | |||
configure(getClass().getResource("SwitchLogbackAppenderTest/valid-switch.xml")); | |||
logger.info("hello"); | |||
assertThat(console.list).hasSize(1); | |||
assertThat(console.list.get(0).getMessage()).isEqualTo("hello"); | |||
assertThat(analyisReports.list).isEmpty(); | |||
} | |||
/** | |||
* Compute service log goes to dedicated appender. Warnings and errors are logged in both appenders. | |||
*/ | |||
@Test | |||
public void compute_service_log_goes_to_dedicated_appender() throws JoranException { | |||
configure(getClass().getResource("SwitchLogbackAppenderTest/valid-switch.xml")); | |||
String initialThreadName = Thread.currentThread().getName(); | |||
Thread.currentThread().setName(ComputationThreadLauncher.THREAD_NAME_PREFIX + "test"); | |||
try { | |||
logger.info("hello"); | |||
assertThat(analyisReports.list).hasSize(1); | |||
assertThat(analyisReports.list.get(0).getMessage()).isEqualTo("hello"); | |||
assertThat(console.list).isEmpty(); | |||
logger.warn("a warning"); | |||
assertThat(analyisReports.list).hasSize(2); | |||
assertThat(analyisReports.list.get(1).getMessage()).isEqualTo("a warning"); | |||
assertThat(console.list).hasSize(1); | |||
assertThat(console.list.get(0).getMessage()).isEqualTo("a warning"); | |||
logger.error("an error"); | |||
assertThat(analyisReports.list).hasSize(3); | |||
assertThat(analyisReports.list.get(2).getMessage()).isEqualTo("an error"); | |||
assertThat(console.list).hasSize(2); | |||
assertThat(console.list.get(1).getMessage()).isEqualTo("an error"); | |||
} finally { | |||
Thread.currentThread().setName(initialThreadName); | |||
} | |||
} | |||
@Test | |||
public void fail_if_bad_configuration() throws JoranException { | |||
boolean foundError = false; | |||
configure(getClass().getResource("SwitchLogbackAppenderTest/invalid-switch.xml")); | |||
StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext); | |||
for (Status status : loggerContext.getStatusManager().getCopyOfStatusList()) { | |||
Throwable error = status.getThrowable(); | |||
if (error != null) { | |||
assertThat(error).hasMessage("Invalid appender name: UNKNOWN"); | |||
foundError = true; | |||
} | |||
} | |||
assertThat(foundError).isTrue(); | |||
} | |||
@Test | |||
public void test_logback_internals() throws Exception { | |||
configure(getClass().getResource("SwitchLogbackAppenderTest/valid-switch.xml")); | |||
assertThat(switchAppender.iteratorForAppenders()).hasSize(2); | |||
assertThat(switchAppender.isAttached(console)).isTrue(); | |||
assertThat(switchAppender.detachAppender("CONSOLE")).isTrue(); | |||
assertThat(switchAppender.detachAppender(analyisReports)).isTrue(); | |||
switchAppender.detachAndStopAllAppenders(); | |||
} | |||
} |
@@ -23,8 +23,8 @@ import org.junit.Before; | |||
import org.junit.Test; | |||
import org.mockito.Mock; | |||
import org.mockito.MockitoAnnotations; | |||
import org.slf4j.Logger; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.core.properties.PropertiesDao; | |||
import org.sonar.core.properties.PropertyDto; | |||
@@ -25,10 +25,10 @@ import com.google.common.collect.Lists; | |||
import org.apache.commons.io.FileUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.junit.rules.ExternalResource; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.database.DatabaseProperties; | |||
import org.sonar.api.resources.Language; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.process.ProcessConstants; | |||
import org.sonar.server.es.EsServerHolder; | |||
import org.sonar.server.platform.BackendCleanup; | |||
@@ -54,7 +54,7 @@ import java.util.Properties; | |||
*/ | |||
public class ServerTester extends ExternalResource { | |||
private static final Logger LOG = LoggerFactory.getLogger(ServerTester.class); | |||
private static final Logger LOG = Loggers.get(ServerTester.class); | |||
private static final String PROP_PREFIX = "mediumTests."; | |||
private Platform platform; |
@@ -20,14 +20,12 @@ | |||
package org.sonar.server.util; | |||
import org.junit.Test; | |||
import org.slf4j.Logger; | |||
import org.sonar.api.utils.log.Logger; | |||
import java.util.concurrent.atomic.AtomicLong; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.atLeast; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.verify; | |||
import static org.mockito.Mockito.*; | |||
public class ProgressLoggerTest { | |||
@@ -1,14 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8" ?> | |||
<configuration debug="false"> | |||
<appender name="CONSOLE" class="ch.qos.logback.core.read.ListAppender" /> | |||
<appender name="UNKNOWN" class="ch.qos.logback.core.read.ListAppender" /> | |||
<appender name="SWITCH" class="org.sonar.server.platform.SwitchLogbackAppender"> | |||
<appender-ref ref="CONSOLE" /> | |||
<appender-ref ref="UNKNOWN" /> | |||
</appender> | |||
<root level="DEBUG"> | |||
<appender-ref ref="SWITCH" /> | |||
</root> | |||
</configuration> |
@@ -1,15 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8" ?> | |||
<configuration debug="false"> | |||
<appender name="CONSOLE" class="ch.qos.logback.core.read.ListAppender" /> | |||
<appender name="ANALYSIS_REPORTS" class="ch.qos.logback.core.read.ListAppender" /> | |||
<appender name="SWITCH" class="org.sonar.server.platform.SwitchLogbackAppender"> | |||
<!-- do not change appender names. See org.sonar.server.platform.SwitchLogbackAppender --> | |||
<appender-ref ref="CONSOLE" /> | |||
<appender-ref ref="ANALYSIS_REPORTS" /> | |||
</appender> | |||
<root level="DEBUG"> | |||
<appender-ref ref="SWITCH" /> | |||
</root> | |||
</configuration> |
@@ -91,6 +91,18 @@ | |||
<groupId>org.slf4j</groupId> | |||
<artifactId>slf4j-api</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.slf4j</groupId> | |||
<artifactId>jcl-over-slf4j</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.slf4j</groupId> | |||
<artifactId>log4j-over-slf4j</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.slf4j</groupId> | |||
<artifactId>jul-to-slf4j</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.maven</groupId> | |||
<artifactId>maven-plugin-api</artifactId> |
@@ -23,13 +23,13 @@ package org.sonar.batch.debt; | |||
import com.google.common.base.Predicate; | |||
import com.google.common.collect.Iterables; | |||
import org.picocontainer.injectors.ProviderAdapter; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.batch.debt.DebtCharacteristic; | |||
import org.sonar.api.batch.debt.DebtModel; | |||
import org.sonar.api.batch.debt.internal.DefaultDebtCharacteristic; | |||
import org.sonar.api.batch.debt.internal.DefaultDebtModel; | |||
import org.sonar.api.utils.TimeProfiler; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.technicaldebt.db.CharacteristicDao; | |||
import org.sonar.core.technicaldebt.db.CharacteristicDto; | |||
@@ -39,7 +39,7 @@ import java.util.List; | |||
public class DebtModelProvider extends ProviderAdapter { | |||
private static final Logger LOG = LoggerFactory.getLogger(DebtModelProvider.class); | |||
private static final Logger LOG = Loggers.get(DebtModelProvider.class); | |||
private DebtModel model; | |||
@@ -23,8 +23,6 @@ package org.sonar.batch.rule; | |||
import com.google.common.collect.ArrayListMultimap; | |||
import com.google.common.collect.ListMultimap; | |||
import org.picocontainer.injectors.ProviderAdapter; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.batch.debt.DebtCharacteristic; | |||
import org.sonar.api.batch.debt.DebtModel; | |||
import org.sonar.api.batch.debt.DebtRemediationFunction; | |||
@@ -35,6 +33,8 @@ import org.sonar.api.batch.rule.internal.RulesBuilder; | |||
import org.sonar.api.rule.RuleKey; | |||
import org.sonar.api.utils.Durations; | |||
import org.sonar.api.utils.TimeProfiler; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.rule.RuleDao; | |||
import org.sonar.core.rule.RuleDto; | |||
import org.sonar.core.rule.RuleParamDto; | |||
@@ -48,7 +48,7 @@ import java.util.List; | |||
*/ | |||
public class RulesProvider extends ProviderAdapter { | |||
private static final Logger LOG = LoggerFactory.getLogger(RulesProvider.class); | |||
private static final Logger LOG = Loggers.get(RulesProvider.class); | |||
private Rules singleton = null; | |||
@@ -21,15 +21,15 @@ package org.sonar.batch.scan; | |||
import com.google.common.base.Splitter; | |||
import com.google.common.collect.Iterators; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.BatchComponent; | |||
import org.sonar.api.utils.TimeProfiler; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.batch.bootstrap.ServerClient; | |||
public class LastLineHashes implements BatchComponent { | |||
private static final Logger LOG = LoggerFactory.getLogger(LastLineHashes.class); | |||
private static final Logger LOG = Loggers.get(LastLineHashes.class); | |||
private final ServerClient server; | |||
@@ -21,14 +21,18 @@ | |||
package org.sonar.core.computation.dbcleaner; | |||
import com.google.common.annotations.VisibleForTesting; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.api.resources.Qualifiers; | |||
import org.sonar.api.utils.TimeUtils; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.core.computation.dbcleaner.period.DefaultPeriodCleaner; | |||
import org.sonar.core.purge.*; | |||
import org.sonar.core.purge.IdUuidPair; | |||
import org.sonar.core.purge.PurgeConfiguration; | |||
import org.sonar.core.purge.PurgeDao; | |||
import org.sonar.core.purge.PurgeListener; | |||
import org.sonar.core.purge.PurgeProfiler; | |||
import org.sonar.core.resource.ResourceDao; | |||
import org.sonar.core.resource.ResourceDto; | |||
import org.sonar.plugins.dbcleaner.api.PurgeTask; | |||
@@ -39,7 +43,7 @@ import static org.sonar.core.purge.PurgeConfiguration.newDefaultPurgeConfigurati | |||
* @since 2.14 | |||
*/ | |||
public class DefaultPurgeTask implements PurgeTask { | |||
private static final Logger LOG = LoggerFactory.getLogger(DefaultPurgeTask.class); | |||
private static final Logger LOG = Loggers.get(DefaultPurgeTask.class); | |||
private final PurgeProfiler profiler; | |||
private final PurgeDao purgeDao; | |||
private final ResourceDao resourceDao; |
@@ -20,8 +20,8 @@ | |||
package org.sonar.core.purge; | |||
import com.google.common.annotations.VisibleForTesting; | |||
import org.slf4j.Logger; | |||
import org.sonar.api.utils.TimeUtils; | |||
import org.sonar.api.utils.log.Logger; | |||
import java.util.ArrayList; | |||
import java.util.Collections; |
@@ -20,7 +20,6 @@ | |||
package org.sonar.core.computation.dbcleaner; | |||
import ch.qos.logback.classic.Logger; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import org.mockito.ArgumentMatcher; | |||
@@ -29,8 +28,13 @@ import org.sonar.api.config.PropertyDefinitions; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.api.resources.Qualifiers; | |||
import org.sonar.api.resources.Scopes; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.core.computation.dbcleaner.period.DefaultPeriodCleaner; | |||
import org.sonar.core.purge.*; | |||
import org.sonar.core.purge.IdUuidPair; | |||
import org.sonar.core.purge.PurgeConfiguration; | |||
import org.sonar.core.purge.PurgeDao; | |||
import org.sonar.core.purge.PurgeListener; | |||
import org.sonar.core.purge.PurgeProfiler; | |||
import org.sonar.core.resource.ResourceDao; | |||
import org.sonar.core.resource.ResourceDto; | |||
@@ -21,7 +21,7 @@ package org.sonar.core.purge; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import org.slf4j.Logger; | |||
import org.sonar.api.utils.log.Logger; | |||
import static org.mockito.Matchers.contains; | |||
import static org.mockito.Mockito.mock; |