]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
1.) Removed the get/setLogger methods from Driver, obsolete with Commons-Logging.
authorGlen Mazza <gmazza@apache.org>
Sun, 20 Jun 2004 12:35:17 +0000 (12:35 +0000)
committerGlen Mazza <gmazza@apache.org>
Sun, 20 Jun 2004 12:35:17 +0000 (12:35 +0000)
2.) Updated examples and documentation.
3.) Added a -v option to show version of FOP being used.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197740 13f79535-47bb-0310-9956-ffa450edef68

12 files changed:
examples/embedding/java/embedding/ExampleDOM2PDF.java
examples/embedding/java/embedding/ExampleFO2PDF.java
examples/embedding/java/embedding/ExampleObj2PDF.java
examples/embedding/java/embedding/ExampleXML2PDF.java
src/documentation/content/xdocs/embedding.xml
src/java/org/apache/fop/apps/CommandLineOptions.java
src/java/org/apache/fop/apps/Driver.java
src/java/org/apache/fop/apps/Fop.java
src/java/org/apache/fop/render/AbstractRenderer.java
src/java/org/apache/fop/servlet/FopPrintServlet.java
src/java/org/apache/fop/servlet/FopServlet.java
src/java/org/apache/fop/tools/anttasks/Fop.java

index ab02e6607d02b990a2753ac6b0c0d9ea32775e31..5531cc2520119d699d5626b69f6212e014ffb85a 100644 (file)
  
 package embedding;
 
-//Java
+// Java
 import java.io.File;
 import java.io.IOException;
 import java.io.OutputStream;
-
-//JAXP
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.DocumentBuilder;
 
@@ -33,10 +31,7 @@ import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.Text;
 
-// Commons-Logging
-import org.apache.commons.logging.impl.SimpleLog;
-
-//FOP
+// FOP
 import org.apache.fop.apps.Driver;
 import org.apache.fop.apps.FOPException;
 
@@ -61,10 +56,7 @@ public class ExampleDOM2PDF {
         // Construct driver
         Driver driver = new Driver();
         
-        // Setup logger
-        SimpleLog logger = new SimpleLog("log");
-        logger.setLevel(SimpleLog.LOG_LEVEL_INFO);
-        driver.setLogger(logger);
+        // Setup driver
         driver.initialize();
         
         // Setup Renderer (output format)        
index be8cd78228bc2644a923f9c6f81f7cb7a384a8d7..6d7a7c564315364b9c0be18678e01f1608a8122a 100644 (file)
  
 package embedding;
 
-//Java
+// Java
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 
-//SAX
+// SAX
 import org.xml.sax.InputSource;
 
-// Commons-Logging
-import org.apache.commons.logging.impl.SimpleLog;
-
-//FOP
+// FOP
 import org.apache.fop.apps.Driver;
 import org.apache.fop.apps.FOPException;
 
@@ -51,10 +48,7 @@ public class ExampleFO2PDF {
         // Construct driver
         Driver driver = new Driver();
         
-        // Setup logger
-        SimpleLog logger = new SimpleLog("log");
-        logger.setLevel(SimpleLog.LOG_LEVEL_INFO);
-        driver.setLogger(logger);
+        // Setup driver
         driver.initialize();
 
         // Setup Renderer (output format)        
index 313faee4376444399c13cd2b2d8985f93751f879..ff2419ff39048175e0999f1c2332b33cd629877a 100644 (file)
  
 package embedding;
 
-//Java
+// Java
 import java.io.File;
 import java.io.OutputStream;
 import java.io.IOException;
 
-//JAXP
+// JAXP
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.TransformerException;
@@ -32,13 +32,9 @@ import javax.xml.transform.Result;
 import javax.xml.transform.stream.StreamSource;
 import javax.xml.transform.sax.SAXResult;
 
-// Commons-Logging
-import org.apache.commons.logging.impl.SimpleLog;
-
-//FOP
+// FOP
 import org.apache.fop.apps.Driver;
 import org.apache.fop.apps.FOPException;
-
 import embedding.model.ProjectTeam;
 
 /**
@@ -62,10 +58,7 @@ public class ExampleObj2PDF {
         // Construct driver
         Driver driver = new Driver();
         
-        // Setup logger
-        SimpleLog logger = new SimpleLog("log");
-        logger.setLevel(SimpleLog.LOG_LEVEL_INFO);
-        driver.setLogger(logger);
+        // Setup driver
         driver.initialize();
 
         // Setup Renderer (output format)        
index 60cdd12ef269579b87e8a4002497ae25e9b3ba79..bb16b6528bdd86da6355a7413454b3d9f4dd2b83 100644 (file)
@@ -32,9 +32,6 @@ import javax.xml.transform.Result;
 import javax.xml.transform.stream.StreamSource;
 import javax.xml.transform.sax.SAXResult;
 
-// Commons-Logging
-import org.apache.commons.logging.impl.SimpleLog;
-
 //FOP
 import org.apache.fop.apps.Driver;
 import org.apache.fop.apps.FOPException;
@@ -74,9 +71,6 @@ public class ExampleXML2PDF {
             Driver driver = new Driver();
             
             // Setup logger
-            SimpleLog logger = new SimpleLog("log");
-            logger.setLevel(SimpleLog.LOG_LEVEL_INFO);
-            driver.setLogger(logger);
             driver.initialize();
     
             // Setup Renderer (output format)        
index ac707fa732d0623dd388eb7d17f9005d3e32f3c6..3c729558ac277dbe154ab4358f456d8ba4bf39ca 100644 (file)
@@ -93,26 +93,13 @@ driver.setLogger(logger);]]></source>
   <section id="basic-logging-new-version">
     <title>Logging (Upcoming FOP 1.0 Version only)</title>
     <p>
-      You also need to set up logging. Global logging for all FOP
-      processes is managed by MessageHandler. Per-instance logging
-      is handled by Driver. You want to set both using an implementation
-      of org.apache.commons.logging.Log. See 
-      <jump href="#logging">below</jump> for more information.
-    </p>
-    <p>
-      Call <code>setLogger(Logger)</code> always immediately after 
-      instantiating the Driver object. See here:
+      Logging is handled automatically via Jakarta Commons-Logging, which uses
+      JDK logging by default.  No special driver configuration is needed.
+      For specialized configuration of Commons-Logging (e.g. to use a
+      different logger or to change logging levels), please see the  
+      <fork href="http://jakarta.apache.org/commons/logging/">Jakarta Commons-Logging</fork>
+      site.
     </p>
-    <source><![CDATA[
-import org.apache.commons.logging.Log; 
-import org.apache.commons.logging.impl.SimpleLog; 
-
-/*..*/
-
-Driver driver = new Driver();
-Log logger = new SimpleLog(SimpleLog.LOG_LEVEL_INFO);
-MessageHandler.setScreenLogger(logger);
-driver.setLogger(logger);]]></source>
   </section>
 
   <section id="render">
index 930a557a1d180118f44f5da5418c4b902f3d6f3b..b6116c7bc60e487e3dd3d6d2f914ac729e5c7fe3 100644 (file)
@@ -174,6 +174,8 @@ public class CommandLineOptions {
                 i = i + parseUnknownOption(args, i);
             } else if (args[i].equals("-at")) {
                 i = i + parseAreaTreeOption(args, i);
+            } else if (args[i].equals("-v")) {
+                System.out.println("FOP Version " + Version.getVersion());
             } else if (args[i].equals("-param")) {
                   if (i + 2 < args.length) {
                       if (xsltParams == null) {
@@ -575,7 +577,8 @@ public class CommandLineOptions {
             + "  -x          dump configuration settings  \n"
             + "  -c cfg.xml  use additional configuration file cfg.xml\n"
             + "  -l lang     the language to use for user information \n"
-            + "  -s          for area tree XML, down to block areas only\n\n"
+            + "  -s          for area tree XML, down to block areas only\n"
+            + "  -v          to show FOP version being used\n\n"
             + " [INPUT]  \n"
             + "  infile            xsl:fo input file (the same as the next) \n"
             + "  -fo  infile       xsl:fo input file  \n"
@@ -608,14 +611,13 @@ public class CommandLineOptions {
     /**
      * shows the options for print output
      */
-    public void printUsagePrintOutput() {
+    private void printUsagePrintOutput() {
         System.err.println("USAGE: -print [-Dstart=i] [-Dend=i] [-Dcopies=i] [-Deven=true|false] "
                            + " org.apache.fop.apps.Fop (..) -print \n"
                            + "Example:\n"
                            + "java -Dstart=1 -Dend=2 org.apache.Fop.apps.Fop infile.fo -print ");
     }
 
-
     /**
      * Outputs all commandline settings
      */
index cf4395a948b6a6faf5b03e35c4de5d8e43932c21..edf138ee61a0645e54b425e0789221a56c02528a 100644 (file)
 
 package org.apache.fop.apps;
 
+// Java
+import java.io.IOException;
+import java.io.OutputStream;
+
+// XML
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.w3c.dom.Document;
+
 // FOP
 import org.apache.fop.fo.ElementMapping;
 import org.apache.fop.fo.FOTreeBuilder;
-
 import org.apache.fop.fo.FOInputHandler;
 import org.apache.fop.fo.FOTreeHandler;
 import org.apache.fop.render.Renderer;
@@ -31,20 +41,6 @@ import org.apache.fop.render.rtf.RTFHandler;
 import org.apache.fop.tools.DocumentInputSource;
 import org.apache.fop.tools.DocumentReader;
 
-import org.apache.commons.logging.impl.SimpleLog;
-import org.apache.commons.logging.Log;
-
-// XML
-import org.xml.sax.ContentHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.w3c.dom.Document;
-
-// Java
-import java.io.IOException;
-import java.io.OutputStream;
-
 /**
  * Primary class that drives overall FOP process.
  * <P>
@@ -57,7 +53,6 @@ import java.io.OutputStream;
  * <PRE>
  * Driver driver = new Driver(new InputSource (args[0]),
  * new FileOutputStream(args[1]));
- * driver.setLogger(myLogger); //optional
  * driver.setRenderer(RENDER_PDF);
  * driver.run();
  * </PRE>
@@ -87,7 +82,6 @@ import java.io.OutputStream;
  *
  * <PRE>
  * Driver driver = new Driver();
- * driver.setLogger(myLogger); //optional
  * driver.setRenderer(new org.apache.fop.render.awt.AWTRenderer(translator));
  * driver.render(parser, fileInputSource(args[0]));
  * </PRE>
@@ -185,9 +179,8 @@ public class Driver {
     private XMLReader reader;
 
     /**
-     * the system resources that FOP will use
+     * The system resources that FOP will use
      */
-    private Log log = null;
     private FOUserAgent userAgent = null;
 
     /**
@@ -238,33 +231,6 @@ public class Driver {
         return userAgent;
     }
 
-    /**
-     * Provide the Driver instance with a logger.
-     * @param log the logger. Must not be <code>null</code>.
-     */
-    public void setLogger(Log log) {
-        if (this.log == null) {
-            this.log = log;
-        } else {
-            getLogger().warn("Logger is already set! Won't use the new logger.");
-        }
-    }
-
-
-    /**
-     * Returns the logger for use by FOP.
-     * @return the logger
-     */
-    public Log getLogger() {
-        if (this.log == null) {
-            // use SimpleLog as default when logger not explicitly set
-            log = new SimpleLog("FOP");
-            ((SimpleLog) log).setLevel(SimpleLog.LOG_LEVEL_INFO);
-        }
-
-        return this.log;
-    }
-
     /**
      * Resets the Driver so it can be reused. Property and element
      * mappings are reset to defaults.
@@ -377,7 +343,7 @@ public class Driver {
 
     /**
      * Set the Renderer to use.
-     * @param renderer the renderer instance to use (Note: Logger must be set at this point)
+     * @param renderer the renderer instance to use
      */
     public void setRenderer(Renderer renderer) {
         // AWTStarter calls this function directly
@@ -584,5 +550,4 @@ public class Driver {
             render(reader, source);
         }
     }
-
 }
index 39d1d6c9ccc0112602dd40915882d5b45a5b9877..362739c224be9e4dbc8ba0a3867df36de62e7801 100644 (file)
@@ -22,8 +22,6 @@ package org.apache.fop.apps;
 import java.io.BufferedOutputStream;
 import java.io.FileOutputStream;
 
-import org.apache.commons.logging.impl.SimpleLog;
-
 // FOP
 import org.apache.fop.render.awt.AWTRenderer;
 
@@ -47,9 +45,6 @@ public class Fop {
             Driver driver = new Driver();
             options = new CommandLineOptions(args);
 
-            driver.setLogger(options.getLogger());
-            driver.getLogger().info(version);
-
             inputHandler = options.getInputHandler();
 
             try {
index 53a6f3b0a9e227ae6a90fd60bc5f0f5b9b2c1339..96c10d0ac8fd9b51d5c73d64107b337002d0e41a 100644 (file)
@@ -87,7 +87,7 @@ public abstract class AbstractRenderer
     /**
      * logging instance
      */
-    protected static Log logger = LogFactory.getLog("Renderer");
+    protected static Log logger = LogFactory.getLog("FOP");
     
     /**
      * producer (usually "FOP")
index 0320a706ee1eac09200a454e507295b1f496834a..f873812aa3e34fdaf24268e1306a7f2ca6d4e7ed 100644 (file)
@@ -134,7 +134,6 @@ public class FopPrintServlet extends HttpServlet {
             Driver driver = new Driver(foFile, null);
             AWTPrintRenderer renderer = new AWTPrintRenderer();
 
-            driver.setLogger(log);
             driver.setRenderer(renderer);
             driver.run();
 
@@ -156,7 +155,6 @@ public class FopPrintServlet extends HttpServlet {
             Driver driver = new Driver();
             AWTPrintRenderer renderer = new AWTPrintRenderer();
 
-            driver.setLogger(log);
             driver.setRenderer(renderer);
             driver.render(input.getParser(), input.getInputSource());
 
index 497d4b64f6ff568c174233465b993c6386c77c09..566b17f4cd8e88366d9fffd527f277f73984d7a4 100644 (file)
@@ -202,7 +202,6 @@ public class FopServlet extends HttpServlet {
 
         //Setup FOP
         Driver driver = new Driver();
-        driver.setLogger(this.log);
         driver.setRenderer(Driver.RENDER_PDF);
         driver.initialize();
 
index d82b922edb126763e172576f04ffe2aa9b80f357..6093c9fd193d7edb960dc7642f831e04037c1d45 100644 (file)
@@ -532,7 +532,6 @@ class FOPTaskStarter {
 
         try {
             Driver driver = new Driver();
-            driver.setLogger(getLogger());
             FOUserAgent userAgent = new FOUserAgent();
             userAgent.setBaseURL(this.baseURL);
             driver.setUserAgent(userAgent);