]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Some log fine-tuning.
authorJeremias Maerki <jeremias@apache.org>
Fri, 26 Oct 2007 07:34:09 +0000 (07:34 +0000)
committerJeremias Maerki <jeremias@apache.org>
Fri, 26 Oct 2007 07:34:09 +0000 (07:34 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@588546 13f79535-47bb-0310-9956-ffa450edef68

test/java/org/apache/fop/visual/BatchDiffer.java

index b42e440d75db2fccb9bd40be70484aaf023f7f36..aa3f5504ff73df7c33c42556120a7ae88f35ab81 100644 (file)
@@ -35,19 +35,15 @@ import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
 import org.apache.avalon.framework.container.ContainerUtil;
-
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.filefilter.IOFileFilter;
 import org.apache.commons.io.filefilter.SuffixFileFilter;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
 import org.apache.fop.layoutengine.LayoutEngineTestSuite;
 import org.apache.xmlgraphics.image.writer.ImageWriter;
 import org.apache.xmlgraphics.image.writer.ImageWriterRegistry;
-
 import org.xml.sax.SAXException;
 
 /**
@@ -192,8 +188,8 @@ public class BatchDiffer {
             Collection files = FileUtils.listFiles(srcDir, filter, null);
             Iterator i = files.iterator();
             while (i.hasNext()) {
+                File f = (File)i.next();
                 try {
-                    File f = (File)i.next();
                     log.info("---=== " + f + " ===---");
                     long[] times = new long[producers.length];
                     for (int j = 0; j < producers.length; j++) {
@@ -201,18 +197,20 @@ public class BatchDiffer {
                         bitmaps[j] = producers[j].produce(f, context);
                         times[j] = System.currentTimeMillis() - times[j];
                     }
-                    StringBuffer sb = new StringBuffer("Bitmap production times: ");
-                    for (int j = 0; j < producers.length; j++) {
-                        if (j > 0) {
-                            sb.append(", ");
+                    if (log.isDebugEnabled()) {
+                        StringBuffer sb = new StringBuffer("Bitmap production times: ");
+                        for (int j = 0; j < producers.length; j++) {
+                            if (j > 0) {
+                                sb.append(", ");
+                            }
+                            sb.append(times[j]).append("ms");
                         }
-                        sb.append(times[j]).append("ms");
+                        log.debug(sb.toString());
                     }
-                    log.info(sb.toString());
                     //Create combined image
                     if (bitmaps[0] == null) {
-                        throw new RuntimeException("First producer didn't return a bitmap."
-                                + " Cannot continue.");
+                        throw new RuntimeException("First producer didn't return a bitmap for " 
+                                + f + ". Cannot continue.");
                     }
                     BufferedImage combined = BitmapComparator.buildCompareImage(bitmaps);
                     
@@ -233,9 +231,9 @@ public class BatchDiffer {
                         bitmaps[k] = null;
                     }
                 } catch (RuntimeException e) {
-                    System.out.println("Catching RE: " + e.getMessage());
+                    log.error("Catching RE on file " + f + ": " + e.getMessage());
                     if (stopOnException) {
-                        System.out.println("rethrowing...");
+                        log.error("rethrowing...");
                         throw e;
                     }
                 }