avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: jakarta-avalon-logkit/src/java/org/apache/log/output/io FileTarget.java
Date Thu, 21 Feb 2002 15:07:03 GMT
colus       02/02/21 07:07:03

  Modified:    src/java/org/apache/log/output/io/rotate
                        RotatingFileTarget.java
               src/java/org/apache/log/output/io FileTarget.java
  Log:
  Fixed bug.
  Rotation check before writing.
  
  Revision  Changes    Path
  1.10      +10 -8     jakarta-avalon-logkit/src/java/org/apache/log/output/io/rotate/RotatingFileTarget.java
  
  Index: RotatingFileTarget.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/io/rotate/RotatingFileTarget.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- RotatingFileTarget.java	21 Feb 2002 11:21:58 -0000	1.9
  +++ RotatingFileTarget.java	21 Feb 2002 15:07:03 -0000	1.10
  @@ -23,6 +23,9 @@
   public class RotatingFileTarget
       extends FileTarget
   {
  +    ///Flag indicating whether or not file should be appended to
  +    private boolean             m_append;
  +
       ///The rotation strategy to be used.
       private RotateStrategy      m_rotateStrategy;
   
  @@ -47,7 +50,7 @@
       /**
        * Construct RotatingFileTarget object.
        *
  -     * @param append true if file is to be appended to, false otherwise     *
  +     * @param append true if file is to be appended to, false otherwise
        * @param formatter Formatter to be used
        * @param rotateStrategy RotateStrategy to be used
        * @param fileStrategy FileStrategy to be used
  @@ -60,6 +63,7 @@
       {
           super( null, append, formatter );
   
  +        m_append = append;
           m_rotateStrategy = rotateStrategy;
           m_fileStrategy = fileStrategy;
   
  @@ -72,7 +76,7 @@
           close();
   
           final File file = m_fileStrategy.nextFile();
  -        setFile( file );
  +        setFile( file, m_append );
           openFile();
       }
   
  @@ -81,13 +85,8 @@
        */
       protected synchronized void write( final String data )
       {
  -        // write the log message
  -        super.write( data );
  -
           // if rotation is needed, close old File, create new File
  -        final boolean rotate =
  -            m_rotateStrategy.isRotationNeeded( data, getFile() );
  -        if( rotate )
  +        if( m_rotateStrategy.isRotationNeeded( data, getFile() ) )
           {
               try { rotate(); }
               catch( final IOException ioe )
  @@ -95,6 +94,9 @@
                   getErrorHandler().error( "Error rotating file", ioe, null );
               }
           }
  +
  +        // write the log message
  +        super.write( data );
       }
   }
   
  
  
  
  1.10      +0 -12     jakarta-avalon-logkit/src/java/org/apache/log/output/io/FileTarget.java
  
  Index: FileTarget.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/io/FileTarget.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- FileTarget.java	21 Feb 2002 11:21:58 -0000	1.9
  +++ FileTarget.java	21 Feb 2002 15:07:03 -0000	1.10
  @@ -50,18 +50,6 @@
        * Set the file for this target.
        *
        * @param file the file to write to
  -     * @exception IOException if directories can not be created or file can not be opened
  -     */
  -    protected void setFile( final File file )
  -        throws IOException
  -    {
  -        setFile( file, m_append );
  -    }
  -
  -    /**
  -     * Set the file for this target.
  -     *
  -     * @param file the file to write to
        * @param append true if file is to be appended to, false otherwise
        * @exception IOException if directories can not be created or file can not be opened
        */
  
  
  

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


Mime
View raw message