proyal 2003/02/17 14:00:18 Modified: . changes.xml src/java/org/apache/cocoon/util/log CocoonTargetFactory.java CocoonLogFormatter.java Log: Add "depth" param to control depth of stacktrace in logs Revision Changes Path 1.347 +5 -1 xml-cocoon2/changes.xml Index: changes.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/changes.xml,v retrieving revision 1.346 retrieving revision 1.347 diff -u -r1.346 -r1.347 --- changes.xml 17 Feb 2003 21:56:42 -0000 1.346 +++ changes.xml 17 Feb 2003 22:00:17 -0000 1.347 @@ -41,6 +41,10 @@ </devs> <release version="@version@" date="@date@"> + <action dev="PAR" type="add"> + Optional "depth" attribute on the cocoon log format to control how deep to go in stacktrace + reporting. + </action> <action dev="PAR" type="fix"> Do not specify a default to the "class-loader" parameter in JavaLanguage </action> 1.7 +3 -2 xml-cocoon2/src/java/org/apache/cocoon/util/log/CocoonTargetFactory.java Index: CocoonTargetFactory.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/util/log/CocoonTargetFactory.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- CocoonTargetFactory.java 31 Jan 2003 22:51:59 -0000 1.6 +++ CocoonTargetFactory.java 17 Feb 2003 22:00:18 -0000 1.7 @@ -143,7 +143,8 @@ if ("cocoon".equals(type)) { - final CocoonLogFormatter formatter = new CocoonLogFormatter(); + int depth = conf.getAttributeAsInteger( "depth", 0 ); + final CocoonLogFormatter formatter = new CocoonLogFormatter( depth ); final String format = conf.getValue(CFORMAT); formatter.setFormat(format); return formatter; 1.9 +21 -12 xml-cocoon2/src/java/org/apache/cocoon/util/log/CocoonLogFormatter.java Index: CocoonLogFormatter.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/util/log/CocoonLogFormatter.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- CocoonLogFormatter.java 31 Jan 2003 22:51:59 -0000 1.8 +++ CocoonLogFormatter.java 17 Feb 2003 22:00:18 -0000 1.9 @@ -51,6 +51,7 @@ package org.apache.cocoon.util.log; import org.apache.avalon.framework.CascadingThrowable; +import org.apache.avalon.framework.ExceptionUtil; import org.apache.cocoon.environment.ObjectModelHelper; import org.apache.cocoon.environment.Request; import org.apache.log.ContextMap; @@ -78,6 +79,12 @@ */ public class CocoonLogFormatter extends ExtensiblePatternFormatter { + /** + * The constant defining the default stack depth when + * none other is specified. + */ + public static final int DEFAULT_STACK_DEPTH = 8; + protected final static int TYPE_CLASS = MAX_TYPE + 1; protected final static int TYPE_URI = MAX_TYPE + 2; protected final static int TYPE_THREAD = MAX_TYPE + 3; @@ -126,6 +133,18 @@ private CallStack callStack = new CallStack(); + //The depth to which stacktraces are printed out + private final int m_stackDepth; + + public CocoonLogFormatter() + { + this( DEFAULT_STACK_DEPTH ); + } + + public CocoonLogFormatter( int stackDepth ) + { + m_stackDepth = stackDepth; + } protected int getTypeIdFor(String type) { @@ -236,17 +255,7 @@ */ protected String getStackTrace( final Throwable throwable, final String format ) { - final StringBuffer sb = new StringBuffer(); - sb.append( super.getStackTrace( throwable, format ) ); - - if( throwable instanceof CascadingThrowable ) - { - final Throwable t = ((CascadingThrowable)throwable).getCause(); - - sb.append( getStackTrace( t, format ) ); - } - - return sb.toString(); + return throwable == null ? null : ExceptionUtil.printStackTrace(throwable,m_stackDepth); } /**
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]