You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by do...@apache.org on 2002/01/12 00:33:30 UTC

cvs commit: jakarta-avalon/src/java/org/apache/avalon/framework/logger AvalonFormatter.java

donaldp     02/01/11 15:33:30

  Modified:    src/java/org/apache/avalon/framework/logger
                        AvalonFormatter.java
  Log:
  Added the ability to specify the depth to which you print stack traces in formatter. Defaults to 8 if not specified (for backwards compatability).
  
  Removed getTime() as it seemed to duplicate superclasses behaviour.
  
  Suggested By: Jeremias Maerki <je...@outline.ch>
  
  Revision  Changes    Path
  1.9       +19 -13    jakarta-avalon/src/java/org/apache/avalon/framework/logger/AvalonFormatter.java
  
  Index: AvalonFormatter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/src/java/org/apache/avalon/framework/logger/AvalonFormatter.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AvalonFormatter.java	11 Dec 2001 09:00:46 -0000	1.8
  +++ AvalonFormatter.java	11 Jan 2002 23:33:30 -0000	1.9
  @@ -15,38 +15,44 @@
    * This formatter extends PatternFormatter so that
    * CascadingExceptions are formatted with all nested exceptions.
    *
  + * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    */
   public class AvalonFormatter
       extends PatternFormatter
   {
  +    //The depth to which stacktraces are printed out
  +    private final int m_stackDepth;
  +
  +    /**
  +     * Construct the formatter with the specified pattern 
  +     * and which which prints out exceptions to stackDepth of 8.
  +     */
       public AvalonFormatter( final String pattern )
       {
  -        super( pattern );
  +        this( pattern, 8 );
       }
   
       /**
  -     * Utility method to format stack trace.
  -     *
  -     * @param throwable the throwable instance
  -     * @param format ancilliary format parameter - allowed to be null
  -     * @return the formatted string
  +     * Construct the formatter with the specified pattern 
  +     * and which which prints out exceptions to stackDepth specified.
        */
  -    protected String getStackTrace( final Throwable throwable, final String format )
  +    public AvalonFormatter( final String pattern, final int stackDepth )
       {
  -        if( null == throwable ) return "";
  -        return ExceptionUtil.printStackTrace( throwable, 8, true );
  +        super( pattern );
  +        m_stackDepth = stackDepth;
       }
   
       /**
  -     * Utility method to format time.
  +     * Utility method to format stack trace.
        *
  -     * @param time the time
  +     * @param throwable the throwable instance
        * @param format ancilliary format parameter - allowed to be null
        * @return the formatted string
        */
  -    protected String getTime( final long time, final String format )
  +    protected String getStackTrace( final Throwable throwable, final String format )
       {
  -        return String.valueOf(System.currentTimeMillis());
  +        if( null == throwable ) return "";
  +        return ExceptionUtil.printStackTrace( throwable, m_stackDepth, true );
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>