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/myrmidon/components/workspace DefaultTaskContext.java
Date Tue, 12 Mar 2002 08:41:38 GMT
donaldp     02/03/12 00:41:37

  Modified:    proposal/myrmidon/src/java/org/apache/myrmidon/api
                        TaskContext.java LogLevel.java
               proposal/myrmidon/src/java/org/apache/antlib/core Log.java
               proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace
                        DefaultTaskContext.java
  Log:
  Move the generic log() methods back into LogLevel. The reason for this is to remove yet
another Avalon dependency from the api package.
  
  I also think that usage of the log() methods except in really rare circumstances leads to
poor programming idioms. Hopefully there will only be a handful of tasks that use it (like
<log/>) and thus it is not universal enough to be in the TaskContext.
  
  Revision  Changes    Path
  1.25      +1 -18     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/api/TaskContext.java
  
  Index: TaskContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/api/TaskContext.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- TaskContext.java	11 Mar 2002 08:41:32 -0000	1.24
  +++ TaskContext.java	12 Mar 2002 08:41:37 -0000	1.25
  @@ -17,7 +17,7 @@
    * Unlike other APIs the Logging is provided through another interface (LogEnabled).
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.24 $ $Date: 2002/03/11 08:41:32 $
  + * @version $Revision: 1.25 $ $Date: 2002/03/12 08:41:37 $
    */
   public interface TaskContext
   {
  @@ -99,23 +99,6 @@
        */
       void setProperty( String name, Object value )
           throws TaskException;
  -
  -    /**
  -     * Log a message.
  -     *
  -     * @param level the level to write the log message at.
  -     * @param message the message to write.
  -     */
  -    void log( LogLevel level, String message );
  -
  -    /**
  -     * Log a message.
  -     *
  -     * @param level the level to write the log message at.
  -     * @param message the message to write.
  -     * @param throwable the throwable
  -     */
  -    void log( LogLevel level, String message, Throwable throwable );
   
       /**
        * Log a debug message.
  
  
  
  1.2       +59 -1     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/api/LogLevel.java
  
  Index: LogLevel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/api/LogLevel.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LogLevel.java	11 Mar 2002 08:41:32 -0000	1.1
  +++ LogLevel.java	12 Mar 2002 08:41:37 -0000	1.2
  @@ -16,7 +16,7 @@
    * for using enum to write to logger.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.1 $ $Date: 2002/03/11 08:41:32 $
  + * @version $Revision: 1.2 $ $Date: 2002/03/12 08:41:37 $
    */
   public final class LogLevel
       extends Enum
  @@ -51,6 +51,64 @@
       {
           final Set keys = c_levels.keySet();
           return (String[])keys.toArray( new String[ keys.size() ] );
  +    }
  +
  +    /**
  +     * Log a message.
  +     *
  +     * @param level the level to write the log message at.
  +     * @param message the message to write.
  +     */
  +    public static void log( final TaskContext context,
  +                            final LogLevel level,
  +                            final String message )
  +    {
  +        if( LogLevel.ERROR == level )
  +        {
  +            context.error( message );
  +        }
  +        else if( LogLevel.WARN == level )
  +        {
  +            context.warn( message );
  +        }
  +        else if( LogLevel.INFO == level )
  +        {
  +            context.info( message );
  +        }
  +        else
  +        {
  +            context.debug( message );
  +        }
  +    }
  +
  +    /**
  +     * Log a message.
  +     *
  +     * @param level the level to write the log message at.
  +     * @param message the message to write.
  +     * @param throwable the throwable.
  +     */
  +    public static void log( final TaskContext context,
  +                            final LogLevel level,
  +                            final String message,
  +                            final Throwable throwable )
  +    {
  +        if( LogLevel.ERROR == level )
  +        {
  +            context.error( message, throwable );
  +        }
  +        else if( LogLevel.WARN == level )
  +        {
  +            context.warn( message, throwable );
  +        }
  +        else if( LogLevel.INFO == level )
  +        {
  +            context.info( message, throwable );
  +        }
  +        else
  +        {
  +            context.debug( message, throwable );
  +        }
       }
   
       /**
  
  
  
  1.10      +1 -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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Log.java	11 Mar 2002 08:41:31 -0000	1.9
  +++ Log.java	12 Mar 2002 08:41:37 -0000	1.10
  @@ -65,7 +65,7 @@
       public void execute()
           throws TaskException
       {
  -        getContext().log( m_level, m_message );
  +        LogLevel.log( getContext(), m_level, m_message );
       }
   
       /**
  
  
  
  1.23      +2 -64     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java
  
  Index: DefaultTaskContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- DefaultTaskContext.java	12 Mar 2002 08:25:02 -0000	1.22
  +++ DefaultTaskContext.java	12 Mar 2002 08:41:37 -0000	1.23
  @@ -18,7 +18,6 @@
   import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.framework.service.ServiceException;
   import org.apache.avalon.framework.service.ServiceManager;
  -import org.apache.myrmidon.api.LogLevel;
   import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.interfaces.model.DefaultNameValidator;
  @@ -28,7 +27,7 @@
    * Default implementation of TaskContext.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.22 $ $Date: 2002/03/12 08:25:02 $
  + * @version $Revision: 1.23 $ $Date: 2002/03/12 08:41:37 $
    */
   public class DefaultTaskContext
       implements TaskContext, Context
  @@ -38,6 +37,7 @@
   
       // Property name validator allows digits, but no internal whitespace.
       private static DefaultNameValidator m_propertyNameValidator = new DefaultNameValidator();
  +
       static
       {
           m_propertyNameValidator.setAllowInternalWhitespace( false );
  @@ -146,7 +146,6 @@
       public Object resolveValue( final String value )
           throws TaskException
       {
  -
           try
           {
               // Lazy lookup of the PropertyResolver
  @@ -211,67 +210,6 @@
           checkPropertyName( name );
           checkPropertyValid( name, value );
           m_contextData.put( name, value );
  -    }
  -
  -    /**
  -     * Log a message.
  -     *
  -     * @param level the level to write the log message at.
  -     * @param message the message to write.
  -     */
  -    public void log( LogLevel level, String message )
  -    {
  -        if( LogLevel.FATAL_ERROR == level )
  -        {
  -            m_logger.fatalError( message );
  -        }
  -        else if( LogLevel.ERROR == level )
  -        {
  -            m_logger.error( message );
  -        }
  -        else if( LogLevel.WARN == level )
  -        {
  -            m_logger.warn( message );
  -        }
  -        else if( LogLevel.INFO == level )
  -        {
  -            m_logger.info( message );
  -        }
  -        else
  -        {
  -            m_logger.debug( message );
  -        }
  -    }
  -
  -    /**
  -     * Log a message.
  -     *
  -     * @param level the level to write the log message at.
  -     * @param message the message to write.
  -     * @param throwable the throwable.
  -     */
  -    public void log( LogLevel level, String message, Throwable throwable )
  -    {
  -        if( LogLevel.FATAL_ERROR == level )
  -        {
  -            m_logger.fatalError( message, throwable );
  -        }
  -        else if( LogLevel.ERROR == level )
  -        {
  -            m_logger.error( message, throwable );
  -        }
  -        else if( LogLevel.WARN == level )
  -        {
  -            m_logger.warn( message, throwable );
  -        }
  -        else if( LogLevel.INFO == level )
  -        {
  -            m_logger.info( message, throwable );
  -        }
  -        else
  -        {
  -            m_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