You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by le...@apache.org on 2003/04/11 22:19:38 UTC

cvs commit: avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/logging DefaultLoggingManager.java package.html

leosimons    2003/04/11 13:19:38

  Modified:    merlin/assembly/src/java/org/apache/avalon/assembly/logging
                        DefaultLoggingManager.java package.html
  Log:
  formatting, imports.
  
  Revision  Changes    Path
  1.2       +57 -81    avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/logging/DefaultLoggingManager.java
  
  Index: DefaultLoggingManager.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/logging/DefaultLoggingManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultLoggingManager.java	13 Mar 2003 01:04:21 -0000	1.1
  +++ DefaultLoggingManager.java	11 Apr 2003 20:19:38 -0000	1.2
  @@ -54,40 +54,38 @@
   import java.io.IOException;
   import java.util.HashMap;
   
  -import org.apache.log.Hierarchy;
  -import org.apache.log.LogTarget;
  -import org.apache.log.Logger;
  -import org.apache.log.Priority;
  -import org.apache.log.output.io.FileTarget;
  -import org.apache.log.output.io.StreamTarget;
  -
   import org.apache.avalon.assembly.locator.Contextualizable;
   import org.apache.avalon.assembly.locator.Locator;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.framework.activity.Initializable;
  -import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.logger.AvalonFormatter;
   import org.apache.avalon.framework.logger.LogKitLogger;
  -import org.apache.avalon.meta.model.LoggingDirective;
   import org.apache.avalon.meta.model.Category;
  +import org.apache.avalon.meta.model.LoggingDirective;
  +import org.apache.log.Hierarchy;
  +import org.apache.log.LogTarget;
  +import org.apache.log.Logger;
  +import org.apache.log.Priority;
  +import org.apache.log.output.io.FileTarget;
  +import org.apache.log.output.io.StreamTarget;
   
   /**
  - * A <code>LoggerManager</code> interface declares operation supporting 
  + * A <code>LoggerManager</code> interface declares operation supporting
    * the management of a logging hierarchy.
    *
    * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
    */
   public class DefaultLoggingManager
  -    implements LoggingManager, Initializable, Contextualizable
  +        implements LoggingManager, Initializable, Contextualizable
   {
       //===============================================================
       // static
       //===============================================================
   
       private static final Resources REZ =
  -        ResourceManager.getPackageResources( DefaultLoggingManager.class );
  +            ResourceManager.getPackageResources( DefaultLoggingManager.class );
   
       /**
        * The default logging priority value.
  @@ -100,13 +98,13 @@
       public static final String DEFAULT_TARGET = "default";
   
       private static final String DEFAULT_FORMAT =
  -        "[%7.7{priority}] (%{category}): %{message}\\n%{throwable}";
  +            "[%7.7{priority}] (%{category}): %{message}\\n%{throwable}";
   
       /**
        * The default fallback log target.
        */
  -    private static final StreamTarget DEFAULT_STREAM = 
  -      new StreamTarget( System.out, new AvalonFormatter( DEFAULT_FORMAT ) );
  +    private static final StreamTarget DEFAULT_STREAM =
  +            new StreamTarget( System.out, new AvalonFormatter( DEFAULT_FORMAT ) );
   
   
       //===============================================================
  @@ -142,12 +140,12 @@
       // Contextualizable
       //==============================================================
   
  -   /**
  -    * <p>Application of a runtime context to the lifestyle service.
  -    * The context value will be passed directly to lifestyle handlers 
  -    * established by this service.
  -    * @param context the runtime context
  -    */
  +    /**
  +     * <p>Application of a runtime context to the lifestyle service.
  +     * The context value will be passed directly to lifestyle handlers
  +     * established by this service.
  +     * @param context the runtime context
  +     */
       public void contextualize( Locator context ) throws ContextException
       {
           m_baseDirectory = (File) context.get( "urn:assembly:home" );
  @@ -155,13 +153,12 @@
           try
           {
               m_descriptor = (LoggingDescriptor) context.get( "urn:assembly:logging.descriptor" );
  -        }
  -        catch( ContextException ce )
  +        } catch( ContextException ce )
           {
  -            m_descriptor = 
  -              new LoggingDescriptor(
  -                "", null, null, new TargetDescriptor[ 0 ],
  -                new Category( "logging", "DEBUG", null ) );
  +            m_descriptor =
  +                    new LoggingDescriptor(
  +                            "", null, null, new TargetDescriptor[0],
  +                            new Category( "logging", "DEBUG", null ) );
           }
       }
   
  @@ -191,14 +188,13 @@
           if( m_descriptor.getPriority() != null )
           {
               priority = m_descriptor.getPriority();
  -        }
  -        else
  +        } else
           {
               priority = DEFAULT_PRIORITY;
           }
   
           getHierarchy().setDefaultPriority(
  -            Priority.getPriorityForName( priority )
  +                Priority.getPriorityForName( priority )
           );
   
           //
  @@ -208,7 +204,7 @@
           Category bootstrap = m_descriptor.getBootstrapCategory();
   
           m_logger = new LogKitLogger(
  -          addCategory( bootstrap.getName(), bootstrap.getPriority(), bootstrap.getTarget(), false ) );
  +                addCategory( bootstrap.getName(), bootstrap.getPriority(), bootstrap.getTarget(), false ) );
           m_logger.debug( "setting default priority: " + priority );
   
           //
  @@ -218,7 +214,7 @@
           TargetDescriptor[] targets = m_descriptor.getTargetDescriptors();
           for( int i = 0; i < targets.length; i++ )
           {
  -            addTarget( targets[ i ] );
  +            addTarget( targets[i] );
           }
   
           //
  @@ -228,16 +224,15 @@
           String name = m_descriptor.getTarget();
           if( name != null )
           {
  -            LogTarget target = (LogTarget)m_targets.get( name );
  +            LogTarget target = (LogTarget) m_targets.get( name );
               if( target != null )
               {
                   getHierarchy().setDefaultLogTarget( target );
  -            }
  -            else
  +            } else
               {
                   throw new LoggerException(
  -                  "Supplied default logging target: '" 
  -                  + name + "' does not exist." );
  +                        "Supplied default logging target: '"
  +                        + name + "' does not exist." );
               }
           }
       }
  @@ -264,14 +259,13 @@
           Category[] categories = descriptor.getCategories();
           for( int i = 0; i < categories.length; i++ )
           {
  -            Category category = categories[ i ];
  +            Category category = categories[i];
               final String priority = category.getPriority();
               final String target = category.getTarget();
               if( path.equals( "" ) )
               {
                   addCategory( category.getName(), priority, target );
  -            }
  -            else
  +            } else
               {
                   addCategory( path + "." + category.getName(), priority, target );
               }
  @@ -290,8 +284,8 @@
        * @throws Exception if an error occurs
        */
       public org.apache.avalon.framework.logger.Logger getLoggerForCategory(
  -        final String name, String target, String priority )
  -        throws Exception
  +            final String name, String target, String priority )
  +            throws Exception
       {
           return new LogKitLogger( addCategory( name, target, priority ) );
       }
  @@ -305,14 +299,14 @@
        * @throws Exception if an error occurs
        */
       public org.apache.avalon.framework.logger.Logger getLoggerForCategory( final Category category )
  -        throws Exception
  +            throws Exception
       {
           return new LogKitLogger(
  -            addCategory(
  -                category.getName(),
  -                category.getPriority(),
  -                category.getTarget()
  -            )
  +                addCategory(
  +                        category.getName(),
  +                        category.getPriority(),
  +                        category.getTarget()
  +                )
           );
       }
   
  @@ -330,8 +324,7 @@
           if( category == null )
           {
               return new LogKitLogger( getHierarchy().getLoggerFor( "" ) );
  -        }
  -        else
  +        } else
           {
               String cat = filter( category );
               if( category.indexOf( "/" ) > -1 )
  @@ -341,16 +334,14 @@
                   {
                       cat = cat.substring( 1 );
                   }
  -            }
  -            else
  +            } else
               {
                   cat = category;
               }
               try
               {
                   return new LogKitLogger( getHierarchy().getLoggerFor( cat ) );
  -            }
  -            catch( Throwable e )
  +            } catch( Throwable e )
               {
                   throw new RuntimeException( "Bad category: " + category + " or trans: " + cat );
               }
  @@ -371,18 +362,6 @@
           return m_logger;
       }
   
  -    /**
  -     * Add a single category entries relative to the supplied base category
  -     * path, using the supplied category.
  -     * @param path the category base path
  -     * @param category a category descriptors to be added under the base path
  -     */
  -    private Logger addCategory( String path, Category category )
  -    {
  -        return addCategory(
  -            path, category.getPriority(), category.getTarget(), true );
  -    }
  -
       private Logger addCategory( String path, String priority, String target )
       {
           return addCategory( path, priority, target, true );
  @@ -394,10 +373,9 @@
           final Logger logger;
   
           try
  -        { 
  +        {
               logger = getHierarchy().getLoggerFor( name );
  -        }
  -        catch( Throwable e )
  +        } catch( Throwable e )
           {
               throw new RuntimeException( "Bad category: " + path + " or trans: " + name );
           }
  @@ -415,9 +393,9 @@
   
           if( target != null )
           {
  -            if( !target.equals("default") )
  +            if( !target.equals( "default" ) )
               {
  -                final LogTarget logTarget = (LogTarget)m_targets.get( target );
  +                final LogTarget logTarget = (LogTarget) m_targets.get( target );
                   if( logTarget != null )
                   {
                       logger.setLogTargets( new LogTarget[]{logTarget} );
  @@ -428,7 +406,7 @@
           if( notify && getLogger().isInfoEnabled() )
           {
               final String message =
  -                REZ.getString( "category-create", name, target, priority );
  +                    REZ.getString( "category-create", name, target, priority );
               getLogger().debug( message );
           }
   
  @@ -437,8 +415,8 @@
   
       private String filter( String name )
       {
  -        String path = name.replace('/','.');
  -        if( path.startsWith(".") )
  +        String path = name.replace( '/', '.' );
  +        if( path.startsWith( "." ) )
           {
               path = path.substring( 1 );
               return filter( path );
  @@ -452,7 +430,7 @@
           TargetProvider provider = target.getProvider();
           if( provider instanceof FileTargetProvider )
           {
  -            FileTargetProvider fileProvider = (FileTargetProvider)provider;
  +            FileTargetProvider fileProvider = (FileTargetProvider) provider;
               String filename = fileProvider.getLocation();
               final AvalonFormatter formatter = new AvalonFormatter( DEFAULT_FORMAT );
               File file = new File( m_baseDirectory, filename );
  @@ -460,18 +438,16 @@
               {
                   FileTarget logTarget = new FileTarget( file.getAbsoluteFile(), false, formatter );
                   m_targets.put( name, logTarget );
  -            }
  -            catch( final IOException ioe )
  +            } catch( final IOException ioe )
               {
                   final String message =
  -                    REZ.getString( "target.nocreate", name, file, ioe.getMessage() );
  +                        REZ.getString( "target.nocreate", name, file, ioe.getMessage() );
                   throw new LoggerException( message, ioe );
               }
  -        }
  -        else
  +        } else
           {
               final String error =
  -                "Unrecognized logging provider: " + provider.getClass().getName();
  +                    "Unrecognized logging provider: " + provider.getClass().getName();
               throw new IllegalArgumentException( error );
           }
       }
  
  
  
  1.2       +6 -6      avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/logging/package.html
  
  Index: package.html
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/logging/package.html,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- package.html	13 Mar 2003 01:04:21 -0000	1.1
  +++ package.html	11 Apr 2003 20:19:38 -0000	1.2
  @@ -1,6 +1,6 @@
  -
  -<body>
  -<p>
  -The <code>logging</code> package contains the {@link org.apache.avalon.assembly.logging.DefaultLoggingManager} which is an initial bootstrap logging mananager that uses mata information about logging targets and catagories.  This class is subject to refactoring to bring in into a component model to enable easy specialization and/or replacement.
  -</p>
  -</body>
  +<p>The <code>logging</code> package contains the
  +{@link org.apache.avalon.assembly.logging.DefaultLoggingManager} which
  +is an initial bootstrap logging mananager that uses mata information
  +about logging targets and catagories.  This class is subject to
  +refactoring to bring in into a component model to enable easy
  +specialization and/or replacement.</p>
  
  
  

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