Package org.ka2ddo.yaac.core
Class StringLogger
- All Implemented Interfaces:
Comparable<ReschedulableTimerTask>
,Runnable
,ShutdownHandler
This class batches up logging text messages to a text file.
- Author:
- Andrew Pavlin, KA2DDO
-
Nested Class Summary
Nested classes/interfaces inherited from class org.ka2ddo.yaac.core.FileLogger
FileLogger.RolloverHandler<T>
-
Constructor Summary
ConstructorDescriptionStringLogger
(String prefix, String datePattern, String suffix) Create a StringLogger using the specified prefix on the file name, also using the date format "yyyy-MM-dd" and the file type ".log".StringLogger
(String prefix, String datePattern, String suffix, long rolloverInterval) Create a StringLogger using the specified prefix on the file name, also using the date format "yyyy-MM-dd" and the file type ".log". -
Method Summary
Modifier and TypeMethodDescriptionvoid
dumpRecordQueueToFile
(File logFileFile, ArrayList<String> 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.Methods inherited from class org.ka2ddo.yaac.core.FileLogger
flush, getDefaultLogDir, log, log, log, run, setDatePattern, setDefaultLogDir, setFilePrefix, setFileSuffix, setFlushInterval, setLogDirectory, setRolloverHandler, setRolloverInterval, setTimeZone, shutdown
-
Constructor Details
-
StringLogger
Create a StringLogger using the specified prefix on the file name, also using the date format "yyyy-MM-dd" and the file type ".log".- Parameters:
prefix
- String prefix for the file namedatePattern
- format string for file name embedded date, using SimpleDateFormat directivessuffix
- String file name suffix (after the date)
-
StringLogger
Create a StringLogger using the specified prefix on the file name, also using the date format "yyyy-MM-dd" and the file type ".log".- Parameters:
prefix
- String prefix for the file namedatePattern
- format string for file name embedded date, using SimpleDateFormat directivessuffix
- String file name suffix (after the date)rolloverInterval
- the interval in milliseconds between log file changes
-
-
Method Details
-
dumpRecordQueueToFile
public void dumpRecordQueueToFile(File logFileFile, ArrayList<String> recordQueue) throws IOException 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.- Specified by:
dumpRecordQueueToFile
in classFileLogger<String>
- Parameters:
logFileFile
- File identifying the log file to open and writerecordQueue
- the ArrayList of ordered records to write- Throws:
IOException
- if record saving fails for any reason
-