ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/core Log.java LogLevel.java
Date Sun, 13 Jan 2002 04:50:48 GMT
donaldp     02/01/12 20:50:48

  Modified:    proposal/myrmidon/src/java/org/apache/antlib/core Log.java
                        LogLevel.java
  Log:
  Refactor log() to level into LogLevel class.
  
  Revision  Changes    Path
  1.7       +1 -20     jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/core/Log.java
  
  Index: Log.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/core/Log.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Log.java	13 Jan 2002 00:02:11 -0000	1.6
  +++ Log.java	13 Jan 2002 04:50:48 -0000	1.7
  @@ -63,26 +63,7 @@
       public void execute()
           throws TaskException
       {
  -        if( LogLevel.FATAL_ERROR == m_level )
  -        {
  -            getLogger().fatalError( m_message );
  -        }
  -        else if( LogLevel.ERROR == m_level )
  -        {
  -            getLogger().error( m_message );
  -        }
  -        else if( LogLevel.WARN == m_level )
  -        {
  -            getLogger().warn( m_message );
  -        }
  -        else if( LogLevel.INFO == m_level )
  -        {
  -            getLogger().info( m_message );
  -        }
  -        else
  -        {
  -            getLogger().debug( m_message );
  -        }
  +        LogLevel.log( getLogger(), m_message, m_level );
       }
   
       /**
  
  
  
  1.3       +62 -1     jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/core/LogLevel.java
  
  Index: LogLevel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/core/LogLevel.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LogLevel.java	1 Jan 2002 06:16:24 -0000	1.2
  +++ LogLevel.java	13 Jan 2002 04:50:48 -0000	1.3
  @@ -10,9 +10,11 @@
   import java.util.HashMap;
   import java.util.Set;
   import org.apache.avalon.framework.Enum;
  +import org.apache.avalon.framework.logger.Logger;
   
   /**
  - * Type safe Enum for Log Levels.
  + * Type safe Enum for Log Levels and utility method
  + * for using enum to write to logger.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    */
  @@ -49,6 +51,65 @@
       {
           final Set keys = c_levels.keySet();
           return (String[])keys.toArray( new String[ keys.size() ] );
  +    }
  +
  +    /**
  +     * Log a message to the Logger at the specified level.
  +     */
  +    public static void log( final Logger logger,
  +                            final String message,
  +                            final LogLevel level )
  +    {
  +        if( LogLevel.FATAL_ERROR == level )
  +        {
  +            logger.fatalError( message );
  +        }
  +        else if( LogLevel.ERROR == level )
  +        {
  +            logger.error( message );
  +        }
  +        else if( LogLevel.WARN == level )
  +        {
  +            logger.warn( message );
  +        }
  +        else if( LogLevel.INFO == level )
  +        {
  +            logger.info( message );
  +        }
  +        else
  +        {
  +            logger.debug( message );
  +        }
  +    }
  +
  +    /**
  +     * Log a message to the Logger at the specified level.
  +     */
  +    public static void log( final Logger logger,
  +                            final String message,
  +                            final Throwable throwable,
  +                            final LogLevel level )
  +    {
  +        if( LogLevel.FATAL_ERROR == level )
  +        {
  +            logger.fatalError( message, throwable );
  +        }
  +        else if( LogLevel.ERROR == level )
  +        {
  +            logger.error( message, throwable );
  +        }
  +        else if( LogLevel.WARN == level )
  +        {
  +            logger.warn( message, throwable );
  +        }
  +        else if( LogLevel.INFO == level )
  +        {
  +            logger.info( message, throwable );
  +        }
  +        else
  +        {
  +            logger.debug( message, throwable );
  +        }
       }
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message