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/main/org/apache/tools/ant/taskdefs/exec LogOutputStream.java
Date Sun, 30 Dec 2001 00:03:24 GMT
donaldp     01/12/29 16:03:24

  Modified:    proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec
                        LogOutputStream.java
  Log:
  Update so that LogOutputStream takes a logger and boolean indicating what log level should
be logged at.
  
  Revision  Changes    Path
  1.5       +27 -14    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/LogOutputStream.java
  
  Index: LogOutputStream.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/LogOutputStream.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- LogOutputStream.java	23 Dec 2001 06:34:23 -0000	1.4
  +++ LogOutputStream.java	30 Dec 2001 00:03:24 -0000	1.5
  @@ -10,6 +10,8 @@
   import java.io.ByteArrayOutputStream;
   import java.io.IOException;
   import java.io.OutputStream;
  +import org.apache.avalon.framework.logger.Logger;
  +import org.apache.tools.ant.Project;
   import org.apache.tools.ant.Task;
   
   /**
  @@ -23,22 +25,21 @@
   public class LogOutputStream
       extends OutputStream
   {
  -    private final int m_level;
  -    private final Task m_task;
  +    private final boolean m_isError;
  +    private final Logger m_logger;
   
       private ByteArrayOutputStream m_buffer = new ByteArrayOutputStream();
       private boolean m_skip;
   
  -    /**
  -     * Creates a new instance of this class.
  -     *
  -     * @param task the task for whom to log
  -     * @param level loglevel used to log data written to this stream.
  -     */
  -    public LogOutputStream( final Task task, final int level )
  +    public LogOutputStream( final Logger logger, final boolean isError )
       {
  -        m_task = task;
  -        m_level = level;
  +        m_logger = logger;
  +        m_isError = isError;
  +    }
  +
  +    protected final Logger getLogger()
  +    {
  +        return m_logger;
       }
   
       /**
  @@ -86,7 +87,7 @@
        */
       private void processBuffer()
       {
  -        processLine( m_buffer.toString(), m_level );
  +        processLine( m_buffer.toString() );
           m_buffer.reset();
       }
   
  @@ -96,8 +97,20 @@
        * @param line the line to log.
        * @param level Description of Parameter
        */
  -    protected void processLine( String line, int level )
  +    protected void processLine( final String line )
  +    {
  +        if( m_isError )
  +        {
  +            getLogger().warn( line );
  +        }
  +        else
  +        {
  +            getLogger().info( line );
  +        }
  +    }
  +
  +    public boolean isError()
       {
  -        m_task.log( line, level );
  +        return m_isError;
       }
   }
  
  
  

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