You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by vh...@apache.org on 2013/07/30 22:10:35 UTC

svn commit: r1508599 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop: cli/CommandLineOptions.java fonts/apps/AbstractFontReader.java fonts/apps/PFMReader.java fonts/apps/TTFReader.java util/CommandLineLogger.java

Author: vhennebert
Date: Tue Jul 30 20:10:35 2013
New Revision: 1508599

URL: http://svn.apache.org/r1508599
Log:
Removed obsolete CommandLineLogger.
The Jdk14Logger is guaranteed to be there by default now that the minimal Java requirement is 1.5.
Also, CommandLineLogger messes up the output when rendering to stdout.

Removed:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/util/CommandLineLogger.java
Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/apps/AbstractFontReader.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/apps/PFMReader.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/apps/TTFReader.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java?rev=1508599&r1=1508598&r2=1508599&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java Tue Jul 30 20:10:35 2013
@@ -58,7 +58,6 @@ import org.apache.fop.render.pdf.PDFEncr
 import org.apache.fop.render.print.PagesMode;
 import org.apache.fop.render.print.PrintRenderer;
 import org.apache.fop.render.xml.XMLRenderer;
-import org.apache.fop.util.CommandLineLogger;
 
 /**
  * Options parses the commandline arguments
@@ -146,15 +145,6 @@ public class CommandLineOptions {
      */
     public CommandLineOptions() {
         LogFactory logFactory = LogFactory.getFactory();
-
-        // Enable the simple command line logging when no other logger is
-        // defined.
-        if (System.getProperty("org.apache.commons.logging.Log") == null) {
-            logFactory.setAttribute("org.apache.commons.logging.Log",
-                                            CommandLineLogger.class.getName());
-            setLogLevel("info");
-        }
-
         log = LogFactory.getLog("FOP");
     }
 
@@ -292,7 +282,7 @@ public class CommandLineOptions {
             } else if (args[i].equals("-s")) {
                 suppressLowLevelAreas = Boolean.TRUE;
             } else if (args[i].equals("-d")) {
-                setLogOption("debug", "debug");
+                // nop. Left there for backwards compatibility
             } else if (args[i].equals("-r")) {
                 strictValidation = false;
             } else if (args[i].equals("-conserve")) {
@@ -304,7 +294,7 @@ public class CommandLineOptions {
             } else if (args[i].equals("-dpi")) {
                 i = i + parseResolution(args, i);
             } else if (args[i].equals("-q") || args[i].equals("--quiet")) {
-                setLogOption("quiet", "error");
+                // nop. Left there for backwards compatibility
             } else if (args[i].equals("-fo")) {
                 i = i + parseFOInputOption(args, i);
             } else if (args[i].equals("-xsl")) {
@@ -904,27 +894,6 @@ public class CommandLineOptions {
         }
     }
 
-    private void setLogOption(String option, String level) {
-        if (log instanceof CommandLineLogger
-            || System.getProperty("org.apache.commons.logging.Log") == null) {
-            setLogLevel(level);
-        } else if (log != null) {
-            log.warn("The option " + option + " can only be used");
-            log.warn("with FOP's command line logger,");
-            log.warn("which is the default on the command line.");
-            log.warn("Configure other loggers using Java system properties.");
-        }
-    }
-
-    private void setLogLevel(String level) {
-        // Set the level for future loggers.
-        LogFactory.getFactory().setAttribute("level", level);
-        if (log instanceof CommandLineLogger) {
-            // Set the level for the logger created already.
-            ((CommandLineLogger) log).setLogLevel(level);
-        }
-    }
-
     private void setInputFormat(int format) throws FOPException {
         if (inputmode == NOT_SET || inputmode == format) {
             inputmode = format;
@@ -1208,9 +1177,7 @@ public class CommandLineOptions {
                     + "[-awt|-pdf|-mif|-rtf|-tiff|-png|-pcl|-ps|-txt|-at [mime]|-print] <outfile>\n"
             + " [OPTIONS]  \n"
             + "  -version          print FOP version and exit\n"
-            + "  -d                debug mode   \n"
             + "  -x                dump configuration settings  \n"
-            + "  -q                quiet mode  \n"
             + "  -c cfg.xml        use additional configuration file cfg.xml\n"
             + "  -l lang           the language to use for user information \n"
             + "  -nocs             disable complex script features\n"

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/apps/AbstractFontReader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/apps/AbstractFontReader.java?rev=1508599&r1=1508598&r2=1508599&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/apps/AbstractFontReader.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/apps/AbstractFontReader.java Tue Jul 30 20:10:35 2013
@@ -32,8 +32,6 @@ import javax.xml.transform.TransformerFa
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import org.apache.fop.util.CommandLineLogger;
-
 /**
  * Abstract base class for the PFM and TTF Reader command-line applications.
  */
@@ -90,10 +88,6 @@ public abstract class AbstractFontReader
     protected static void setLogLevel(String level) {
         // Set the evel for future loggers.
         LogFactory.getFactory().setAttribute("level", level);
-        if (log instanceof CommandLineLogger) {
-            // Set the level for the logger creates already.
-            ((CommandLineLogger) log).setLogLevel(level);
-        }
     }
 
     /**

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/apps/PFMReader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/apps/PFMReader.java?rev=1508599&r1=1508598&r2=1508599&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/apps/PFMReader.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/apps/PFMReader.java Tue Jul 30 20:10:35 2013
@@ -33,7 +33,6 @@ import org.apache.commons.logging.LogFac
 
 import org.apache.fop.Version;
 import org.apache.fop.fonts.type1.PFMFile;
-import org.apache.fop.util.CommandLineLogger;
 
 /**
  * A tool which reads PFM files from Adobe Type 1 fonts and creates
@@ -92,14 +91,7 @@ public class PFMReader extends AbstractF
         Map options = new java.util.HashMap();
         String[] arguments = parseArguments(options, args);
 
-        // Enable the simple command line logging when no other logger is
-        // defined.
         LogFactory logFactory = LogFactory.getFactory();
-        if (System.getProperty("org.apache.commons.logging.Log") == null) {
-            logFactory.setAttribute("org.apache.commons.logging.Log",
-                                            CommandLineLogger.class.getName());
-        }
-
         determineLogLevel(options);
 
         PFMReader app = new PFMReader();

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/apps/TTFReader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/apps/TTFReader.java?rev=1508599&r1=1508598&r2=1508599&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/apps/TTFReader.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/apps/TTFReader.java Tue Jul 30 20:10:35 2013
@@ -39,7 +39,6 @@ import org.apache.fop.fonts.CMapSegment;
 import org.apache.fop.fonts.FontUtil;
 import org.apache.fop.fonts.truetype.FontFileReader;
 import org.apache.fop.fonts.truetype.TTFFile;
-import org.apache.fop.util.CommandLineLogger;
 
 // CSOFF: InnerAssignmentCheck
 // CSOFF: LineLengthCheck
@@ -123,14 +122,7 @@ public class TTFReader extends AbstractF
         Map options = new java.util.HashMap();
         String[] arguments = parseArguments(options, args);
 
-        // Enable the simple command line logging when no other logger is
-        // defined.
         LogFactory logFactory = LogFactory.getFactory();
-        if (System.getProperty("org.apache.commons.logging.Log") == null) {
-            logFactory.setAttribute("org.apache.commons.logging.Log",
-                                            CommandLineLogger.class.getName());
-        }
-
         determineLogLevel(options);
 
         TTFReader app = new TTFReader();



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Re: svn commit: r1508599 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop: cli/CommandLineOptions.java fonts/apps/AbstractFontReader.java fonts/apps/PFMReader.java fonts/apps/TTFReader.java util/CommandLineLogger.java

Posted by Vincent Hennebert <vh...@gmail.com>.
Some background on this: for years I had been able to activate debug
output just by uncommenting the LOGLEVEL line in the fop script
(line 246), that I had customized to use a JDK 1.4 logger.

Suddenly, some time last year that ceased working. I finally decided to
investigate and it turned out to be a side effect of the work on URI
resolution.

Here are the gory details:
> Modified: 
> xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java
> URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java?rev=1508599&r1=1508598&r2=1508599&view=diff
> ==============================================================================
> --- xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java (original)
> +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java Tue Jul 30 20:10:35 2013
> @@ -58,7 +58,6 @@ import org.apache.fop.render.pdf.PDFEncr
>  import org.apache.fop.render.print.PagesMode;
>  import org.apache.fop.render.print.PrintRenderer;
>  import org.apache.fop.render.xml.XMLRenderer;
> -import org.apache.fop.util.CommandLineLogger;
>  
>  /**
>   * Options parses the commandline arguments
> @@ -146,15 +145,6 @@ public class CommandLineOptions {
>       */
>      public CommandLineOptions() {
>          LogFactory logFactory = LogFactory.getFactory();
> -
> -        // Enable the simple command line logging when no other logger is
> -        // defined.
> -        if (System.getProperty("org.apache.commons.logging.Log") == null) {
> -            logFactory.setAttribute("org.apache.commons.logging.Log",
> -                                            CommandLineLogger.class.getName());
> -            setLogLevel("info");
> -        }
> -
>          log = LogFactory.getLog("FOP");
>      }

Previously, a FopFactory instance was created before that code was run.
So the LogFactory had already set itself up to return a certain logger,
Jdk14Logger by default. So setting the "org.apache.commons.logging.Log"
attribute had no effect.

After the URI resolution changes, it appeared that no class that uses
a log was initialized any more before that code was called. Which means
that the LogFactory was still unset, and that code set it to return
a CommandLineLogger. And my custom configuration for Jdk14Logger was no
longer working.

Since that code had been having no effect for years (at least 4,
probably more), and CommandLineLogger is suboptimal anyway (messing up
the output when rendering into stdout rather than a file), I decided to
remove it.

Vincent



On 30/07/13 22:10, vhennebert wrote:
> Author: vhennebert
> Date: Tue Jul 30 20:10:35 2013
> New Revision: 1508599
> 
> URL: http://svn.apache.org/r1508599
> Log:
> Removed obsolete CommandLineLogger.
> The Jdk14Logger is guaranteed to be there by default now that the minimal Java requirement is 1.5.
> Also, CommandLineLogger messes up the output when rendering to stdout.
> 
> Removed:
>     xmlgraphics/fop/trunk/src/java/org/apache/fop/util/CommandLineLogger.java
> Modified:
>     xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java
>     xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/apps/AbstractFontReader.java
>     xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/apps/PFMReader.java
>     xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/apps/TTFReader.java
<snip/>