Class TextLog

All Implemented Interfaces:
LogInterface, AutoCloseable
Direct Known Subclasses:
UiLog

public class TextLog extends GenericLog implements LogInterface, AutoCloseable
A heavyweight implementation of LogInterface.

TextLog is a logging mechanism designed for large volumes of data over a protracted period of time. Log files are stored in their own dedicated directory structure.

See LogInterface

Copyright 2003-2026 ATB Consultancy Services Ltd (formerly Orinda Software Ltd, Dublin, Ireland)

Version:
7
Author:
[email protected]
  • Field Details

    • MAX_MESSAGES_PER_FILE

      protected static final int MAX_MESSAGES_PER_FILE
      Max number of messages in a log file.

      Once this limit is reached the log file will switch.

      See Also:
    • LOG_FILE_EXTENSION

      protected static final String LOG_FILE_EXTENSION
      File extension for log files.
      See Also:
    • howManyMessagesInThisFile

      protected int howManyMessagesInThisFile
      How many messages are in this log file.
    • thePrefix

      protected String thePrefix
      A mnemonic prefix used for naming the log files
    • logFileDayFormat

      protected SimpleDateFormat logFileDayFormat
      The Year/Month/Day format in use
    • logFileTimeFormat

      protected SimpleDateFormat logFileTimeFormat
      The Hour/Minute format in use
    • theDirectoryFile

      protected File theDirectoryFile
      The directory log files will be kept in.
    • theCurrentLogFile

      protected File theCurrentLogFile
      The current log file
    • iAmBroken

      protected boolean iAmBroken
      A flag that is set if we can't write any more
    • consoleOutput

      protected boolean consoleOutput
      Whether messages are to be printed in standard output/error as well as written to a log file
  • Constructor Details

    • TextLog

      public TextLog(String thePrefix)
      Create an instance of TextLog. The log files will reside in the current working directory.
      Parameters:
      thePrefix - A mnemonic prefix used for naming the log file.
    • TextLog

      public TextLog(String theDirectoryName, String thePrefix)
      Create an instance of TextLog. The log files will reside in the directory specified.
      Parameters:
      theDirectoryName - the absolute path of the logging directory.
      thePrefix - An mnemonic prefix used for naming the log file.
  • Method Details

    • writeMessage

      protected void writeMessage(String messageType, String messageText, boolean isModal, boolean isLogged)
      Format a message and log it to the current log file.
      Specified by:
      writeMessage in class GenericLog
      Parameters:
      messageType - should be one of the constants DEBUG, INFO, WARN, ERROR or SYSERR as defined in LogInterface.
      messageText - The message
      isModal - ignored as we are dumping messages to a file.
      isLogged - whether the message is logged or not.
    • getLogFileDate

      protected String getLogFileDate()
      figure out what the date part of the log file should be called
    • getLogFileTime

      protected String getLogFileTime()
      figure out what the time part of the log file should be called
    • getLogFileName

      protected String getLogFileName(String thePrefix, String fileExtension)
      Return a new log file name.
    • closeFile

      public void closeFile()
      Flush and close the current log file.
    • flush

      public void flush()
      Flush any outstanding changes.
      Specified by:
      flush in interface LogInterface
      Specified by:
      flush in class GenericLog
    • getCurrentLog

      public String getCurrentLog()
      Get current log file name.
      Specified by:
      getCurrentLog in interface LogInterface
      Specified by:
      getCurrentLog in class GenericLog
      Returns:
      An absolute file name if we are writing to a log file. "NONE" If we haven't started writing to a file yet. Log files aren't opened until the first call to writeMessage "BROKEN" If we were unable to open a log file.
    • getConsoleOutput

      public boolean getConsoleOutput()
      Find out whether messages are being sent to standard output and standard error.
    • setConsoleOutput

      public void setConsoleOutput(boolean sendOutputToConsole)
      Set whether messages are to be sent to standard output and standard error.
    • close

      public void close()
      Close log file if currently open.
      Specified by:
      close in interface AutoCloseable