]> source.dussan.org Git - sonarqube.git/commitdiff
Adding trace log on visitors and measure computers
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 26 Aug 2015 14:42:34 +0000 (16:42 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 31 Aug 2015 07:49:15 +0000 (09:49 +0200)
server/sonar-server/src/main/java/org/sonar/server/computation/component/ComponentImpl.java
server/sonar-server/src/main/java/org/sonar/server/computation/component/FileAttributes.java
server/sonar-server/src/main/java/org/sonar/server/computation/component/PathAwareVisitorWrapper.java
server/sonar-server/src/main/java/org/sonar/server/computation/component/ReportAttributes.java
server/sonar-server/src/main/java/org/sonar/server/computation/component/TypeAwareVisitorWrapper.java
server/sonar-server/src/main/java/org/sonar/server/computation/component/VisitorsCrawler.java
server/sonar-server/src/main/java/org/sonar/server/computation/measure/MeasureComputersVisitor.java

index d1b3e9b4bfd16ddce093544c7454ca097fe82f40..a20aa98e752a637095807470ca1b3b783de362be 100644 (file)
@@ -139,4 +139,16 @@ public class ComponentImpl implements Component {
   public ProjectViewAttributes getProjectViewAttributes() {
     throw new IllegalStateException("Only component of type PROJECT_VIEW have a FileAttributes object");
   }
+
+  @Override
+  public String toString() {
+    return "ComponentImpl{" +
+      "key='" + key + '\'' +
+      ", type=" + type +
+      ", uuid='" + uuid + '\'' +
+      ", fileAttributes=" + fileAttributes +
+      ", name='" + name + '\'' +
+      ", reportAttributes=" + reportAttributes +
+      '}';
+  }
 }
index f7fdfb4eac33b5d6cf6423f6a5ccd6ffa737d9a7..bbcf22e0c0815df1deceef290d6f3ebd9f8f9319 100644 (file)
@@ -44,4 +44,12 @@ public class FileAttributes {
   public String getLanguageKey() {
     return languageKey;
   }
+
+  @Override
+  public String toString() {
+    return "FileAttributes{" +
+      "languageKey='" + languageKey + '\'' +
+      ", unitTest=" + unitTest +
+      '}';
+  }
 }
index 560868b84a839ae779468a0abb95b85c112fdf4f..acd5bd91122448b2189a91102f143ad43e7a1a40 100644 (file)
@@ -105,4 +105,8 @@ public class PathAwareVisitorWrapper<T> implements VisitorWrapper {
     }
   }
 
+  @Override
+  public String toString() {
+    return delegate.toString();
+  }
 }
index 53c32ca3773a6b9c3fc7c3b8979c950b69425772..22ffb0b0002ac0c35e70663402020042767bff90 100644 (file)
@@ -23,8 +23,6 @@ import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 import javax.annotation.concurrent.Immutable;
 
-import static java.util.Objects.requireNonNull;
-
 @Immutable
 public class ReportAttributes {
   private final int ref;
@@ -50,4 +48,11 @@ public class ReportAttributes {
     return this.version;
   }
 
+  @Override
+  public String toString() {
+    return "ReportAttributes{" +
+      "ref=" + ref +
+      ", version='" + version + '\'' +
+      '}';
+  }
 }
index 182cb4aa612aacd7277b2511039118892af5f9bf..fc04c6e1fa41dcc5161efc469f2a70fc18768995 100644 (file)
@@ -88,4 +88,8 @@ public class TypeAwareVisitorWrapper implements VisitorWrapper {
     return delegate.getMaxDepth();
   }
 
+  @Override
+  public String toString() {
+    return delegate.toString();
+  }
 }
index 6333fcf4a6fa8bdb8096e2d8d3583139d44ee974..ea5e20ee9a218a3d35143c33baf9bbdaa62169df 100644 (file)
@@ -26,6 +26,8 @@ import com.google.common.collect.ImmutableMap;
 import java.util.List;
 import java.util.Map;
 import javax.annotation.Nonnull;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
 
 import static com.google.common.collect.FluentIterable.from;
 import static com.google.common.collect.Iterables.concat;
@@ -36,6 +38,8 @@ import static java.util.Objects.requireNonNull;
  */
 public class VisitorsCrawler implements ComponentCrawler {
 
+  private static final Logger LOGGER = Loggers.get(VisitorsCrawler.class);
+
   private final List<VisitorWrapper> preOrderVisitorWrappers;
   private final List<VisitorWrapper> postOrderVisitorWrappers;
 
@@ -80,6 +84,7 @@ public class VisitorsCrawler implements ComponentCrawler {
   }
 
   private void visitNode(Component component, VisitorWrapper visitor) {
+    LOGGER.trace("Visitor '{}' is currently visiting component {}", visitor, component);
     visitor.visitAny(component);
     switch (component.getType()) {
       case PROJECT:
index 43ad33fdf0542935c2074ebe1dceb4e166b68b47..8998020f1115cddf7cf7fa1304ec13e9da38ddf5 100644 (file)
@@ -21,6 +21,8 @@
 package org.sonar.server.computation.measure;
 
 import org.sonar.api.ce.measure.MeasureComputer;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
 import org.sonar.server.computation.component.CrawlerDepthLimit;
 import org.sonar.server.computation.component.SettingsRepository;
 import org.sonar.server.computation.component.TypeAwareVisitorAdapter;
@@ -28,10 +30,12 @@ import org.sonar.server.computation.issue.ComponentIssuesRepository;
 import org.sonar.server.computation.measure.api.MeasureComputerImplementationContext;
 import org.sonar.server.computation.metric.MetricRepository;
 
-import static org.sonar.server.computation.component.ComponentVisitor.Order.PRE_ORDER;
+import static org.sonar.server.computation.component.ComponentVisitor.Order.POST_ORDER;
 
 public class MeasureComputersVisitor extends TypeAwareVisitorAdapter {
 
+  private static final Logger LOGGER = Loggers.get(MeasureComputersVisitor.class);
+
   private final MetricRepository metricRepository;
   private final MeasureRepository measureRepository;
   private final SettingsRepository settings;
@@ -41,7 +45,7 @@ public class MeasureComputersVisitor extends TypeAwareVisitorAdapter {
 
   public MeasureComputersVisitor(MetricRepository metricRepository, MeasureRepository measureRepository, SettingsRepository settings,
     MeasureComputersHolder measureComputersHolder, ComponentIssuesRepository componentIssuesRepository) {
-    super(CrawlerDepthLimit.FILE, PRE_ORDER);
+    super(CrawlerDepthLimit.FILE, POST_ORDER);
     this.metricRepository = metricRepository;
     this.measureRepository = measureRepository;
     this.settings = settings;
@@ -52,6 +56,7 @@ public class MeasureComputersVisitor extends TypeAwareVisitorAdapter {
   @Override
   public void visitAny(org.sonar.server.computation.component.Component component) {
     for (MeasureComputer computer : measureComputersHolder.getMeasureComputers()) {
+      LOGGER.trace("Measure computer '{}' is computing component {}", computer.getImplementation(), component);
       MeasureComputerImplementationContext measureComputerContext = new MeasureComputerImplementationContext(component, computer,
         settings, measureRepository, metricRepository, componentIssuesRepository);
       computer.getImplementation().compute(measureComputerContext);