|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.TimerTask
org.ka2ddo.yaac.core.FileLogger<T>
public abstract class FileLogger<T>
This class implements a generic time-batched logging facility for an arbitrary record type T in a date-rolled sequential logging file.
Constructor Summary | |
---|---|
protected |
FileLogger(java.lang.String prefix,
java.lang.String datePattern,
java.lang.String suffix,
int flushEveryNSeconds)
Create a FileLogger using the specified file prefix, date pattern, suffix, and flush interval, storing the log files in YAAC's default log directory. |
protected |
FileLogger(java.lang.String prefix,
java.lang.String datePattern,
java.lang.String suffix,
int flushEveryNSeconds,
java.lang.String logDirPath)
Create a FileLogger using the specified file prefix, date pattern, suffix, and flush interval, storing the log files in the explicitly specified log directory. |
Method Summary | |
---|---|
abstract void |
dumpRecordQueueToFile(java.io.File logFileFile,
java.util.ArrayList<T> recordQueue)
Subclasses should implement this method to open the specified sequential file for append, then write each of the records in the recordQueue in order to the file, then close the file. |
void |
flush()
Dump the current contents of the backlog queue to the current log file. |
void |
log(T record)
Append one record to the log file, using asynchronous background writing. |
void |
log(T record,
java.util.Date date)
Append one record to the log file, using asynchronous background writing. |
void |
log(T record,
long date)
Append one record to the log file, using asynchronous background writing. |
void |
run()
|
void |
setDatePattern(java.lang.String datePattern)
|
static void |
setDefaultLogDir(java.lang.String defaultLogDirPath)
|
void |
setFilePrefix(java.lang.String prefix)
Change the constant prefix that should be used before the date part of the log file name. |
void |
setFileSuffix(java.lang.String suffix)
Change the constant suffix that should be used after the date part of the log file name. |
void |
setFlushInterval(int flushEveryNSeconds)
Set how frequently the logger should dump its backlog queue to disk and close the file for checkpointing. |
void |
setLogDirectory(java.lang.String logDirPath)
Set the directory in which log files should be created. |
void |
shutdown()
Do whatever cleanup this object needs for program shutdown. |
Methods inherited from class java.util.TimerTask |
---|
cancel, scheduledExecutionTime |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected FileLogger(java.lang.String prefix, java.lang.String datePattern, java.lang.String suffix, int flushEveryNSeconds)
prefix
- String file name prefix (before the date)datePattern
- format string for file name embedded date, using SimpleDateFormat directivessuffix
- String file name suffix (after the date)flushEveryNSeconds
- the interval between log flushes in secondssetDefaultLogDir(String)
protected FileLogger(java.lang.String prefix, java.lang.String datePattern, java.lang.String suffix, int flushEveryNSeconds, java.lang.String logDirPath)
prefix
- String file name prefix (before the date)datePattern
- format string for file name embedded date, using SimpleDateFormat directivessuffix
- String file name suffix (after the date)flushEveryNSeconds
- the interval between log flushes in secondslogDirPath
- String path name of directory to contain the log filesMethod Detail |
---|
public void setLogDirectory(java.lang.String logDirPath)
logDirPath
- String pathname of log-containing directorypublic static void setDefaultLogDir(java.lang.String defaultLogDirPath)
public void setFlushInterval(int flushEveryNSeconds)
flushEveryNSeconds
- the interval in seconds between file closespublic void setDatePattern(java.lang.String datePattern)
public void setFilePrefix(java.lang.String prefix)
prefix
- String name prefixpublic void setFileSuffix(java.lang.String suffix)
suffix
- String name suffixpublic void log(T record)
record
- data record to log of the specified generic typepublic void log(T record, java.util.Date date)
record
- data record to log of the specified generic typedate
- Date when record was created, received, etc.public void log(T record, long date)
record
- data record to log of the specified generic typedate
- long timestamp in milliseconds since midnight Jan 19 1970 UTC when record was created, received, etc.public void flush()
public abstract void dumpRecordQueueToFile(java.io.File logFileFile, java.util.ArrayList<T> recordQueue) throws java.io.IOException
logFileFile
- File identifying the log file to open and writerecordQueue
- the ArrayList of ordered records to write
java.io.IOException
- if record saving fails for any reasonpublic final void run()
run
in interface java.lang.Runnable
run
in class java.util.TimerTask
public void shutdown()
shutdown
in interface ShutdownHandler
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |