You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2021/11/10 18:20:38 UTC

svn commit: r1894924 - /pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java

Author: tilman
Date: Wed Nov 10 18:20:38 2021
New Revision: 1894924

URL: http://svn.apache.org/viewvc?rev=1894924&view=rev
Log:
PDFBOX-2941: improve logging, log printing duration

Modified:
    pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java

Modified: pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java?rev=1894924&r1=1894923&r2=1894924&view=diff
==============================================================================
--- pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java (original)
+++ pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java Wed Nov 10 18:20:38 2021
@@ -45,6 +45,7 @@ import java.util.List;
 import java.util.Properties;
 import java.util.Set;
 import java.util.concurrent.Callable;
+import java.util.concurrent.TimeUnit;
 
 import javax.imageio.spi.IIORegistry;
 
@@ -70,6 +71,8 @@ import javax.swing.border.BevelBorder;
 import javax.swing.event.TreeSelectionEvent;
 import javax.swing.filechooser.FileFilter;
 import javax.swing.tree.TreePath;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import org.apache.pdfbox.Loader;
 import org.apache.pdfbox.cos.COSArray;
@@ -146,6 +149,8 @@ import picocli.CommandLine.Model.Command
 @Command(name = "pdfdebugger", description = "Analyzes and inspects the internal structure of a PDF document")
 public class PDFDebugger extends JFrame implements Callable<Integer>
 {
+    private static Log LOG; // needs late initialization
+
     private static final Set<COSName> SPECIALCOLORSPACES = new HashSet<>(
             Arrays.asList(COSName.INDEXED, COSName.SEPARATION, COSName.DEVICEN));
 
@@ -257,11 +262,12 @@ public class PDFDebugger extends JFrame
             initComponents();
 
             // use our custom logger
-            // this works only if there is no "LogFactory.getLog()" in this class,
+            // this works only if there is no earlier "LogFactory.getLog()" in this class,
             // and if there are no methods that call logging, even invisible
             // use reduced file from PDFBOX-3653 to see logging
             LogDialog.init(this,statusBar.getLogLabel());
             System.setProperty("org.apache.commons.logging.Log", "org.apache.pdfbox.debugger.ui.DebugLog");
+            LOG = LogFactory.getLog(PDFDebugger.class);
 
             TextDialog.init(this);
 
@@ -1227,7 +1233,11 @@ public class PDFDebugger extends JFrame
                 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                 try
                 {
+                    long t0 = System.nanoTime();
                     job.print(pras);
+                    long t1 = System.nanoTime();
+                    long ms = TimeUnit.MILLISECONDS.convert(t1 - t0, TimeUnit.NANOSECONDS);
+                    LOG.info("Printed in " + ms + " ms");
                 }
                 finally
                 {