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:36:55 GMT
bloritsch    2003/02/03 11:36:55

  Modified:    src/java/org/apache/log Hierarchy.java Logger.java
               src/test/org/apache/log/test InheritanceTestCase.java
               src/test/org/apache/log/util/test UtilTestCase.java
               src/xdocs changes.xml
  Log:
  add LoggerListener hierarchy
  
  Revision  Changes    Path
  1.20      +53 -1     jakarta-avalon-logkit/src/java/org/apache/log/Hierarchy.java
  
  Index: Hierarchy.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/Hierarchy.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- Hierarchy.java	3 Feb 2003 17:40:12 -0000	1.19
  +++ Hierarchy.java	3 Feb 2003 19:36:54 -0000	1.20
  @@ -57,6 +57,7 @@
   import org.apache.log.format.PatternFormatter;
   import org.apache.log.output.io.StreamTarget;
   import org.apache.log.util.DefaultErrorHandler;
  +import org.apache.log.util.LoggerListener;
   
   /**
    * This class encapsulates a basic independent log hierarchy.
  @@ -80,6 +81,9 @@
       ///The root logger which contains all Loggers in this hierarchy
       private Logger m_rootLogger;
   
  +    ///LoggerListener associated with hierarchy
  +    private LoggerListener m_loggerListener;
  +
       /**
        * Retrieve the default hierarchy.
        *
  @@ -103,7 +107,9 @@
       public Hierarchy()
       {
           m_errorHandler = new DefaultErrorHandler();
  -        m_rootLogger = new Logger( new InnerErrorHandler(), "", null, null );
  +        m_rootLogger = new Logger( new InnerErrorHandler(),
  +                                   new InnerLoggerListener(),
  +                                   "", null, null );
   
           //Setup default output target to print to console
           final PatternFormatter formatter = new PatternFormatter( FORMAT );
  @@ -188,6 +194,16 @@
       }
   
       /**
  +     * Set the LoggerListener associated with hierarchy.
  +     *
  +     * @param loggerListener the LoggerListener
  +     */
  +    public synchronized void setLoggerListener( final LoggerListener loggerListener )
  +    {
  +        m_loggerListener = loggerListener;
  +    }
  +
  +    /**
        * Retrieve a logger for named category.
        *
        * @param category the context
  @@ -221,6 +237,42 @@
       public void log( final String message )
       {
           log( message, null );
  +    }
  +
  +    /**
  +     * Notify logger listener (if any) that a new logger was created.
  +     *
  +     * @param category the category of new logger
  +     * @param logger the logger
  +     */
  +    private synchronized void notifyLoggerCreated( final String category,
  +                                                   final Logger logger )
  +    {
  +        if( null != m_loggerListener )
  +        {
  +            m_loggerListener.loggerCreated( category, logger );
  +        }
  +    }
  +
  +    /**
  +     * Inner class to redirect to hierarchys real LoggerListener if any.
  +     * Used so that all the loggers will not have to be updated
  +     * when LoggerListener changes.
  +     */
  +    private class InnerLoggerListener
  +        extends LoggerListener
  +    {
  +        /**
  +         * Notify listener that a logger was created.
  +         *
  +         * @param category the category of logger
  +         * @param logger the logger object
  +         */
  +        public void loggerCreated( final String category,
  +                                   final Logger logger )
  +        {
  +            notifyLoggerCreated( category, logger );
  +        }
       }
   
       private class InnerErrorHandler
  
  
  
  1.34      +12 -1     jakarta-avalon-logkit/src/java/org/apache/log/Logger.java
  
  Index: Logger.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/Logger.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- Logger.java	3 Feb 2003 17:40:12 -0000	1.33
  +++ Logger.java	3 Feb 2003 19:36:54 -0000	1.34
  @@ -54,6 +54,8 @@
    */
   package org.apache.log;
   
  +import org.apache.log.util.LoggerListener;
  +
   /**
    * The object interacted with by client objects to perform logging.
    *
  @@ -69,6 +71,9 @@
       ///The ErrorHandler associated with Logger
       private final ErrorHandler m_errorHandler;
   
  +    ///The ErrorHandler associated with Logger
  +    private final LoggerListener m_loggerListener;
  +
       ///Logger to inherit logtargets and priorities from
       private final Logger m_parent;
   
  @@ -106,11 +111,13 @@
        * @param parent the parent logger (used for inheriting from)
        */
       Logger( final ErrorHandler errorHandler,
  +            final LoggerListener loggerListener,
               final String category,
               final LogTarget[] logTargets,
               final Logger parent )
       {
           m_errorHandler = errorHandler;
  +        m_loggerListener = loggerListener;
           m_category = category;
           m_logTargets = logTargets;
           m_parent = parent;
  @@ -545,12 +552,16 @@
           }
   
           //Create new logger
  -        final Logger child = new Logger( m_errorHandler, category, null, this );
  +        final Logger child =
  +            new Logger( m_errorHandler, m_loggerListener, category, null, this );
   
           if( m_additivity )
           {
               child.setAdditivity( true );
           }
  +
  +        m_loggerListener.loggerCreated( child.m_category, child );
  +
   
           //Add new logger to child list
           if( null == m_children )
  
  
  
  1.6       +0 -2      jakarta-avalon-logkit/src/test/org/apache/log/test/InheritanceTestCase.java
  
  Index: InheritanceTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-logkit/src/test/org/apache/log/test/InheritanceTestCase.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- InheritanceTestCase.java	3 Feb 2003 17:40:17 -0000	1.5
  +++ InheritanceTestCase.java	3 Feb 2003 19:36:54 -0000	1.6
  @@ -71,8 +71,6 @@
   public final class InheritanceTestCase
       extends TestCase
   {
  -    private final static String POSITIVE = "+1 Positive - yay - lets do the chicken dance.";
  -
       private final static String PATTERN = "%{priority}-%{message}";
       private final static PatternFormatter FORMATTER = new PatternFormatter( PATTERN );
   
  
  
  
  1.6       +1 -1      jakarta-avalon-logkit/src/test/org/apache/log/util/test/UtilTestCase.java
  
  Index: UtilTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-logkit/src/test/org/apache/log/util/test/UtilTestCase.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- UtilTestCase.java	3 Feb 2003 17:40:17 -0000	1.5
  +++ UtilTestCase.java	3 Feb 2003 19:36:54 -0000	1.6
  @@ -77,7 +77,6 @@
   
       private final static String MSG = "No soup for you!";
       private final static String RMSG = MSG;
  -    private final static String METHOD_RESULT = UtilTestCase.class.getName() + ".";
   
       public UtilTestCase( final String name )
       {
  @@ -95,6 +94,7 @@
           throws Exception
       {
           /*
  +        final String METHOD_RESULT = UtilTestCase.class.getName() + ".";
           final ByteArrayOutputStream output = new ByteArrayOutputStream();
           final StreamTarget target = new StreamTarget( output, METHOD_FORMATTER );
           final Hierarchy hierarchy = new Hierarchy();
  
  
  
  1.38      +3 -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.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- changes.xml	3 Feb 2003 19:07:29 -0000	1.37
  +++ changes.xml	3 Feb 2003 19:36:55 -0000	1.38
  @@ -12,6 +12,9 @@
       <author email="shash_list at hotmail.com">Sash Chatterjee</author>
     </devs>
     <release version="1.2" date="?">
  +    <action dev="PD" type="add">
  +      Add LoggerListener support.
  +    </action>
       <action dev="SC" type="add">
         Add support for any arbitrary logger wrapper class.
       </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