You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Anton Tagunov <at...@mail.cnt.ru> on 2003/04/30 01:56:22 UTC

[PATCH] bug 19453 Let us add configuration parameter to instruct JaxpProcessor not to log stack traces - end user output

19453. Let us add configuration parameter to instruct
JaxpProcessor not to log stack traces - end user output

http://issues.apache.org/bugzilla/show_bug.cgi?id=19453


Enhancment proposal: if a real-worl command-line app is being
built it's reasonable to provide end user (presumably
xml/xsl-writer) with short messages on what is wrong in xml/xsl - just
filename/line-number/error-message. In such a setup the
stack traces are not needed. Let us add a
conf parameter to JaxpParser to do this?



--- JaxpParser.orig     2003-02-27 12:22:54.000000000 +0300
+++ JaxpParser.java     2003-04-30 00:48:11.000000000 +0400
@@ -101,6 +101,11 @@
  * <li>stop-on-recoverable-error (boolean, default = <code>true</code>) : should the parser
  *     stop parsing if a recoverable error occurs ?
  * </li>
+ * <li>log-stack-trace (boolean, default = <code>true</code>) : do we want 
+ * stack traces logged for warnings and errors?<br>
+ * In many case this is not needed -- all we need is the name of
+ * the offending xml file, line number and error message
+ * </li>
  * <li>reuse-parsers (boolean, default = <code>true</code>) : do we want to reuse
  *     parsers or create a new parser for each parse ?<br>
  *     <i>Note</i> : even if this parameter is <code>true</code>, parsers are not
@@ -148,6 +153,9 @@
     /** do we stop on recoverable errors ? */
     private boolean m_stopOnRecoverableError;
 
+    /** do we want stack traces logged for errors and warnings ? */
+    private boolean m_logStackTrace;
+
     /** the Document Builder factory */
     private DocumentBuilderFactory m_docFactory;
 
@@ -182,6 +190,7 @@
         m_reuseParsers = params.getParameterAsBoolean( "reuse-parsers", true );
         m_stopOnWarning = params.getParameterAsBoolean( "stop-on-warning", true );
         m_stopOnRecoverableError = params.getParameterAsBoolean( "stop-on-recoverable-error", true );
+        m_logStackTrace = params.getParameterAsBoolean( "log-stack-trace", true );//maybe false?
 
         // Get the SAXFactory
         final String saxParserFactoryName = params.getParameter( "sax-parser-factory",
@@ -430,7 +439,8 @@
         {
             throw new SAXException( message, spe );
         }
-        getLogger().error( message, spe );
+        if ( m_logStackTrace ) getLogger().error( message, spe );
+        else                   getLogger().error( message );
     }
 
     /**
@@ -461,6 +471,7 @@
         {
             throw new SAXException( message, spe );
         }
-        getLogger().warn( message, spe );
+        if ( m_logStackTrace ) getLogger().warn( message, spe );
+        else                   getLogger().warn( message );
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org