Class TFileLogger

java.lang.Object
org.cdlib.mrt.utility.LoggerAbs
org.cdlib.mrt.utility.TFileLogger
All Implemented Interfaces:
LoggerInf

public class TFileLogger extends LoggerAbs implements LoggerInf
Stores informational and error messages in a sequential file.
Author:
dloy
  • Field Details

    • DEFAULTNAME

      protected static final String DEFAULTNAME
      See Also:
    • m_logFile

      protected FileWriter m_logFile
    • m_dateQualifier

      protected String m_dateQualifier
    • m_messageMaxLevel

      protected int m_messageMaxLevel
    • m_errorMaxLevel

      protected int m_errorMaxLevel
    • EOL

      protected String EOL
    • m_mFrameID

      protected String m_mFrameID
    • includeThreadName

      protected boolean includeThreadName
    • defaultFlush

      protected boolean defaultFlush
    • initializeProperties

      protected Properties initializeProperties
    • m_filePath

      protected String m_filePath
  • Constructor Details

  • Method Details

    • initialize

      public void initialize(String mFrameID, String filePath, Properties prop) throws TException
      Initialize the logger inside of a framework. Uses framework properties to configure the logger, as follows:
      • fileLogger.message.maximumLevel - The maximum significance of informational messages that will be logged
      • fileLogger.error.maximumLevel - The maximum significance of error messages that will be logged
      • fileLogger.path - The path to the directory in which the log file will be written
      • fileLogger.name - The base name of the log file
      Parameters:
      fw - - Framework in which the logger is operating
      Throws:
      TException
    • initialize

      public void initialize(String frameworkID)
      Initialize the logger with no framework present. Default configuration values remain in place.
      Parameters:
      frameworkID - Framework identifier to disply in log entries
    • logMessage

      public void logMessage(String message, LoggerInf.LogLevel logLevel)
      Log an informational message to a file Default: no flush
      Specified by:
      logMessage in interface LoggerInf
      Parameters:
      message - - Text of message to be logged
      significance - - Level of significance (0 - 10) of the message
    • logMessage

      public void logMessage(String message, LoggerInf.LogLevel logLevel, boolean flushLog)
      Log an informational message to a file
      Specified by:
      logMessage in interface LoggerInf
      Parameters:
      message - - Text of message to be logged
      significance - - Level of significance (0 - 10) of the message
      flushLog - - flush log at completion of this log output
    • logError

      public void logError(String message, LoggerInf.LogLevel logLevel)
      Log an error message
      Specified by:
      logError in interface LoggerInf
      Parameters:
      message - - Text of message to be logged
      significance - - Level of significance (0 - 10) of the message
      source - - Source of the message
    • isMessageLoggable

      public boolean isMessageLoggable(LoggerInf.LogLevel logLevel)
      is this logLevel high enough to be message logged
      Specified by:
      isMessageLoggable in interface LoggerInf
      Parameters:
      logLevel - logging level
      Returns:
      true=level will be logged
    • isErrorLoggable

      public boolean isErrorLoggable(LoggerInf.LogLevel logLevel)
      is this logLevel high enough to be error logged
      Specified by:
      isErrorLoggable in interface LoggerInf
      Parameters:
      logLevel - logging level
      Returns:
      true=level will be logged
    • logMessage

      public void logMessage(String message, int significance)
      Log an informational message to a file Default: no flush
      Specified by:
      logMessage in interface LoggerInf
      Parameters:
      message - - Text of message to be logged
      significance - - Level of significance (0 - 10) of the message
    • logMessage

      public void logMessage(String message, int significance, boolean flushLog)
      Log an informational message to a file
      Specified by:
      logMessage in interface LoggerInf
      Parameters:
      message - - Text of message to be logged
      significance - - Level of significance (0 - 10) of the message
      flushLog - - flush log at completion of this log output
    • logError

      public void logError(String message, int significance)
      Log an error message
      Specified by:
      logError in interface LoggerInf
      Parameters:
      message - - Text of message to be logged
      significance - - Level of significance (0 - 10) of the message
      source - - Source of the message
    • getNow

      protected String getNow()
      Return a string representation of the current date, for use in qualifying the log file name. The string returned is determined by the current date/time and a format pattern string specified in property "fileLogger.qualifier".
      Returns:
      The formatted string representation of the current date/time
    • flush

      public void flush()
      Flushes the log
      Specified by:
      flush in interface LoggerInf
    • close

      public void close()
      Closes the log
      Specified by:
      close in interface LoggerInf
    • getMessageMaxLevel

      public int getMessageMaxLevel()
      get threshold for message creation
      Specified by:
      getMessageMaxLevel in interface LoggerInf
      Returns:
      message creation threshold (e.g. <=)
    • getErrorMaxLevel

      public int getErrorMaxLevel()
      get threshold for error message creation
      Specified by:
      getErrorMaxLevel in interface LoggerInf
      Returns:
      error message creation threshold (e.g. <=)
    • getFrameworkID

      protected String getFrameworkID()
      Get the FrameworkID - imbed thread name if requested
      Returns:
      displayable log name
    • getLogLevelValue

      protected int getLogLevelValue(LoggerInf.LogLevel logLevel)