From f4322ee342723d15173b31ff6eb59199cf3f4a37 Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Mon, 10 Jan 2011 16:15:10 +0100 Subject: [PATCH] do not log timemachine messages 'Compare to ...' on views --- .../components/TimeMachineConfiguration.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/sonar-batch/src/main/java/org/sonar/batch/components/TimeMachineConfiguration.java b/sonar-batch/src/main/java/org/sonar/batch/components/TimeMachineConfiguration.java index 0274fb22637..136ac380cd7 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/components/TimeMachineConfiguration.java +++ b/sonar-batch/src/main/java/org/sonar/batch/components/TimeMachineConfiguration.java @@ -21,9 +21,14 @@ package org.sonar.batch.components; import com.google.common.collect.Lists; import org.apache.commons.configuration.Configuration; +import org.apache.commons.lang.StringUtils; +import org.slf4j.LoggerFactory; import org.sonar.api.BatchExtension; import org.sonar.api.CoreProperties; +import org.sonar.api.database.model.ResourceModel; import org.sonar.api.database.model.Snapshot; +import org.sonar.api.resources.Resource; +import org.sonar.api.resources.ResourceUtils; import org.sonar.api.utils.Logs; import java.util.Collections; @@ -46,12 +51,22 @@ public class TimeMachineConfiguration implements BatchExtension { for (int index = 1; index <= NUMBER_OF_VARIATION_SNAPSHOTS; index++) { PastSnapshot pastSnapshot = pastSnapshotFinder.find(projectSnapshot, configuration, index); if (pastSnapshot != null) { - Logs.INFO.info(pastSnapshot.toString()); + log(pastSnapshot); projectPastSnapshots.add(pastSnapshot); } } } + private void log(PastSnapshot pastSnapshot) { + String qualifier = pastSnapshot.getProjectSnapshot().getQualifier(); + // hack to avoid too many logs when the views plugin is installed + if (StringUtils.equals(Resource.QUALIFIER_VIEW, qualifier) || StringUtils.equals(Resource.QUALIFIER_SUBVIEW, qualifier)) { + LoggerFactory.getLogger(getClass()).debug(pastSnapshot.toString()); + } else { + Logs.INFO.info(pastSnapshot.toString()); + } + } + public TimeMachineConfiguration(Configuration configuration) { this.configuration = configuration; this.projectPastSnapshots = Collections.emptyList(); -- 2.39.5