avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pro...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/logger/src/java/org/apache/avalon/excalibur/logger LogKitLoggerManager.java
Date Mon, 07 Oct 2002 17:50:06 GMT
proyal      2002/10/07 10:50:06

  Modified:    logger/src/java/org/apache/avalon/excalibur/logger
                        LogKitLoggerManager.java
  Log:
  * Use ContainerUtil where possible
  * Expose additivity property of LogKit.
  
  Revision  Changes    Path
  1.9       +24 -26    jakarta-avalon-excalibur/logger/src/java/org/apache/avalon/excalibur/logger/LogKitLoggerManager.java
  
  Index: LogKitLoggerManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/logger/src/java/org/apache/avalon/excalibur/logger/LogKitLoggerManager.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- LogKitLoggerManager.java	2 Oct 2002 01:47:02 -0000	1.8
  +++ LogKitLoggerManager.java	7 Oct 2002 17:50:05 -0000	1.9
  @@ -60,6 +60,7 @@
   import org.apache.avalon.framework.logger.LogEnabled;
   import org.apache.avalon.framework.logger.LogKitLogger;
   import org.apache.avalon.framework.logger.Logger;
  +import org.apache.avalon.framework.container.ContainerUtil;
   import org.apache.log.Hierarchy;
   import org.apache.log.LogTarget;
   import org.apache.log.Priority;
  @@ -70,6 +71,7 @@
    *
    * @author <a href="mailto:giacomo@apache.org">Giacomo Pati</a>
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  + * @author <a href="mailto:proyal@apache.org">Peter Royal</a>
    * @version CVS $Revision$ $Date$
    * @since 4.0
    */
  @@ -229,7 +231,10 @@
   
           final Configuration categories = configuration.getChild( "categories" );
           final Configuration[] category = categories.getChildren( "category" );
  -        setupLoggers( targetManager, m_prefix, category );
  +        setupLoggers( targetManager,
  +                      m_prefix,
  +                      category,
  +                      categories.getAttributeAsBoolean( "additive", false ) );
       }
   
       /**
  @@ -242,24 +247,19 @@
           throws ConfigurationException
       {
           final DefaultLogTargetFactoryManager targetFactoryManager = new DefaultLogTargetFactoryManager();
  -        if( targetFactoryManager instanceof LogEnabled )
  +
  +        ContainerUtil.enableLogging( targetFactoryManager, m_logger );
  +
  +        try
           {
  -            targetFactoryManager.enableLogging( m_logger );
  +            ContainerUtil.contextualize( targetFactoryManager, m_context );
           }
  -
  -        if( targetFactoryManager instanceof Contextualizable )
  +        catch( final ContextException ce )
           {
  -            try
  -            {
  -                targetFactoryManager.contextualize( m_context );
  -            }
  -            catch( final ContextException ce )
  -            {
  -                throw new ConfigurationException( "cannot contextualize default factory
manager", ce );
  -            }
  +            throw new ConfigurationException( "cannot contextualize default factory manager",
ce );
           }
   
  -        targetFactoryManager.configure( configuration );
  +        ContainerUtil.configure( targetFactoryManager, configuration );
   
           return targetFactoryManager;
       }
  @@ -276,20 +276,14 @@
       {
           final DefaultLogTargetManager targetManager = new DefaultLogTargetManager();
   
  -        if( targetManager instanceof LogEnabled )
  -        {
  -            targetManager.enableLogging( m_logger );
  -        }
  +        ContainerUtil.enableLogging( targetManager, m_logger );
   
           if( targetManager instanceof LogTargetFactoryManageable )
           {
               targetManager.setLogTargetFactoryManager( targetFactoryManager );
           }
   
  -        if( targetManager instanceof Configurable )
  -        {
  -            targetManager.configure( configuration );
  -        }
  +        ContainerUtil.configure( targetManager, configuration );
   
           return targetManager;
       }
  @@ -330,18 +324,21 @@
       /**
        * Setup Loggers
        *
  -     * @param categories []  The array object of configurations for categories.
  +\     * @param categories []  The array object of configurations for categories.
        * @throws ConfigurationException if the configuration is malformed
        */
       private final void setupLoggers( final LogTargetManager targetManager,
                                        final String parentCategory,
  -                                     final Configuration[] categories )
  +                                     final Configuration[] categories,
  +                                     final boolean defaultAdditive )
           throws ConfigurationException
       {
           for( int i = 0; i < categories.length; i++ )
           {
               final String category = categories[ i ].getAttribute( "name" );
               final String loglevel = categories[ i ].getAttribute( "log-level" ).toUpperCase();
  +            final boolean additive = categories[i].getAttributeAsBoolean( "additive",
  +                                                                          defaultAdditive
);
   
               final Configuration[] targets = categories[ i ].getChildren( "log-target" );
               final LogTarget[] logTargets = new LogTarget[ targets.length ];
  @@ -367,11 +364,12 @@
               }
               logger.setPriority( Priority.getPriorityForName( loglevel ) );
               logger.setLogTargets( logTargets );
  +            logger.setAdditivity( additive );
   
               final Configuration[] subCategories = categories[ i ].getChildren( "category"
);
               if( null != subCategories )
               {
  -                setupLoggers( targetManager, fullCategory, subCategories );
  +                setupLoggers( targetManager, fullCategory, subCategories, defaultAdditive
);
               }
           }
       }
  
  
  

--
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