org.jpos.util
Class DailyLogListener

java.lang.Object
  extended by org.jpos.util.SimpleLogListener
      extended by org.jpos.util.RotateLogListener
          extended by org.jpos.util.DailyLogListener
All Implemented Interfaces:
EventListener, Configurable, Destroyable, LogListener

public class DailyLogListener
extends RotateLogListener

Rotates log daily and compress the prevoius log.

Since:
jPOS 1.5.1
Author:
Andrés Alcarraz

Nested Class Summary
protected  class DailyLogListener.Compressor
           
 
Nested classes/interfaces inherited from class org.jpos.util.RotateLogListener
RotateLogListener.Rotate
 
Field Summary
 
Fields inherited from class org.jpos.util.RotateLogListener
CHECK_INTERVAL, DEFAULT_MAXSIZE
 
Constructor Summary
DailyLogListener()
          Creates a new instance of DailyLogListener
 
Method Summary
protected  void checkSize()
           
protected  void closeCompressedOutputStream(OutputStream os)
           
protected  void compress(File logFile)
          Hook method to optionally compress the file
protected  OutputStream getCompressedOutputStream(File f)
          Hook method that creates an output stream that will compress the data.
 String getCompressedSuffix()
          Getter for property compressedExt.
 int getCompressionBufferSize()
          Getter for property compressionBufferSize.
 int getCompressionFormat()
          Getter for property compressionFormat.
protected  Thread getCompressorThread(File f)
          Hook method that creates a thread to compress the file f.
 DateFormat getDateFmt()
          Getter for property dateFmt.
 String getLastDate()
          Getter for property lastDate.
 String getPrefix()
          Getter for property prefix.
 int getRotateCount()
          Getter for property rotateCount.
 String getSuffix()
          Getter for property suffix.
protected  void logDebugEx(String msg, Throwable e)
           
 void logRotate()
           
 void setCompressedSuffix(String compressedSuffix)
          Setter for property compressedExt.
 void setCompressionBufferSize(int compressionBufferSize)
          Setter for property compressionBufferSize.
 void setCompressionFormat(int compressionFormat)
          Setter for property compressionFormat.
 void setConfiguration(Configuration cfg)
          Configure this RotateLogListener
Properties:
file base log filename [window] in seconds (default 0 - never rotate) [count] number of copies (default 0 == single copy) [maxsize] max log size in bytes (aprox)
 void setDateFmt(DateFormat dateFmt)
          Setter for property dateFmt.
 void setLastDate(String lastDate)
          Setter for property lastDate.
 void setPrefix(String prefix)
          Setter for property prefix.
 void setRotateCount(int rotateCount)
          Setter for property rotateCount.
 void setSuffix(String suffix)
          Setter for property suffix.
 
Methods inherited from class org.jpos.util.RotateLogListener
closeLogFile, destroy, log, logDebug, openLogFile
 
Methods inherited from class org.jpos.util.SimpleLogListener
close, setPrintStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DailyLogListener

public DailyLogListener()
Creates a new instance of DailyLogListener

Method Detail

setConfiguration

public void setConfiguration(Configuration cfg)
                      throws ConfigurationException
Description copied from class: RotateLogListener
Configure this RotateLogListener
Properties:

Specified by:
setConfiguration in interface Configurable
Overrides:
setConfiguration in class RotateLogListener
Parameters:
cfg - Configuration
Throws:
ConfigurationException

logRotate

public void logRotate()
               throws IOException
Overrides:
logRotate in class RotateLogListener
Throws:
IOException

getSuffix

public String getSuffix()
Getter for property suffix.

Returns:
Value of property suffix.

setSuffix

public void setSuffix(String suffix)
Setter for property suffix.

Parameters:
suffix - New value of property suffix.

getPrefix

public String getPrefix()
Getter for property prefix.

Returns:
Value of property prefix.

setPrefix

public void setPrefix(String prefix)
Setter for property prefix.

Parameters:
prefix - New value of property prefix.

getRotateCount

public int getRotateCount()
Getter for property rotateCount.

Returns:
Value of property rotateCount.

setRotateCount

public void setRotateCount(int rotateCount)
Setter for property rotateCount.

Parameters:
rotateCount - New value of property rotateCount.

getDateFmt

public DateFormat getDateFmt()
Getter for property dateFmt.

Returns:
Value of property dateFmt.

setDateFmt

public void setDateFmt(DateFormat dateFmt)
Setter for property dateFmt.

Parameters:
dateFmt - New value of property dateFmt.

getLastDate

public String getLastDate()
Getter for property lastDate.

Returns:
Value of property lastDate.

setLastDate

public void setLastDate(String lastDate)
Setter for property lastDate.

Parameters:
lastDate - New value of property lastDate.

getCompressedSuffix

public String getCompressedSuffix()
Getter for property compressedExt.

Returns:
Value of property compressedExt.

setCompressedSuffix

public void setCompressedSuffix(String compressedSuffix)
Setter for property compressedExt.

Parameters:
compressedSuffix - New value of property compressedExt.

getCompressorThread

protected Thread getCompressorThread(File f)
Hook method that creates a thread to compress the file f.

Parameters:
f - the file name
Returns:
a thread to compress the file and null if it is not necesary

getCompressedOutputStream

protected OutputStream getCompressedOutputStream(File f)
                                          throws IOException
Hook method that creates an output stream that will compress the data.

Parameters:
f - the file name
Returns:
ZIP/GZip OutputStream
Throws:
IOException - on error

closeCompressedOutputStream

protected void closeCompressedOutputStream(OutputStream os)
                                    throws IOException
Throws:
IOException

logDebugEx

protected void logDebugEx(String msg,
                          Throwable e)

getCompressionFormat

public int getCompressionFormat()
Getter for property compressionFormat.

Returns:
Value of property compressionFormat.

setCompressionFormat

public void setCompressionFormat(int compressionFormat)
Setter for property compressionFormat.

Parameters:
compressionFormat - New value of property compressionFormat.

getCompressionBufferSize

public int getCompressionBufferSize()
Getter for property compressionBufferSize.

Returns:
Value of property compressionBufferSize.

setCompressionBufferSize

public void setCompressionBufferSize(int compressionBufferSize)
Setter for property compressionBufferSize.

Parameters:
compressionBufferSize - New value of property compressionBufferSize.

checkSize

protected void checkSize()
Overrides:
checkSize in class RotateLogListener

compress

protected void compress(File logFile)
Hook method to optionally compress the file

Parameters:
logFile - the file name


Copyright © 1998-2012 jPOS.org. All Rights Reserved.