avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine/facilities/log AvalonLogFormatter.java DefaultLogManager.java
Date Mon, 16 Apr 2001 08:01:41 GMT
donaldp     01/04/16 01:01:41

  Modified:    src/java/org/apache/phoenix/engine/facilities
                        LogManager.java
               src/java/org/apache/phoenix/engine/facilities/log
                        DefaultLogManager.java
  Added:       src/java/org/apache/phoenix/engine/facilities/log
                        AvalonLogFormatter.java
  Log:
  added method to LogManager to get Loggers by name.
  
  Also transfered AvalonLogFormatter to this CVS.
  
  Revision  Changes    Path
  1.2       +9 -1      jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine/facilities/LogManager.java
  
  Index: LogManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine/facilities/LogManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LogManager.java	2001/04/15 13:55:40	1.1
  +++ LogManager.java	2001/04/16 08:01:40	1.2
  @@ -8,6 +8,7 @@
   package org.apache.phoenix.engine.facilities;
   
   import org.apache.avalon.atlantis.Facility;
  +import org.apache.log.Logger;
   
   /**
    * This facility manages the logs for an application instance.
  @@ -17,5 +18,12 @@
   public interface LogManager
       extends Facility
   {
  -    //TODO: Provide some extra functionality here
  +    /**
  +     * Get logger with category for application.
  +     * Note that this name may not be the absolute category.
  +     *
  +     * @param category the logger category
  +     * @return the Logger
  +     */
  +    Logger getLogger( String category );
   }
  
  
  
  1.2       +28 -5     jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine/facilities/log/DefaultLogManager.java
  
  Index: DefaultLogManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine/facilities/log/DefaultLogManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultLogManager.java	2001/04/15 13:54:39	1.1
  +++ DefaultLogManager.java	2001/04/16 08:01:40	1.2
  @@ -16,10 +16,10 @@
   import org.apache.avalon.configuration.Configurable;
   import org.apache.avalon.configuration.Configuration;
   import org.apache.avalon.configuration.ConfigurationException;
  -import org.apache.avalon.util.log.AvalonLogFormatter;
   import org.apache.log.Category;
   import org.apache.log.LogKit;
   import org.apache.log.LogTarget;
  +import org.apache.log.Logger;
   import org.apache.log.output.FileOutputLogTarget;
   import org.apache.phoenix.engine.facilities.LogManager;
   
  @@ -60,9 +60,32 @@
           */
       }
   
  -    protected void configureTargets( final String baseName,
  -                                     final File baseDirectory,
  -                                     final Configuration[] targets )
  +    /**
  +     * Get logger with category for application.
  +     * Note that this name may not be the absolute category.
  +     *
  +     * @param category the logger category
  +     * @return the Logger
  +     */
  +    public Logger getLogger( final String category )
  +    {
  +        String name = null;
  +
  +        if( category.trim().equals( "" ) )
  +        {
  +            name = m_baseName;
  +        }
  +        else
  +        {
  +            name = m_baseName + '.' + category;
  +        }
  +
  +        return LogKit.getLoggerFor( name );
  +    }
  +
  +    private void configureTargets( final String baseName,
  +                                   final File baseDirectory,
  +                                   final Configuration[] targets )
           throws ConfigurationException
       {
           for( int i = 0; i < targets.length; i++ )
  @@ -100,7 +123,7 @@
           }
       }
   
  -    protected void configureCategories( final String baseName, final Configuration[] categories
)
  +    private void configureCategories( final String baseName, final Configuration[] categories
)
           throws ConfigurationException
       {
           for( int i = 0; i < categories.length; i++ )
  
  
  
  1.1                  jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine/facilities/log/AvalonLogFormatter.java
  
  Index: AvalonLogFormatter.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  package org.apache.phoenix.engine.facilities.log;
  
  import java.util.Date;
  import org.apache.avalon.util.StringUtil;
  import org.apache.log.format.PatternFormatter;
  
  /**
   * Specialized formatter that knows about CascadingThrowables.
   *
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   */
  public class AvalonLogFormatter
      extends PatternFormatter
  {
      protected String getStackTrace( final Throwable throwable, final String format )
      {
          if( null == throwable ) return "";
          return StringUtil.printStackTrace( throwable, 8, true );
      }
  
      /**
       * Utility method to format time.
       *
       * @param time the time
       * @param format ancilliary format parameter - allowed to be null
       * @return the formatted string
       */
      protected String getTime( final long time, final String format )
      {
          return new Date().toString();
      }
  }
  
  
  

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


Mime
View raw message