avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leosu...@apache.org
Subject cvs commit: avalon-logkit/src/java/org/apache/log/output/io/rotate RotateStrategyBySize.java
Date Thu, 06 Feb 2003 12:13:50 GMT
leosutic    2003/02/06 04:13:50

  Modified:    src/java/org/apache/log/output/io/rotate
                        RotateStrategyBySize.java
  Log:
  Changes to remove the self-resetting behavior. The strategy did a reset on
  itself when it returned true from the isRotationNeeded() method - it didn't
  wait for a reset().
  
  Also added some Javadoc explaining the known problems with the class.
  
  A possible solution to the problem is to set m_currentSize to file.length() if
  m_currentSize == 0 in the isRotationNeeded method, or by reset()-ing to the
  size of the last message, but at the time I don't want to do such changes to
  the code as we have a release coming up.
  
  Revision  Changes    Path
  1.11      +14 -12    avalon-logkit/src/java/org/apache/log/output/io/rotate/RotateStrategyBySize.java
  
  Index: RotateStrategyBySize.java
  ===================================================================
  RCS file: /home/cvs/avalon-logkit/src/java/org/apache/log/output/io/rotate/RotateStrategyBySize.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- RotateStrategyBySize.java	5 Feb 2003 09:56:53 -0000	1.10
  +++ RotateStrategyBySize.java	6 Feb 2003 12:13:50 -0000	1.11
  @@ -57,8 +57,17 @@
   import java.io.File;
   
   /**
  - * Rotation stragety based on size written to log file.
  + * Rotation strategy based on size written to log file.
  + * The strategy will signal that a rotation is needed if the
  + * size goes above a set limit. Due to performance reasons
  + * the limit is not strictly enforced, however, the strategy has
  + * at most an error of the longest single data message written to the
  + * logging system. The error will occur immediately after a rotation,
  + * when the strategy is reset and the data that triggered the
  + * rotation is written. The strategy's internal counter will then
  + * be off with data.length() bytes.
    *
  + * @author <a href="mailto:leo.sutic@inspireinfrastructure.com">Leo Sutic</a>
    * @author <a href="mailto:bh22351@i-one.at">Bernhard Huber</a>
    */
   public class RotateStrategyBySize
  @@ -88,7 +97,7 @@
       }
   
       /**
  -     * reset log size written so far.
  +     * Reset log size written so far.
        */
       public void reset()
       {
  @@ -98,22 +107,15 @@
       /**
        *  Check if now a log rotation is neccessary.
        *
  -     *  @param data the last message written to the log system
  +     *  @param data the message about to be written to the log system
        *  @return boolean return true if log rotation is neccessary, else false
        *  @param file not used
        */
       public boolean isRotationNeeded( final String data, final File file )
       {
  -        if( m_currentSize >= m_maxSize )
  -        {
  -            m_currentSize = data.length();
  -            return true;
  -        }
  -        else
  -        {
           m_currentSize += data.length();
  -            return false;
  -        }
  +        
  +        return m_currentSize >= m_maxSize;
       }
   }
   
  
  
  

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


Mime
View raw message