avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon/src/java/org/apache/avalon/framework/logger AvalonFormatter.java
Date Sat, 26 Jan 2002 21:57:01 GMT
donaldp     02/01/26 13:57:01

  Modified:    src/java/org/apache/avalon/framework/logger
                        AvalonFormatter.java
  Log:
  Made it configurable whether you print nested exceptions or not.
  
  Submitted By: Jeremias Maerki <jeremias.maerki@outline.ch>
  
  Revision  Changes    Path
  1.11      +23 -6     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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- AvalonFormatter.java	11 Jan 2002 23:35:06 -0000	1.10
  +++ AvalonFormatter.java	26 Jan 2002 21:57:01 -0000	1.11
  @@ -25,28 +25,45 @@
        * The constant defining the default stack depth when 
        * none other is specified.
        */
  -    private static final int DEFAULT_STACK_DEPTH = 8;
  +    public static final int DEFAULT_STACK_DEPTH = 8;
  +
  +    /**
  +     * The constant defining the default behaviour for printing
  +     * nested exceptions.
  +     */
  +    public static final boolean DEFAULT_PRINT_CASCADING = true;
   
       //The depth to which stacktraces are printed out
       private final int m_stackDepth;
   
  +    //Determines if nested exceptions should be logged
  +    private final boolean m_printCascading;
  +
       /**
  -     * Construct the formatter with the specified pattern 
  +     * Construct the formatter with the specified pattern
        * and which which prints out exceptions to stackDepth of 8.
  +     *
  +     * @param pattern The pattern to use to format the log entries
        */
       public AvalonFormatter( final String pattern )
       {
  -        this( pattern, DEFAULT_STACK_DEPTH );
  +        this( pattern, DEFAULT_STACK_DEPTH, DEFAULT_PRINT_CASCADING );
       }
   
       /**
  -     * Construct the formatter with the specified pattern 
  +     * Construct the formatter with the specified pattern
        * and which which prints out exceptions to stackDepth specified.
  +     *
  +     * @param pattern The pattern to use to format the log entries
  +     * @param stackDepth The depth to which stacktraces are printed out
  +     * @param printCascading true enables printing of nested exceptions,
  +     *   false only prints out the outermost exception
        */
  -    public AvalonFormatter( final String pattern, final int stackDepth )
  +    public AvalonFormatter( final String pattern, final int stackDepth, final boolean printCascading
)
       {
           super( pattern );
           m_stackDepth = stackDepth;
  +        m_printCascading = printCascading;
       }
   
       /**
  @@ -59,6 +76,6 @@
       protected String getStackTrace( final Throwable throwable, final String format )
       {
           if( null == throwable ) return "";
  -        return ExceptionUtil.printStackTrace( throwable, m_stackDepth, true );
  +        return ExceptionUtil.printStackTrace( throwable, m_stackDepth, m_printCascading
);
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message