com.caucho.log
Class RotateStream

java.lang.Object
  extended by com.caucho.vfs.StreamImpl
      extended by com.caucho.log.RotateStream

public class RotateStream
extends StreamImpl

Automatically-rotating streams. Normally, clients will call getStream instead of using the StreamImpl interface.


Field Summary
 
Fields inherited from class com.caucho.vfs.StreamImpl
_nullPath, _path
 
Method Summary
 boolean canWrite()
          True if the stream can write
static void clear()
          Clears the streams.
 void close()
          The close call does nothing since the rotate stream is shared for many logs.
static RotateStream create(Path path)
          Returns the rotate stream corresponding to this path
static RotateStream create(java.lang.String path)
          Returns the rotate stream corresponding to this path
 void finalize()
           
 void flush()
          Flushes the underlying stream.
 Path getPath()
          Returns the Path associated with the stream.
 AbstractRolloverLog getRolloverLog()
          Returns the rollover log.
 WriteStream getStream()
          Gets the current write stream
 void init()
          Initialize the stream, setting any logStream, System.out and System.err as necessary.
 void setArchiveFormat(java.lang.String format)
          Sets the archive format.
 void setMaxRolloverCount(int count)
          Sets the maximum number of rolled logs.
 void setRolloverPeriod(long period)
          Sets the log rollover period, rounded up to the nearest hour.
 void setRolloverSize(long size)
          Sets the log rollover size in bytes.
 void write(byte[] buffer, int offset, int length, boolean isEnd)
          Writes to the stream
 
Methods inherited from class com.caucho.vfs.StreamImpl
canRead, clearWrite, closeWrite, flushBuffer, flushToDisk, getAttribute, getAttributeNames, getAvailable, getFlushOnNewline, getNewline, getReadBuffer, getReadPosition, hasSkip, isClosed, isEof, read, readNonBlock, readTimeout, removeAttribute, seekEnd, seekStart, setAttribute, setPath, setWriteEncoding, skip, write
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static RotateStream create(Path path)
Returns the rotate stream corresponding to this path


create

public static RotateStream create(java.lang.String path)
                           throws ConfigException
Returns the rotate stream corresponding to this path

Throws:
ConfigException

clear

public static void clear()
Clears the streams.


getRolloverLog

public AbstractRolloverLog getRolloverLog()
Returns the rollover log.


setMaxRolloverCount

public void setMaxRolloverCount(int count)
Sets the maximum number of rolled logs.


setRolloverPeriod

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

Parameters:
period - the new rollover period in milliseconds.

setRolloverSize

public void setRolloverSize(long size)
Sets the log rollover size in bytes.


setArchiveFormat

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

Parameters:
format - the archive format.

init

public void init()
          throws java.io.IOException
Initialize the stream, setting any logStream, System.out and System.err as necessary.

Throws:
java.io.IOException

getPath

public Path getPath()
Returns the Path associated with the stream.

Overrides:
getPath in class StreamImpl

canWrite

public boolean canWrite()
True if the stream can write

Overrides:
canWrite in class StreamImpl

write

public void write(byte[] buffer,
                  int offset,
                  int length,
                  boolean isEnd)
           throws java.io.IOException
Writes to the stream

Overrides:
write in class StreamImpl
Parameters:
buffer - the byte array to write.
offset - the offset into the byte array.
length - the number of bytes to write.
isEnd - true when the write is flushing a close.
Throws:
java.io.IOException

getStream

public WriteStream getStream()
Gets the current write stream


flush

public void flush()
           throws java.io.IOException
Flushes the underlying stream.

Overrides:
flush in class StreamImpl
Throws:
java.io.IOException

close

public void close()
The close call does nothing since the rotate stream is shared for many logs.

Overrides:
close in class StreamImpl

finalize

public void finalize()
              throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable