avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: avalon-excalibur/logger/src/java/org/apache/avalon/excalibur/logger LogKitLoggerManager.java
Date Tue, 27 May 2003 07:40:10 GMT
donaldp     2003/05/27 00:40:10

  Modified:    logger/src/java/org/apache/avalon/excalibur/logger
                        LogKitLoggerManager.java
  Log:
  Made disposable close the log targets
  
  based on a patch by  Mauro Talevi <mauro.talevi@aquilonia.org>
  
  Revision  Changes    Path
  1.16      +30 -4     avalon-excalibur/logger/src/java/org/apache/avalon/excalibur/logger/LogKitLoggerManager.java
  
  Index: LogKitLoggerManager.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/logger/src/java/org/apache/avalon/excalibur/logger/LogKitLoggerManager.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- LogKitLoggerManager.java	27 May 2003 07:30:27 -0000	1.15
  +++ LogKitLoggerManager.java	27 May 2003 07:40:10 -0000	1.16
  @@ -50,7 +50,11 @@
   package org.apache.avalon.excalibur.logger;
   
   import java.util.HashMap;
  +import java.util.HashSet;
  +import java.util.Iterator;
   import java.util.Map;
  +import java.util.Set;
  +import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  @@ -64,6 +68,7 @@
   import org.apache.log.Hierarchy;
   import org.apache.log.LogTarget;
   import org.apache.log.Priority;
  +import org.apache.log.util.Closeable;
   
   /**
    * LogKitLoggerManager implementation.  It populates the LoggerManager
  @@ -76,11 +81,14 @@
    * @since 4.0
    */
   public class LogKitLoggerManager
  -    implements LoggerManager, LogEnabled, Contextualizable, Configurable
  +    implements LoggerManager, LogEnabled, Contextualizable, Configurable, Disposable
   {
       /** Map for name to logger mapping */
       final private Map m_loggers = new HashMap();
   
  +    /** Set of log targets */
  +    final private Set m_targets = new HashSet();
  +
       /** The context object */
       private Context m_context;
   
  @@ -337,8 +345,8 @@
           {
               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 boolean additive = categories[ i ].
  +                getAttributeAsBoolean( "additive", defaultAdditive );
   
               final Configuration[] targets = categories[ i ].getChildren( "log-target" );
               final LogTarget[] logTargets = new LogTarget[ targets.length ];
  @@ -346,6 +354,10 @@
               {
                   final String id = targets[ j ].getAttribute( "id-ref" );
                   logTargets[ j ] = targetManager.getLogTarget( id );
  +                if( !m_targets.contains( logTargets[ j ] ) )
  +                {
  +                    m_targets.add( logTargets[ j ] );
  +                }
               }
   
               if( "".equals( category ) && logTargets.length > 0 )
  @@ -371,6 +383,20 @@
               {
                   setupLoggers( targetManager, fullCategory, subCategories, defaultAdditive
);
               }
  +        }
  +    }
  +
  +    public void dispose()
  +    {
  +        final Iterator iterator = m_targets.iterator();
  +        while( iterator.hasNext() )
  +        {
  +            final LogTarget target = (LogTarget)iterator.next();
  +            if( target instanceof Closeable )
  +            {
  +                ( (Closeable)target ).close();
  +            }
  +
           }
       }
   }
  
  
  

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


Mime
View raw message