cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Turner <je...@apache.org>
Subject AbstractSAXTransformer logging (Re: cvs commit: ... AbstractSAXTransformer.java)
Date Wed, 18 Jun 2003 12:47:21 GMT
I'm not too sure of this commit.  The problem is that AbstractSAXTransformer's
debug-level logging is so verbose that it swamps the debug logs of its children
with stuff like this:

DEBUG   (/forrest/body-index.html): BEGIN endTransformingElement uri=, name=link, raw=link)
DEBUG   (/forrest/body-index.html): END endTransformingElement
DEBUG   (/forrest/body-index.html): BEGIN endTransformingElement uri=, name=p, raw=p)
DEBUG   (/forrest/body-index.html): END endTransformingElement
...

Simplest solution would be to just remove those debug() statements.

However, assuming these logs are useful to someone, I've added a flag to switch
them on/off (left on by default).  The flag is declared 'final' and can be
switched off with the protected constructor added for this purpose.

Advice welcome.

--Jeff


On Wed, Jun 18, 2003 at 12:22:07PM -0000, jefft@apache.org wrote:
> 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");
>            }
>        }
>   
>   
>   

Mime
View raw message