From d825f8703421eca5e22463c137f83884d8e7ad80 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Mon, 1 Oct 2012 13:51:49 +0200 Subject: [PATCH] Do not use deprecated Logs.INFO in startup tasks --- .../org/sonar/server/startup/RegisterNewDashboards.java | 8 +++++--- .../java/org/sonar/server/startup/RegisterNewFilters.java | 4 ++-- .../org/sonar/server/startup/RegisterNewProfiles.java | 5 +++-- .../org/sonar/server/startup/RegisterQualityModels.java | 6 ++++-- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewDashboards.java b/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewDashboards.java index ea1cd7f29df..ed5683cbe64 100644 --- a/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewDashboards.java +++ b/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewDashboards.java @@ -21,6 +21,7 @@ package org.sonar.server.startup; import com.google.common.collect.Lists; import com.google.common.collect.Ordering; +import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.utils.TimeProfiler; import org.sonar.api.web.Dashboard; @@ -38,6 +39,8 @@ import java.util.Map.Entry; * @since 2.13 */ public final class RegisterNewDashboards { + private static final Logger LOG = LoggerFactory.getLogger(RegisterNewDashboards.class); + static final String DEFAULT_DASHBOARD_NAME = "Dashboard"; private final List dashboardTemplates; @@ -54,7 +57,7 @@ public final class RegisterNewDashboards { } public void start() { - TimeProfiler profiler = new TimeProfiler().start("Register dashboards"); + TimeProfiler profiler = new TimeProfiler(LOG).start("Register dashboards"); List registeredDashboards = Lists.newArrayList(); for (DashboardTemplate template : dashboardTemplates) { @@ -81,12 +84,11 @@ public final class RegisterNewDashboards { } private void activate(DashboardDto dashboardDto, int index) { + LOG.info("Register dashboard: " + dashboardDto.getName()); ActiveDashboardDto activeDashboardDto = new ActiveDashboardDto() .setDashboardId(dashboardDto.getId()) .setOrderIndex(index); activeDashboardDao.insert(activeDashboardDto); - - LoggerFactory.getLogger(getClass()).info("New dashboard '" + dashboardDto.getName() + "' registered"); } protected DashboardDto register(String name, Dashboard dashboard) { diff --git a/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewFilters.java b/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewFilters.java index 1a9c7b1d233..864b3e01cc3 100644 --- a/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewFilters.java +++ b/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewFilters.java @@ -53,7 +53,7 @@ public final class RegisterNewFilters { } public void start() { - TimeProfiler profiler = new TimeProfiler(LoggerFactory.getLogger(getClass())).start("Register filters"); + TimeProfiler profiler = new TimeProfiler(LOG).start("Register filters"); for (FilterTemplate template : filterTemplates) { if (shouldRegister(template.getName())) { @@ -72,9 +72,9 @@ public final class RegisterNewFilters { protected FilterDto register(String name, Filter filter) { FilterDto dto = null; if (filterDao.findFilter(name) == null) { + LOG.info("Register filter: " + name); dto = createDtoFromExtension(name, filter); filterDao.insert(dto); - LOG.info("New filter '" + dto.getName() + "' registered"); } // and save the fact that is has now already been loaded loadedTemplateDao.insert(new LoadedTemplateDto(name, LoadedTemplateDto.FILTER_TYPE)); diff --git a/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewProfiles.java b/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewProfiles.java index 5c2f5a15480..8853c88f5b3 100644 --- a/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewProfiles.java +++ b/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewProfiles.java @@ -75,7 +75,7 @@ public class RegisterNewProfiles { } public void start() { - TimeProfiler profiler = new TimeProfiler().start("Register Quality Profiles"); + TimeProfiler profiler = new TimeProfiler(LOGGER).start("Register Quality Profiles"); session = sessionFactory.getSession(); ListMultimap profilesByLanguage = loadDefinitions(); for (String language : profilesByLanguage.keySet()) { @@ -99,7 +99,7 @@ public class RegisterNewProfiles { String propertyKey = "sonar.profile." + language; if (settings.getString(propertyKey) == null) { String defaultProfileName = defaultProfileName(profiles); - LOGGER.info("Set default profile for " + language + ": " + defaultProfileName); + LOGGER.info("Set default " + language + " profile: " + defaultProfileName); settings.saveProperty(propertyKey, defaultProfileName); } } @@ -122,6 +122,7 @@ public class RegisterNewProfiles { } private void register(String language, String name, Collection profiles) { + LOGGER.info("Register " + language + " profile: " + name); clean(language, name); insert(language, name, profiles); loadedTemplateDao.insert(new LoadedTemplateDto(templateKey(language, name), LoadedTemplateDto.QUALITY_PROFILE_TYPE)); diff --git a/sonar-server/src/main/java/org/sonar/server/startup/RegisterQualityModels.java b/sonar-server/src/main/java/org/sonar/server/startup/RegisterQualityModels.java index 8cd11babaf1..5f76dbd9840 100644 --- a/sonar-server/src/main/java/org/sonar/server/startup/RegisterQualityModels.java +++ b/sonar-server/src/main/java/org/sonar/server/startup/RegisterQualityModels.java @@ -19,11 +19,13 @@ */ package org.sonar.server.startup; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.sonar.api.utils.TimeProfiler; import org.sonar.server.qualitymodel.ModelManager; public final class RegisterQualityModels { - + private static final Logger LOG = LoggerFactory.getLogger(RegisterQualityModels.class); private final ModelManager manager; /** @@ -34,7 +36,7 @@ public final class RegisterQualityModels { } public void start() { - TimeProfiler profiler = new TimeProfiler().start("Register quality models"); + TimeProfiler profiler = new TimeProfiler(LOG).start("Register Quality Models"); manager.registerDefinitions(); profiler.stop(); } -- 2.39.5