Package org.cdlib.mrt.utility
Class TFileLogger
java.lang.Object
org.cdlib.mrt.utility.LoggerAbs
org.cdlib.mrt.utility.TFileLogger
- All Implemented Interfaces:
LoggerInf
Stores informational and error messages in a sequential file.
- Author:
- dloy
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.cdlib.mrt.utility.LoggerInf
LoggerInf.LogLevel
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected static final String
protected String
protected boolean
protected Properties
protected String
protected int
protected String
protected FileWriter
protected int
protected String
-
Constructor Summary
ConstructorsConstructorDescriptionTFileLogger
(String mFrameID, int messageMaxLevel, int errorMaxLevel) TFileLogger
(String mFrameID, String filePath, Properties prop) TFileLogger
(String mFrameID, LoggerInf.LogLevel messageLogLevel, LoggerInf.LogLevel errorLogLevel) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the logvoid
flush()
Flushes the logint
get threshold for error message creationprotected String
Get the FrameworkID - imbed thread name if requestedprotected int
getLogLevelValue
(LoggerInf.LogLevel logLevel) int
get threshold for message creationprotected String
getNow()
Return a string representation of the current date, for use in qualifying the log file name.void
initialize
(String frameworkID) Initialize the logger with no framework present.void
initialize
(String mFrameID, String filePath, Properties prop) Initialize the logger inside of a framework.boolean
isErrorLoggable
(LoggerInf.LogLevel logLevel) is this logLevel high enough to be error loggedboolean
isMessageLoggable
(LoggerInf.LogLevel logLevel) is this logLevel high enough to be message loggedvoid
Log an error messagevoid
logError
(String message, LoggerInf.LogLevel logLevel) Log an error messagevoid
logMessage
(String message, int significance) Log an informational message to a file Default: no flushvoid
logMessage
(String message, int significance, boolean flushLog) Log an informational message to a filevoid
logMessage
(String message, LoggerInf.LogLevel logLevel) Log an informational message to a file Default: no flushvoid
logMessage
(String message, LoggerInf.LogLevel logLevel, boolean flushLog) Log an informational message to a fileMethods inherited from class org.cdlib.mrt.utility.LoggerAbs
getTFileLogger, getTFileLogger, getTFileLogger
-
Field Details
-
DEFAULTNAME
- See Also:
-
m_logFile
-
m_dateQualifier
-
m_messageMaxLevel
protected int m_messageMaxLevel -
m_errorMaxLevel
protected int m_errorMaxLevel -
EOL
-
m_mFrameID
-
includeThreadName
protected boolean includeThreadName -
defaultFlush
protected boolean defaultFlush -
initializeProperties
-
m_filePath
-
-
Constructor Details
-
TFileLogger
-
TFileLogger
public TFileLogger(String mFrameID, LoggerInf.LogLevel messageLogLevel, LoggerInf.LogLevel errorLogLevel) -
TFileLogger
- Throws:
TException
-
-
Method Details
-
initialize
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
Initialize the logger with no framework present. Default configuration values remain in place.- Parameters:
frameworkID
- Framework identifier to disply in log entries
-
logMessage
Log an informational message to a file Default: no flush- Specified by:
logMessage
in interfaceLoggerInf
- Parameters:
message
- - Text of message to be loggedsignificance
- - Level of significance (0 - 10) of the message
-
logMessage
Log an informational message to a file- Specified by:
logMessage
in interfaceLoggerInf
- Parameters:
message
- - Text of message to be loggedsignificance
- - Level of significance (0 - 10) of the messageflushLog
- - flush log at completion of this log output
-
logError
Log an error message -
isMessageLoggable
is this logLevel high enough to be message logged- Specified by:
isMessageLoggable
in interfaceLoggerInf
- Parameters:
logLevel
- logging level- Returns:
- true=level will be logged
-
isErrorLoggable
is this logLevel high enough to be error logged- Specified by:
isErrorLoggable
in interfaceLoggerInf
- Parameters:
logLevel
- logging level- Returns:
- true=level will be logged
-
logMessage
Log an informational message to a file Default: no flush- Specified by:
logMessage
in interfaceLoggerInf
- Parameters:
message
- - Text of message to be loggedsignificance
- - Level of significance (0 - 10) of the message
-
logMessage
Log an informational message to a file- Specified by:
logMessage
in interfaceLoggerInf
- Parameters:
message
- - Text of message to be loggedsignificance
- - Level of significance (0 - 10) of the messageflushLog
- - flush log at completion of this log output
-
logError
Log an error message -
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 -
close
public void close()Closes the log -
getMessageMaxLevel
public int getMessageMaxLevel()get threshold for message creation- Specified by:
getMessageMaxLevel
in interfaceLoggerInf
- Returns:
- message creation threshold (e.g. <=)
-
getErrorMaxLevel
public int getErrorMaxLevel()get threshold for error message creation- Specified by:
getErrorMaxLevel
in interfaceLoggerInf
- Returns:
- error message creation threshold (e.g. <=)
-
getFrameworkID
Get the FrameworkID - imbed thread name if requested- Returns:
- displayable log name
-
getLogLevelValue
-