From d470d62badfec6dca2e8d16d1aec9ce1f773c6a9 Mon Sep 17 00:00:00 2001 From: Keiron Liddle Date: Tue, 21 Aug 2001 06:18:55 +0000 Subject: [PATCH] changed to new logging for renderers git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194436 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/apps/CommandLineOptions.java | 1 - .../apache/fop/apps/CommandLineStarter.java | 1 - src/org/apache/fop/apps/Driver.java | 35 ++++++----- src/org/apache/fop/apps/FOInputHandler.java | 3 - src/org/apache/fop/apps/Starter.java | 3 - src/org/apache/fop/apps/TraxInputHandler.java | 3 - src/org/apache/fop/apps/XSLTInputHandler.java | 1 - .../apache/fop/render/AbstractRenderer.java | 41 +++++++++++++ src/org/apache/fop/render/PrintRenderer.java | 6 +- src/org/apache/fop/render/Renderer.java | 61 ++++--------------- .../apache/fop/render/awt/AWTRenderer.java | 12 ++-- .../apache/fop/render/mif/MIFRenderer.java | 10 +-- .../apache/fop/render/pcl/PCLRenderer.java | 15 +++-- .../apache/fop/render/pdf/PDFRenderer.java | 11 ++-- src/org/apache/fop/render/ps/PSRenderer.java | 37 +++++------ .../apache/fop/render/txt/TXTRenderer.java | 11 ++-- .../apache/fop/render/xml/XMLRenderer.java | 8 +-- src/org/apache/fop/tools/TestConverter.java | 2 +- src/org/apache/fop/tools/anttasks/Fop.java | 3 +- 19 files changed, 126 insertions(+), 138 deletions(-) create mode 100644 src/org/apache/fop/render/AbstractRenderer.java diff --git a/src/org/apache/fop/apps/CommandLineOptions.java b/src/org/apache/fop/apps/CommandLineOptions.java index 5bb0d700d..80d8aa42e 100644 --- a/src/org/apache/fop/apps/CommandLineOptions.java +++ b/src/org/apache/fop/apps/CommandLineOptions.java @@ -13,7 +13,6 @@ import java.io.File; import java.io.FileNotFoundException; // FOP -import org.apache.fop.messaging.MessageHandler; import org.apache.fop.configuration.Configuration; import org.apache.fop.apps.FOPException; diff --git a/src/org/apache/fop/apps/CommandLineStarter.java b/src/org/apache/fop/apps/CommandLineStarter.java index b516ee938..c7d463290 100644 --- a/src/org/apache/fop/apps/CommandLineStarter.java +++ b/src/org/apache/fop/apps/CommandLineStarter.java @@ -21,7 +21,6 @@ import java.net.URL; // FOP -import org.apache.fop.messaging.MessageHandler; import org.apache.fop.configuration.Configuration; /** diff --git a/src/org/apache/fop/apps/Driver.java b/src/org/apache/fop/apps/Driver.java index dbd4f7a0c..e8c9003ac 100644 --- a/src/org/apache/fop/apps/Driver.java +++ b/src/org/apache/fop/apps/Driver.java @@ -207,6 +207,23 @@ public class Driver implements Loggable { _treeBuilder.setLogger(log); } + private Logger getLogger() { + if(log == null) { + Hierarchy hierarchy = Hierarchy.getDefaultHierarchy(); + PatternFormatter formatter = new PatternFormatter( + "[%{priority}]: %{message}\n%{throwable}" ); + + LogTarget target = null; + target = new StreamTarget(System.out, formatter); + + hierarchy.setDefaultLogTarget(target); + log = hierarchy.getLoggerFor("fop"); + log.setPriority(Priority.INFO); + log.error("Logger not set"); + } + return log; + } + /** * Resets the Driver so it can be reused. Property and element * mappings are reset to defaults. @@ -327,6 +344,7 @@ public class Driver implements Loggable { * @param renderer the renderer instance to use */ public void setRenderer(Renderer renderer) { + renderer.setLogger(getLogger()); _renderer = renderer; } @@ -420,22 +438,8 @@ public class Driver implements Loggable { * events but isn't a SAX Parser itself. */ public ContentHandler getContentHandler() { - if(log == null) { - Hierarchy hierarchy = Hierarchy.getDefaultHierarchy(); - PatternFormatter formatter = new PatternFormatter( - "[%{priority}]: %{message}\n%{throwable}" ); - - LogTarget target = null; - target = new StreamTarget(System.out, formatter); - - hierarchy.setDefaultLogTarget(target); - log = hierarchy.getLoggerFor("fop"); - log.setPriority(Priority.INFO); - log.error("Logger not set"); - } - StreamRenderer streamRenderer = new StreamRenderer(_stream, _renderer); - streamRenderer.setLogger(log); + streamRenderer.setLogger(getLogger()); _treeBuilder.setStreamRenderer(streamRenderer); return _treeBuilder; @@ -487,6 +491,7 @@ public class Driver implements Loggable { */ public void dumpError(Exception e) { if (_errorDump) { + Logger log = getLogger(); if (e instanceof SAXException) { log.error("", e); if (((SAXException)e).getException() != null) { diff --git a/src/org/apache/fop/apps/FOInputHandler.java b/src/org/apache/fop/apps/FOInputHandler.java index d3a871903..732a400a2 100644 --- a/src/org/apache/fop/apps/FOInputHandler.java +++ b/src/org/apache/fop/apps/FOInputHandler.java @@ -11,9 +11,6 @@ package org.apache.fop.apps; import org.xml.sax.InputSource; import org.xml.sax.XMLReader; -// fop -import org.apache.fop.messaging.MessageHandler; - // java import java.io.File; import java.net.URL; diff --git a/src/org/apache/fop/apps/Starter.java b/src/org/apache/fop/apps/Starter.java index 29e620f33..90d63c59b 100644 --- a/src/org/apache/fop/apps/Starter.java +++ b/src/org/apache/fop/apps/Starter.java @@ -17,9 +17,6 @@ import org.xml.sax.SAXException; import java.io.*; import java.net.URL; -// FOP -import org.apache.fop.messaging.MessageHandler; - /** * abstract super class * Creates a SAX Parser (defaulting to Xerces). diff --git a/src/org/apache/fop/apps/TraxInputHandler.java b/src/org/apache/fop/apps/TraxInputHandler.java index 4cebd7521..47d5ae008 100644 --- a/src/org/apache/fop/apps/TraxInputHandler.java +++ b/src/org/apache/fop/apps/TraxInputHandler.java @@ -29,9 +29,6 @@ import java.io.InputStream; import java.io.IOException; import java.io.File; -// FOP -import org.apache.fop.messaging.MessageHandler; - /** * XSLTInputHandler basically takes an xmlfile and transforms it with an xsltfile * and the resulting xsl:fo document is input for Fop. diff --git a/src/org/apache/fop/apps/XSLTInputHandler.java b/src/org/apache/fop/apps/XSLTInputHandler.java index 3b035838a..2b7e58fee 100644 --- a/src/org/apache/fop/apps/XSLTInputHandler.java +++ b/src/org/apache/fop/apps/XSLTInputHandler.java @@ -19,7 +19,6 @@ import org.xml.sax.XMLReader; import java.io.*; // FOP -import org.apache.fop.messaging.MessageHandler; import org.apache.fop.tools.xslt.XSLTransform; /** diff --git a/src/org/apache/fop/render/AbstractRenderer.java b/src/org/apache/fop/render/AbstractRenderer.java new file mode 100644 index 000000000..b7222229b --- /dev/null +++ b/src/org/apache/fop/render/AbstractRenderer.java @@ -0,0 +1,41 @@ +/* + * $Id$ + * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * For details on use and redistribution please refer to the + * LICENSE file included with these sources." + */ + +package org.apache.fop.render; + +// FOP +import org.apache.fop.pdf.PDFPathPaint; +import org.apache.fop.pdf.PDFColor; +import org.apache.fop.image.ImageArea; +import org.apache.fop.apps.FOPException; +import org.apache.fop.fo.properties.*; +import org.apache.fop.layout.*; +import org.apache.fop.layout.inline.*; +import org.apache.fop.datatypes.*; +import org.apache.fop.render.pdf.FontSetup; + +import org.apache.fop.svg.SVGArea; + +import org.apache.log.Logger; + +// Java +import java.io.IOException; +import java.io.OutputStream; +import java.util.Enumeration; + +/** + * Abstract base class for all renderers. + * + */ +public abstract class AbstractRenderer implements Renderer { + protected Logger log; + + public void setLogger(Logger logger) { + log = logger; + } + +} diff --git a/src/org/apache/fop/render/PrintRenderer.java b/src/org/apache/fop/render/PrintRenderer.java index f1afcde91..2213c6296 100644 --- a/src/org/apache/fop/render/PrintRenderer.java +++ b/src/org/apache/fop/render/PrintRenderer.java @@ -1,5 +1,3 @@ -/*--- formatted by Jindent 2.1, (www.c-lab.de/~jindent) ---*/ - /* * $Id$ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. @@ -15,8 +13,6 @@ package org.apache.fop.render; // FOP import org.apache.fop.pdf.PDFPathPaint; import org.apache.fop.pdf.PDFColor; -// import org.apache.fop.render.Renderer; -// import org.apache.fop.messaging.MessageHandler; import org.apache.fop.image.ImageArea; // import org.apache.fop.image.FopImage; import org.apache.fop.apps.FOPException; @@ -46,7 +42,7 @@ import java.util.Enumeration; * is not mentioned in this class but it is inherited from * the Renderer interface. */ -public abstract class PrintRenderer implements Renderer { +public abstract class PrintRenderer extends AbstractRenderer { // vvv These are not currently referenced by the PrintRenderer, but are common to PCL and PDF renderers - so declare here. /** diff --git a/src/org/apache/fop/render/Renderer.java b/src/org/apache/fop/render/Renderer.java index f9bc5946d..36d4364fa 100644 --- a/src/org/apache/fop/render/Renderer.java +++ b/src/org/apache/fop/render/Renderer.java @@ -1,54 +1,8 @@ -/*--- formatted by Jindent 2.1, (www.c-lab.de/~jindent) ---*/ - /* - * -- $Id$ -- - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modifica- - * tion, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The end-user documentation included with the redistribution, if any, must - * include the following acknowledgment: "This product includes software - * developed by the Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, if - * and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Fop" and "Apache Software Foundation" must not be used to - * endorse or promote products derived from this software without prior - * written permission. For written permission, please contact - * apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", nor may - * "Apache" appear in their name, without prior written permission of the - * Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- - * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software consists of voluntary contributions made by many individuals - * on behalf of the Apache Software Foundation and was originally created by - * James Tauber . For more information on the Apache - * Software Foundation, please see . - * + * $Id$ + * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * For details on use and redistribution please refer to the + * LICENSE file included with these sources. */ package org.apache.fop.render; @@ -59,6 +13,8 @@ import org.apache.fop.apps.FOPException; import org.apache.fop.layout.*; import org.apache.fop.layout.inline.*; +import org.apache.log.Logger; + // Java import java.io.OutputStream; import java.io.IOException; @@ -71,6 +27,11 @@ import java.io.IOException; */ public interface Renderer { + /** + * Set the logger + */ + public void setLogger(Logger logger); + /** * set up the given FontInfo */ diff --git a/src/org/apache/fop/render/awt/AWTRenderer.java b/src/org/apache/fop/render/awt/AWTRenderer.java index 5907f5de3..d88a30c12 100644 --- a/src/org/apache/fop/render/awt/AWTRenderer.java +++ b/src/org/apache/fop/render/awt/AWTRenderer.java @@ -16,7 +16,6 @@ package org.apache.fop.render.awt; import org.apache.fop.layout.*; import org.apache.fop.layout.inline.*; -import org.apache.fop.messaging.MessageHandler; import org.apache.fop.datatypes.*; import org.apache.fop.image.*; import org.apache.fop.svg.*; @@ -51,7 +50,7 @@ import java.awt.print.*; import java.awt.image.BufferedImage; import java.text.*; -import org.apache.fop.render.Renderer; +import org.apache.fop.render.AbstractRenderer; /** Modified by Mark Lillywhite mark-fop@inomial.com. Did lots of @@ -59,8 +58,7 @@ import org.apache.fop.render.Renderer; interface. This class could also do with a general audit, and I suspect it's not swing-thread-safe either. */ - -public class AWTRenderer implements Renderer, Printable, Pageable { +public class AWTRenderer extends AbstractRenderer implements Printable, Pageable { protected int pageWidth = 0; protected int pageHeight = 0; @@ -603,7 +601,7 @@ public class AWTRenderer implements Renderer, Printable, Pageable { FopImage img = area.getImage(); if (img == null) { - MessageHandler.logln("Error while loading image : area.getImage() is null"); + log.error("Error while loading image : area.getImage() is null"); // correct integer roundoff // graphics.drawRect(x / 1000, pageHeight - y / 1000, @@ -984,8 +982,8 @@ public class AWTRenderer implements Renderer, Printable, Pageable { * (int) height, imageIcon.getImageObserver()); * graphics.drawImage(bi, bop, (int) x, (int) y); * } catch (Exception ex) { - * MessageHandler.errorln("AWTRenderer: renderImage(): " + - * ex.getMessage()); + * log.error("AWTRenderer: renderImage(): " + + * ex.getMessage(), ex); * } * } */ diff --git a/src/org/apache/fop/render/mif/MIFRenderer.java b/src/org/apache/fop/render/mif/MIFRenderer.java index 154c73dc7..47627311f 100644 --- a/src/org/apache/fop/render/mif/MIFRenderer.java +++ b/src/org/apache/fop/render/mif/MIFRenderer.java @@ -11,7 +11,7 @@ package org.apache.fop.render.mif; // FOP import org.apache.fop.render.Renderer; -import org.apache.fop.messaging.MessageHandler; +import org.apache.fop.render.AbstractRenderer; import org.apache.fop.image.ImageArea; import org.apache.fop.image.FopImage; import org.apache.fop.apps.FOPException; @@ -47,7 +47,7 @@ import java.util.Hashtable; * it should still work. I don't have an MIF view to test it with, * you see. */ -public class MIFRenderer implements Renderer { +public class MIFRenderer extends AbstractRenderer { private String currentFontName; private String currentFontSize; @@ -378,7 +378,7 @@ public class MIFRenderer implements Renderer { * } */ - MessageHandler.logln("Warning: SVG images not supported in this version"); + log.warn("SVG images not supported in this version"); } else { String url = img.getURL(); this.mifDoc.addImage(url, x, pageHeight - y, w, h); @@ -487,7 +487,7 @@ public class MIFRenderer implements Renderer { */ public void startRenderer(OutputStream outputStream) throws IOException { - MessageHandler.logln("rendering areas to MIF"); + log.info("rendering areas to MIF"); } /** @@ -496,7 +496,7 @@ public class MIFRenderer implements Renderer { */ public void stopRenderer(OutputStream outputStream) throws IOException { - MessageHandler.logln("writing out MIF"); + log.info("writing out MIF"); this.mifDoc.output(outputStream); outputStream.flush(); } diff --git a/src/org/apache/fop/render/pcl/PCLRenderer.java b/src/org/apache/fop/render/pcl/PCLRenderer.java index 2b1dbbb1a..687bc8c77 100755 --- a/src/org/apache/fop/render/pcl/PCLRenderer.java +++ b/src/org/apache/fop/render/pcl/PCLRenderer.java @@ -9,7 +9,6 @@ package org.apache.fop.render.pcl; // FOP import org.apache.fop.render.PrintRenderer; -import org.apache.fop.messaging.MessageHandler; import org.apache.fop.image.ImageArea; import org.apache.fop.image.FopImage; import org.apache.fop.apps.FOPException; @@ -219,7 +218,7 @@ public class PCLRenderer extends PrintRenderer { int xpos = xoffset + (x / 100); if (xpos < 0) { xpos = 0; - MessageHandler.errorln("PCLRenderer.addRect() WARNING: Horizontal position out of bounds."); + log.error("PCLRenderer.addRect() WARNING: Horizontal position out of bounds."); } currentStream.add("\033*v1O\033&a" + xpos + "h" @@ -230,7 +229,7 @@ public class PCLRenderer extends PrintRenderer { xpos = xoffset + ((x + 240) / 100); if (xpos < 0) { xpos = 0; - MessageHandler.errorln("PCLRenderer.addRect() WARNING: Horizontal position out of bounds."); + log.error("PCLRenderer.addRect() WARNING: Horizontal position out of bounds."); } currentStream.add("\033&a" + xpos + "h" + (pageHeight - ((y + 240)) / 100) + "V" @@ -373,7 +372,7 @@ public class PCLRenderer extends PrintRenderer { int xpos = xoffset + (x / 100); if (xpos < 0) { xpos = 0; - MessageHandler.errorln("PCLRenderer.renderImageArea() WARNING: Horizontal position out of bounds."); + log.error("PCLRenderer.renderImageArea() WARNING: Horizontal position out of bounds."); } currentStream.add("\033&a" + xpos + "h" + (pageHeight - (y / 100)) @@ -383,7 +382,7 @@ public class PCLRenderer extends PrintRenderer { printBMP(img, x, y, w, h); } catch (FopImageException e) { // e.printStackTrace(System.out); - MessageHandler.errorln("PCLRenderer.renderImageArea() Error printing BMP (" + log.error("PCLRenderer.renderImageArea() Error printing BMP (" + e.toString() + ")"); } } @@ -617,7 +616,7 @@ public class PCLRenderer extends PrintRenderer { int xpos = xoffset + (rx / 100); if (xpos < 0) { xpos = 0; - MessageHandler.errorln("PCLRenderer.renderWordArea() WARNING: Horizontal position out of bounds."); + log.error("PCLRenderer.renderWordArea() WARNING: Horizontal position out of bounds."); } currentStream.add("\033&a" + xpos + "h" + (pageHeight - (bl / 100)) + "V" + s); @@ -725,7 +724,7 @@ public class PCLRenderer extends PrintRenderer { } public void startRenderer(OutputStream outputStream) throws IOException { - MessageHandler.logln("rendering areas to PCL"); + log.info("rendering areas to PCL"); currentStream = new PCLStream(outputStream); // Set orientation. @@ -744,7 +743,7 @@ public class PCLRenderer extends PrintRenderer { public void stopRenderer(OutputStream outputStream) throws IOException { - MessageHandler.logln("writing out PCL"); + log.info("writing out PCL"); outputStream.flush(); } diff --git a/src/org/apache/fop/render/pdf/PDFRenderer.java b/src/org/apache/fop/render/pdf/PDFRenderer.java index 45ca0b4ba..b76b1b77d 100644 --- a/src/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/org/apache/fop/render/pdf/PDFRenderer.java @@ -9,7 +9,6 @@ package org.apache.fop.render.pdf; // FOP import org.apache.fop.render.PrintRenderer; -import org.apache.fop.messaging.MessageHandler; import org.apache.fop.image.ImageArea; import org.apache.fop.image.FopImage; import org.apache.fop.apps.FOPException; @@ -423,8 +422,8 @@ public class PDFRenderer extends PrintRenderer { root.paint(graphics, rc); currentStream.add(graphics.getString()); } catch (Exception e) { - MessageHandler.errorln("Error: svg graphic could not be rendered: " - + e.getMessage()); + log.error("svg graphic could not be rendered: " + + e.getMessage(), e); } currentAnnotList = graphics.getAnnotList(); @@ -681,7 +680,7 @@ public class PDFRenderer extends PrintRenderer { public void render(Page page, OutputStream outputStream) throws FOPException, IOException { - // MessageHandler.logln("rendering single page to PDF"); + // log.debug("rendering single page to PDF"); this.idReferences = page.getIDReferences(); this.pdfResources = this.pdfDoc.getResources(); this.pdfDoc.setIDReferences(idReferences); @@ -692,7 +691,7 @@ public class PDFRenderer extends PrintRenderer { // TODO: this needs to be implemented renderRootExtensions(page); - // MessageHandler.logln("writing out PDF"); + // log.debug("writing out PDF"); this.pdfDoc.output(outputStream); } @@ -825,7 +824,7 @@ public class PDFRenderer extends PrintRenderer { PDFOutline pdfParentOutline = (PDFOutline)parent.getRendererObject(); if (pdfParentOutline == null) { - MessageHandler.errorln("Error: pdfParentOutline is null"); + log.error("pdfParentOutline is null"); } else { pdfOutline = this.pdfDoc.makeOutline(pdfParentOutline, diff --git a/src/org/apache/fop/render/ps/PSRenderer.java b/src/org/apache/fop/render/ps/PSRenderer.java index 5bfcca1a3..a7836df34 100644 --- a/src/org/apache/fop/render/ps/PSRenderer.java +++ b/src/org/apache/fop/render/ps/PSRenderer.java @@ -8,8 +8,8 @@ package org.apache.fop.render.ps; // FOP -import org.apache.fop.messaging.MessageHandler; import org.apache.fop.svg.SVGArea; +import org.apache.fop.render.AbstractRenderer; import org.apache.fop.render.Renderer; import org.apache.fop.image.ImageArea; import org.apache.fop.image.FopImage; @@ -29,6 +29,8 @@ import org.apache.batik.gvt.renderer.*; import org.apache.batik.gvt.filter.*; import org.apache.batik.gvt.event.*; +import org.apache.log.Logger; + // SVG import org.w3c.dom.svg.SVGSVGElement; import org.w3c.dom.svg.SVGDocument; @@ -76,7 +78,7 @@ import java.awt.Dimension; * * @author Jeremias Märki */ -public class PSRenderer implements Renderer { +public class PSRenderer extends AbstractRenderer { /** * the application producing the PostScript @@ -430,7 +432,7 @@ public class PSRenderer implements Renderer { write(sx + " " + sy + " " + " scale"); - UserAgent userAgent = new MUserAgent(new AffineTransform()); + UserAgent userAgent = new MUserAgent(new AffineTransform(), log); GVTBuilder builder = new GVTBuilder(); GraphicsNodeRenderContext rc = getRenderContext(); @@ -447,9 +449,8 @@ public class PSRenderer implements Renderer { root = builder.build(ctx, doc); root.paint(graphics, rc); } catch (Exception e) { - MessageHandler.errorln("Error: svg graphic could not be rendered: " - + e.getMessage()); - // e.printStackTrace(); + log.error("svg graphic could not be rendered: " + + e.getMessage(), e); } @@ -555,9 +556,8 @@ public class PSRenderer implements Renderer { write(""); write("grestore"); } catch (FopImageException e) { - e.printStackTrace(); - MessageHandler.errorln("PSRenderer.renderImageArea(): Error rendering bitmap (" - + e.toString() + ")"); + log.error("PSRenderer.renderImageArea(): Error rendering bitmap (" + + e.getMessage() + ")", e); } } @@ -824,11 +824,11 @@ public class PSRenderer implements Renderer { break; case LeaderPattern.DOTS: comment("% --- Leader dots NYI"); - MessageHandler.errorln("Leader dots: Not yet implemented"); + log.error("Leader dots: Not yet implemented"); break; case LeaderPattern.USECONTENT: comment("% --- Leader use-content NYI"); - MessageHandler.errorln("Leader use-content: Not yet implemented"); + log.error("Leader use-content: Not yet implemented"); break; } this.currentXPosition += area.getContentWidth(); @@ -927,26 +927,27 @@ public class PSRenderer implements Renderer { protected class MUserAgent implements UserAgent { AffineTransform currentTransform = null; - + Logger log; /** * Creates a new SVGUserAgent. */ - protected MUserAgent(AffineTransform at) { + protected MUserAgent(AffineTransform at, Logger logger) { currentTransform = at; + log = logger; } /** * Displays an error message. */ public void displayError(String message) { - System.err.println(message); + log.error(message); } /** * Displays an error resulting from the specified Exception. */ public void displayError(Exception ex) { - ex.printStackTrace(System.err); + log.error("SVG Error" + ex.getMessage(), ex); } /** @@ -954,7 +955,7 @@ public class PSRenderer implements Renderer { * The given message is typically displayed in a status bar. */ public void displayMessage(String message) { - System.out.println(message); + log.info(message); } /** @@ -1037,7 +1038,7 @@ public class PSRenderer implements Renderer { */ public void startRenderer(OutputStream outputStream) throws IOException { - MessageHandler.logln("rendering areas to PostScript"); + log.debug("rendering areas to PostScript"); this.out = new PSStream(outputStream); write("%!PS-Adobe-3.0"); @@ -1064,7 +1065,7 @@ public class PSRenderer implements Renderer { write("%%Trailer"); write("%%EOF"); this.out.flush(); - MessageHandler.logln("written out PostScript"); + log.debug("written out PostScript"); } public void render(Page page, OutputStream outputStream) { diff --git a/src/org/apache/fop/render/txt/TXTRenderer.java b/src/org/apache/fop/render/txt/TXTRenderer.java index b173ab03c..d8f6b0d5a 100755 --- a/src/org/apache/fop/render/txt/TXTRenderer.java +++ b/src/org/apache/fop/render/txt/TXTRenderer.java @@ -11,7 +11,6 @@ package org.apache.fop.render.txt; // FOP import org.apache.fop.render.PrintRenderer; import org.apache.fop.render.pcl.*; -import org.apache.fop.messaging.MessageHandler; import org.apache.fop.apps.FOPException; import org.apache.fop.fo.properties.*; import org.apache.fop.layout.*; @@ -784,8 +783,8 @@ public class TXTRenderer extends PrintRenderer { printBMP(img, x, y, w, h); } catch (FopImageException e) { // e.printStackTrace(System.out); - MessageHandler.errorln("TXTRenderer.renderImageArea() Error printing BMP (" - + e.toString() + ")."); + log.error("TXTRenderer.renderImageArea() printing BMP (" + + e.toString() + ").", e); } } @@ -805,7 +804,7 @@ public class TXTRenderer extends PrintRenderer { } } } catch (Exception e) { - MessageHandler.errorln("could not add image to SVG: " + href); + log.error("could not add image to SVG: " + href, e); } } @@ -1677,7 +1676,7 @@ public class TXTRenderer extends PrintRenderer { } public void startRenderer(OutputStream outputStream) throws IOException { - MessageHandler.logln("rendering areas to TEXT"); + log.info("rendering areas to TEXT"); currentStream = new PCLStream(outputStream); firstPage=true; } @@ -1690,7 +1689,7 @@ public class TXTRenderer extends PrintRenderer { public void stopRenderer(OutputStream outputStream) throws IOException { - MessageHandler.logln("writing out TEXT"); + log.info("writing out TEXT"); outputStream.flush(); } diff --git a/src/org/apache/fop/render/xml/XMLRenderer.java b/src/org/apache/fop/render/xml/XMLRenderer.java index 842c07f95..22223a171 100644 --- a/src/org/apache/fop/render/xml/XMLRenderer.java +++ b/src/org/apache/fop/render/xml/XMLRenderer.java @@ -9,8 +9,8 @@ package org.apache.fop.render.xml; // FOP import org.apache.fop.svg.*; -import org.apache.fop.messaging.MessageHandler; import org.apache.fop.render.Renderer; +import org.apache.fop.render.AbstractRenderer; import org.apache.fop.image.ImageArea; import org.apache.fop.layout.*; import org.apache.fop.layout.inline.*; @@ -30,7 +30,7 @@ import java.util.Hashtable; * Modified by Mark Lillywhite mark-fop@inomial.com to use the * new renderer interface. Not 100% certain that this is correct. */ -public class XMLRenderer implements Renderer { +public class XMLRenderer extends AbstractRenderer { /** * indentation to use for pretty-printing the XML @@ -442,7 +442,7 @@ public class XMLRenderer implements Renderer { */ public void startRenderer(OutputStream outputStream) throws IOException { - MessageHandler.logln("rendering areas to XML"); + log.info("rendering areas to XML"); this.writer = new PrintWriter(outputStream); this.writer.write( "\n\n"); @@ -457,6 +457,6 @@ public class XMLRenderer implements Renderer { throws IOException { writeEndTag(""); this.writer.flush(); - MessageHandler.errorln("written out XML"); + log.error("written out XML"); } } diff --git a/src/org/apache/fop/tools/TestConverter.java b/src/org/apache/fop/tools/TestConverter.java index 676b86346..4cc6dd17d 100644 --- a/src/org/apache/fop/tools/TestConverter.java +++ b/src/org/apache/fop/tools/TestConverter.java @@ -85,7 +85,7 @@ public class TestConverter { } private void setupLogging() { - log = Hierarchy.getDefaultHierarchy().getLoggerFor("testing"); + log = Hierarchy.getDefaultHierarchy().getLoggerFor("test"); } public void setOutputPDF(boolean pdf) { diff --git a/src/org/apache/fop/tools/anttasks/Fop.java b/src/org/apache/fop/tools/anttasks/Fop.java index fdf5f906b..94ea54c98 100644 --- a/src/org/apache/fop/tools/anttasks/Fop.java +++ b/src/org/apache/fop/tools/anttasks/Fop.java @@ -212,7 +212,7 @@ class FOPTaskStarter extends Starter { } } - +/* class MessageLogger implements MessageListener { MessageHandler handler; Task task; @@ -294,3 +294,4 @@ class MessageLogger implements MessageListener { } } +*/ -- 2.39.5