Class StringLogger

All Implemented Interfaces:
Comparable<ReschedulableTimerTask>, Runnable, ShutdownHandler

public class StringLogger extends FileLogger<String>
This class batches up logging text messages to a text file.
Author:
Andrew Pavlin, KA2DDO
  • Constructor Details

    • StringLogger

      public StringLogger(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".
      Parameters:
      prefix - String prefix for the file name
      datePattern - format string for file name embedded date, using SimpleDateFormat directives
      suffix - String file name suffix (after the date)
    • StringLogger

      public 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".
      Parameters:
      prefix - String prefix for the file name
      datePattern - format string for file name embedded date, using SimpleDateFormat directives
      suffix - 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 class FileLogger<String>
      Parameters:
      logFileFile - File identifying the log file to open and write
      recordQueue - the ArrayList of ordered records to write
      Throws:
      IOException - if record saving fails for any reason