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
Date Sat, 29 Dec 2001 21:28:04 GMT
donaldp     01/12/29 13:28:04

  Modified:    proposal/myrmidon/src/java/org/apache/antlib/core Log.java
  Log:
  Update Log class so that it takes enums to specify the level.
  
  Revision  Changes    Path
  1.5       +50 -1     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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Log.java	23 Dec 2001 14:25:01 -0000	1.4
  +++ Log.java	29 Dec 2001 21:28:04 -0000	1.5
  @@ -18,26 +18,75 @@
   public class Log
       extends AbstractTask
   {
  +    /**
  +     * The message to printout when logging
  +     */
       private String m_message;
   
  +    /**
  +     * The level at which to print out messages.
  +     */
  +    private LogLevel m_level = LogLevel.WARN;
  +
  +    /**
  +     * Set the level at which the message will be logged.
  +     *
  +     * @param the level at which message will be logged
  +     */
  +    public void setLevel( final LogLevel level )
  +    {
  +        m_level = level;
  +    }
  +
  +    /**
  +     * Set the message to print out when logging message
  +     */
       public void setMessage( final String message )
       {
           checkNullMessage();
           m_message = message;
       }
   
  +    /**
  +     * Set the message to print out when logging message
  +     */
       public void addContent( final String message )
       {
           checkNullMessage();
           m_message = message;
       }
   
  +    /**
  +     * Log message at specified level.
  +     */
       public void execute()
           throws TaskException
       {
  -        getLogger().warn( m_message );
  +        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 );
  +        }
       }
   
  +    /**
  +     * Utility message to verify that the message has not already been set.
  +     */
       private void checkNullMessage()
       {
           if( null != m_message )
  
  
  

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