jefft 2003/06/18 05:22:07
Modified: src/java/org/apache/cocoon/transformation AbstractSAXTransformer.java Log: Add a boolean field determining whether to log SAX events (primarily element start/endTransformingElement() calls). Occasionally these SAX logs are useful, but they are so numerous that they often render the 'debug' level useless for subclasses. Field is marked as final to aid the JVM in optimizing away the logs if set to false, and subclasses can set the field using a protected constructor. Revision Changes Path 1.3 +20 -4 cocoon-2.1/src/java/org/apache/cocoon/transformation/AbstractSAXTransformer.java Index: AbstractSAXTransformer.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/transformation/AbstractSAXTransformer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- AbstractSAXTransformer.java 18 Jun 2003 12:11:07 -0000 1.2 +++ AbstractSAXTransformer.java 18 Jun 2003 12:22:06 -0000 1.3 @@ -201,6 +201,22 @@ private List namespaces = new ArrayList(5); /** + * Whether to log SAX events for debugging. Defaults to true, and can be + * set to false by subclasses with a constructor. + * */ + protected final boolean logSAXEvents; + + public AbstractSAXTransformer() { + this(true); + } + + /** @param logSAXEvents Whether to do a debug-level log for each processed + * element. */ + protected AbstractSAXTransformer(final boolean logSAXEvents) { + this.logSAXEvents = logSAXEvents; + } + + /** * Avalon Configurable Interface */ public void configure(Configuration configuration) @@ -683,11 +699,11 @@ String raw, Attributes attr) throws ProcessingException, IOException, SAXException { - if (this.getLogger().isDebugEnabled()) { + if (this.logSAXEvents && this.getLogger().isDebugEnabled()) { this.getLogger().debug("BEGIN startTransformingElement uri=" + uri + ", name=" + name + ", raw=" + raw + ", attr=" + attr + ")"); } if (this.ignoreEventsCount == 0) super.startElement(uri, name, raw, attr); - if (this.getLogger().isDebugEnabled()) { + if (this.logSAXEvents && this.getLogger().isDebugEnabled()) { this.getLogger().debug("END startTransformingElement"); } } @@ -703,11 +719,11 @@ String name, String raw) throws ProcessingException, IOException, SAXException { - if (this.getLogger().isDebugEnabled()) { + if (this.logSAXEvents && this.getLogger().isDebugEnabled()) { this.getLogger().debug("BEGIN endTransformingElement uri=" + uri + ", name=" + name + ", raw=" + raw + ")"); } if (this.ignoreEventsCount == 0) super.endElement(uri, name, raw); - if (this.getLogger().isDebugEnabled()) { + if (this.logSAXEvents && this.getLogger().isDebugEnabled()) { this.getLogger().debug("END endTransformingElement"); } }