avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: jakarta-avalon-logkit/src/xdocs changes.xml
Date Mon, 03 Feb 2003 19:07:29 GMT
bloritsch    2003/02/03 11:07:29

  Modified:    src/java/org/apache/log/format ExtendedPatternFormatter.java
               src/java/org/apache/log/util StackIntrospector.java
               src/xdocs changes.xml
  Log:
  Add patches from Sash Chatterjee to support any arbitrary wrappers
  
  Revision  Changes    Path
  1.8       +18 -3     jakarta-avalon-logkit/src/java/org/apache/log/format/ExtendedPatternFormatter.java
  
  Index: ExtendedPatternFormatter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/format/ExtendedPatternFormatter.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ExtendedPatternFormatter.java	3 Feb 2003 17:40:12 -0000	1.7
  +++ ExtendedPatternFormatter.java	3 Feb 2003 19:07:28 -0000	1.8
  @@ -82,11 +82,18 @@
       private static final String TYPE_METHOD_STR = "method";
       private static final String TYPE_THREAD_STR = "thread";
   
  +    private int m_callStackOffset = 0;
  +
       public ExtendedPatternFormatter( final String format )
       {
  -        super( format );
  +        this( format, 0 );
       }
   
  +    public ExtendedPatternFormatter( final String format, final int callStackOffset )
  +    {
  +        super( format );
  +        m_callStackOffset = callStackOffset;
  +    }
       /**
        * Retrieve the type-id for a particular string.
        *
  @@ -147,7 +154,15 @@
               }
           }
   
  -        final String result = StackIntrospector.getCallerMethod( Logger.class );
  +        //Determine callee of user's class.  If offset is 0, we need to find
  +        // Logger.class.  If offset is 1, We need to find caller of Logger.class, etc.
  +        final Class clazz = StackIntrospector.getCallerClass( Logger.class, m_callStackOffset
- 1);
  +        if (null == clazz)
  +        {
  +            return "UnknownMethod";
  +        }
  +
  +        final String result = StackIntrospector.getCallerMethod( clazz );
           if( null == result )
           {
               return "UnknownMethod";
  
  
  
  1.8       +16 -2     jakarta-avalon-logkit/src/java/org/apache/log/util/StackIntrospector.java
  
  Index: StackIntrospector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/util/StackIntrospector.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- StackIntrospector.java	3 Feb 2003 17:40:17 -0000	1.7
  +++ StackIntrospector.java	3 Feb 2003 19:07:28 -0000	1.8
  @@ -129,6 +129,20 @@
       public static final Class getCallerClass( final Class clazz )
           throws SecurityException
       {
  +        return getCallerClass(clazz, 0);
  +    }
  +
  +    /**
  +     * Find the caller of the passed in Class.
  +     * May return null if caller not found on execution stack
  +     *
  +     * @param clazz the Class to search for on stack to find caller of
  +     * @param stackDepthOffset Offset call-stack depth to find caller
  +     * @return the Class of object that called parrameter class
  +     * @exception SecurityException if an existing SecurityManager disallows construction
  +     *            of another SecurityManager and thus blocks method results
  +     */
  +    public static final Class getCallerClass(final Class clazz, int stackDepthOffset) {
           final Class[] stack = getCallStack().get();
   
           // Traverse the call stack in reverse order until we find clazz
  @@ -137,7 +151,7 @@
               if( clazz.isAssignableFrom( stack[ i ] ) )
               {
                   // Found : the caller is the previous stack element
  -                return stack[ i + 1 ];
  +                return stack[ i + 1 + stackDepthOffset];
               }
           }
   
  
  
  
  1.37      +4 -0      jakarta-avalon-logkit/src/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-logkit/src/xdocs/changes.xml,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- changes.xml	3 Feb 2003 18:35:16 -0000	1.36
  +++ changes.xml	3 Feb 2003 19:07:29 -0000	1.37
  @@ -9,8 +9,12 @@
       <author email="giacomo at apache.org">Giacomo Pati</author>
       <author email="crafterm at apache.org">Marcus Crafter</author>
       <author email="sylvain.wallez at anyware-tech.com">Sylvain Wallez</author>
  +    <author email="shash_list at hotmail.com">Sash Chatterjee</author>
     </devs>
     <release version="1.2" date="?">
  +    <action dev="SC" type="add">
  +      Add support for any arbitrary logger wrapper class.
  +    </action>
       <action dev="SW" type="add">
         Add support for the LF5 GUI logging target.
       </action>
  
  
  

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


Mime
View raw message