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 booleanprotected static final Stringprotected Stringprotected booleanprotected Propertiesprotected Stringprotected intprotected Stringprotected FileWriterprotected intprotected 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 TypeMethodDescriptionvoidclose()Closes the logvoidflush()Flushes the logintget threshold for error message creationprotected StringGet the FrameworkID - imbed thread name if requestedprotected intgetLogLevelValue(LoggerInf.LogLevel logLevel) intget threshold for message creationprotected StringgetNow()Return a string representation of the current date, for use in qualifying the log file name.voidinitialize(String frameworkID) Initialize the logger with no framework present.voidinitialize(String mFrameID, String filePath, Properties prop) Initialize the logger inside of a framework.booleanisErrorLoggable(LoggerInf.LogLevel logLevel) is this logLevel high enough to be error loggedbooleanisMessageLoggable(LoggerInf.LogLevel logLevel) is this logLevel high enough to be message loggedvoidLog an error messagevoidlogError(String message, LoggerInf.LogLevel logLevel) Log an error messagevoidlogMessage(String message, int significance) Log an informational message to a file Default: no flushvoidlogMessage(String message, int significance, boolean flushLog) Log an informational message to a filevoidlogMessage(String message, LoggerInf.LogLevel logLevel) Log an informational message to a file Default: no flushvoidlogMessage(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:
logMessagein interfaceLoggerInf- Parameters:
message- - Text of message to be loggedlogLevel- - Level of signifiance (0 - 10) of the messagesignificance- - Level of significance (0 - 10) of the message
-
logMessage
Log an informational message to a file- Specified by:
logMessagein interfaceLoggerInf- Parameters:
message- - Text of message to be loggedlogLevel- - Level of signifiance of the messageflushLog- - flush log at completion of this log outputsignificance- - Level of significance (0 - 10) of the message
-
logError
Log an error message -
isMessageLoggable
is this logLevel high enough to be message logged- Specified by:
isMessageLoggablein interfaceLoggerInf- Parameters:
logLevel- logging level- Returns:
- true=level will be logged
-
isErrorLoggable
is this logLevel high enough to be error logged- Specified by:
isErrorLoggablein interfaceLoggerInf- Parameters:
logLevel- logging level- Returns:
- true=level will be logged
-
logMessage
Log an informational message to a file Default: no flush- Specified by:
logMessagein 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:
logMessagein 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:
getMessageMaxLevelin interfaceLoggerInf- Returns:
- message creation threshold (e.g. invalid input: '<'=)
-
getErrorMaxLevel
public int getErrorMaxLevel()get threshold for error message creation- Specified by:
getErrorMaxLevelin interfaceLoggerInf- Returns:
- error message creation threshold (e.g. invalid input: '<'=)
-
getFrameworkID
Get the FrameworkID - imbed thread name if requested- Returns:
- displayable log name
-
getLogLevelValue
-