com.caucho.log
Class AbstractRolloverLog

java.lang.Object
  extended by com.caucho.log.AbstractRolloverLog
Direct Known Subclasses:
AccessLogWriter

public class AbstractRolloverLog
extends java.lang.Object

Abstract class for a log that rolls over based on size or period.


Field Summary
protected  Path _path
           
protected  java.lang.String _pathFormat
           
protected static L10N L
           
 
Constructor Summary
AbstractRolloverLog()
           
 
Method Summary
 void close()
          Closes the log, flushing the results.
protected  void flush()
          Writes to the underlying log.
protected  void flushStream()
           
 java.lang.String getArchiveFormat()
          Sets the archive name format
protected  Path getArchivePath(long time)
          Returns the name of the archived file
protected  java.lang.String getFormatName(java.lang.String format, long time)
          Returns the name of the archived file
 long getNextRolloverCheckTime()
           
 Path getPath()
          Returns the access-log's path.
protected  Path getPath(long time)
          Returns the path of the format file
 java.lang.String getPathFormat()
          Returns the formatted path
 Path getPwd()
          Returns the pwd for the rollover log
 long getRolloverCheckPeriod()
          Sets how often the log rollover will be checked.
 long getRolloverPeriod()
          Sets the log rollover period, rounded up to the nearest hour.
 long getRolloverSize()
          Sets the log rollover size, rounded up to the megabyte.
 void init()
          Initialize the log.
 boolean isRollover()
           
 boolean rollover()
           
protected  void rolloverLog()
          Check to see if we need to rollover the log.
 void setArchiveFormat(java.lang.String format)
          Sets the archive name format
 void setLastTime(long lastTime)
           
 void setPath(Path path)
          Sets the access-log's path.
 void setPathFormat(java.lang.String pathFormat)
          Sets the formatted path.
 void setRolloverCheckPeriod(long period)
          Sets how often the log rollover will be checked.
 void setRolloverCount(int count)
          Sets the max rollover files.
 void setRolloverCron(CronType cron)
          Sets the log rollover cron specification
 void setRolloverPeriod(Period period)
          Sets the log rollover period, rounded up to the nearest hour.
 void setRolloverSize(Bytes bytes)
          Sets the log rollover size, rounded up to the megabyte.
 void setRolloverSizeBytes(long size)
           
protected  void write(byte[] buffer, int offset, int length)
          Writes to the underlying log.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

L

protected static final L10N L

_path

protected Path _path

_pathFormat

protected java.lang.String _pathFormat
Constructor Detail

AbstractRolloverLog

public AbstractRolloverLog()
Method Detail

getPath

public Path getPath()
Returns the access-log's path.


setPath

public void setPath(Path path)
Sets the access-log's path.


getPwd

public Path getPwd()
Returns the pwd for the rollover log


getPathFormat

public java.lang.String getPathFormat()
Returns the formatted path


setPathFormat

public void setPathFormat(java.lang.String pathFormat)
                   throws ConfigException
Sets the formatted path.

Throws:
ConfigException

setArchiveFormat

public void setArchiveFormat(java.lang.String format)
Sets the archive name format


getArchiveFormat

public java.lang.String getArchiveFormat()
Sets the archive name format


setRolloverCron

public void setRolloverCron(CronType cron)
Sets the log rollover cron specification


setRolloverPeriod

public void setRolloverPeriod(Period period)
Sets the log rollover period, rounded up to the nearest hour.

Parameters:
period - the new rollover period in milliseconds.

getRolloverPeriod

public long getRolloverPeriod()
Sets the log rollover period, rounded up to the nearest hour.

Returns:
the new period in milliseconds.

setRolloverSize

public void setRolloverSize(Bytes bytes)
Sets the log rollover size, rounded up to the megabyte.

Parameters:
bytes - maximum size of the log file

setRolloverSizeBytes

public void setRolloverSizeBytes(long size)

getRolloverSize

public long getRolloverSize()
Sets the log rollover size, rounded up to the megabyte.

Returns:
maximum size of the log file

setRolloverCheckPeriod

public void setRolloverCheckPeriod(long period)
Sets how often the log rollover will be checked.

Parameters:
period - how often the log rollover will be checked.

getRolloverCheckPeriod

public long getRolloverCheckPeriod()
Sets how often the log rollover will be checked.

Returns:
how often the log rollover will be checked.

setRolloverCount

public void setRolloverCount(int count)
Sets the max rollover files.


setLastTime

public void setLastTime(long lastTime)

init

public void init()
          throws java.io.IOException
Initialize the log.

Throws:
java.io.IOException

getNextRolloverCheckTime

public long getNextRolloverCheckTime()

isRollover

public boolean isRollover()

rollover

public boolean rollover()

write

protected void write(byte[] buffer,
                     int offset,
                     int length)
              throws java.io.IOException
Writes to the underlying log.

Throws:
java.io.IOException

flush

protected void flush()
              throws java.io.IOException
Writes to the underlying log.

Throws:
java.io.IOException

flushStream

protected void flushStream()
                    throws java.io.IOException
Throws:
java.io.IOException

rolloverLog

protected void rolloverLog()
Check to see if we need to rollover the log.

Parameters:
now - current time in milliseconds.

getPath

protected Path getPath(long time)
Returns the path of the format file

Parameters:
time - the archive date

getArchivePath

protected Path getArchivePath(long time)
Returns the name of the archived file

Parameters:
time - the archive date

getFormatName

protected java.lang.String getFormatName(java.lang.String format,
                                         long time)
Returns the name of the archived file

Parameters:
time - the archive date

close

public void close()
           throws java.io.IOException
Closes the log, flushing the results.

Throws:
java.io.IOException