Skip to content

Commit 0cee5e7

Browse files
committed
Small logging improvements
1 parent 156ec30 commit 0cee5e7

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/ReviewCodeCmd.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import java.util.ArrayList;
4040
import java.util.Collection;
4141
import java.util.HashMap;
42+
import java.util.HashSet;
4243
import java.util.Iterator;
4344
import java.util.List;
4445
import java.util.Map;
@@ -96,7 +97,7 @@ public class ReviewCodeCmd extends AbstractDefaultCommand {
9697

9798
private static final Logger LOG = Logger.getLogger(ReviewCodeCmd.class);
9899

99-
private final List<ISchedulingRule> resources = new ArrayList<ISchedulingRule>();
100+
private final List<IResource> resources = new ArrayList<IResource>();
100101
private IResourceDelta resourceDelta;
101102
private Map<IFile, Set<MarkerInfo2>> markersByFile = new HashMap<IFile, Set<MarkerInfo2>>();
102103
private boolean taskMarker;
@@ -277,12 +278,12 @@ public void run() {
277278

278279
// Log performance information
279280
if (fileCount > 0 && ruleCount > 0) {
280-
logInfo("Review code command terminated. " + ruleCount + " rules were executed against " + fileCount
281+
logInfo("Review code command finished. " + ruleCount + " rules were executed against " + fileCount
281282
+ " files. Actual PMD duration is about " + pmdDuration + "ms, that is about "
282283
+ (float) pmdDuration / fileCount + " ms/file, " + (float) pmdDuration / ruleCount
283284
+ " ms/rule, " + (float) pmdDuration / ((long) fileCount * (long) ruleCount) + " ms/filerule");
284285
} else {
285-
logInfo("Review code command terminated. " + ruleCount + " rules were executed against " + fileCount
286+
logInfo("Review code command finished. " + ruleCount + " rules were executed against " + fileCount
286287
+ " files. PMD was not executed.");
287288
}
288289
}
@@ -420,10 +421,13 @@ private ISchedulingRule getSchedulingRule() {
420421
* @throws CommandException
421422
*/
422423
private void processResources() throws CommandException {
423-
final Iterator<ISchedulingRule> i = resources.iterator();
424-
while (i.hasNext()) {
425-
final IResource resource = (IResource) i.next();
424+
Set<String> projects = new HashSet<String>();
425+
for (IResource resource : resources) {
426+
projects.add(resource.getProject().getName());
427+
}
428+
logInfo("ReviewCodeCmd started with " + resources.size() + " selected resources on projects " + projects);
426429

430+
for (IResource resource : resources) {
427431
// if resource is a project, visit only its source folders
428432
if (resource instanceof IProject) {
429433
processProject((IProject) resource);
@@ -508,7 +512,8 @@ private void processResource(IResource resource) throws CommandException {
508512
private void processProject(IProject project) throws CommandException {
509513
try {
510514
setStepCount(countResourceElement(project));
511-
LOG.debug("Visiting project " + project.getName() + " : " + getStepCount());
515+
logInfo("ReviewCodeCmd: visiting project " + project.getName() + ": " + getStepCount() + " resources found.");
516+
LOG.debug("Visiting project " + project.getName() + " : " + getStepCount() + " resources found.");
512517

513518
if (project.hasNature(JavaCore.NATURE_ID)) {
514519
processJavaProject(project);
@@ -609,6 +614,7 @@ private void processResourceDelta() throws CommandException {
609614
IResource resource = resourceDelta.getResource();
610615
final IProject project = resource.getProject();
611616
final IProjectProperties properties = getProjectProperties(project);
617+
logInfo("ReviewCodeCmd started on resource delta " + resource.getName() + " in project " + project.getName());
612618

613619
RuleSet ruleSet = rulesetFromResourceDelta(); // properties.getProjectRuleSet();
614620

@@ -680,7 +686,7 @@ private void applyMarkers() {
680686
} finally {
681687
timer.stop();
682688
int count = markersByFile.size();
683-
logInfo("" + violationCount + " markers applied on " + count + " files in " + timer.getDuration() + "ms.");
689+
LOG.info("" + violationCount + " markers applied on " + count + " files in " + timer.getDuration() + "ms.");
684690
LOG.info("End of processing marker directives. " + violationCount + " violations for " + count + " files.");
685691
}
686692
}

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/properties/impl/ProjectPropertiesImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ public ClassLoader getAuxClasspath() {
462462
try {
463463
if (project != null && project.hasNature(JavaCore.NATURE_ID)) {
464464
if (auxclasspath == null) {
465-
LOG.debug("Creating new auxclaspath class loader for project " + project.getName());
465+
PMDPlugin.getDefault().logInformation("Creating new auxclasspath class loader for project " + project.getName());
466466
auxclasspath = new JavaProjectClassLoader(PMD.class.getClassLoader(), project);
467467
}
468468
return auxclasspath;

0 commit comments

Comments
 (0)