|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.isti.util.LogFile
Class LogFile provides log file output services. The 'initLogObj()' and 'getLogObj()' functions support the use of a single "global" log file object. Other "local" log file objects may also be created and used. Each log message is received with one of the the following message levels: ERROR - An error which causes the program to abort. WARNING - An unexpected condition, but the program continues. INFO - An informational message. DEBUG - A debug message, for developers only. DEBUG2-5 - Debug messages of increasing detail, for developers only. The console and log file outputs are configurable such that only messages at or beyond a set message level are retained. The message level is shown on each output message, and the date & time are shown on each message sent to the log file. Options are available for adding a date code to the filename and creating new log files as the date code changes, as well as automatic deletion of old log files.
Field Summary | |
static int |
ALL_MSGS
A message level value used to specify that all messages will be retained (-999). |
static java.lang.String |
ALL_MSGS_STR
String version of a message level value used to specify that all messages will be retained. |
static int |
DEBUG
A message level value that denotes a debug message, for developers only (0). |
static java.lang.String |
DEBUG_STR
String version of a message level value that denotes a debug message, for developers only. |
static int |
DEBUG2
A message level value that denotes a lower-level debug (2) message, for developers only (-1). |
static java.lang.String |
DEBUG2_STR
String version of a message level value that denotes a debug (2) message, for developers only. |
static int |
DEBUG3
A message level value that denotes a lower-level debug (3) message, for developers only (-2). |
static java.lang.String |
DEBUG3_STR
String version of a message level value that denotes a debug (3) message, for developers only. |
static int |
DEBUG4
A message level value that denotes a lower-level debug (4) message, for developers only (-3). |
static java.lang.String |
DEBUG4_STR
String version of a message level value that denotes a debug (4) message, for developers only. |
static int |
DEBUG5
A message level value that denotes a lower-level debug (5) message, for developers only (-4). |
static java.lang.String |
DEBUG5_STR
String version of a message level value that denotes a debug (5) message, for developers only. |
static boolean |
DEFAULT_GMT_FLAG
Default for 'gmtFlag'. |
static boolean |
DEFAULT_USE_DATE_IN_FNAME_FLAG
Default for 'useDateInFnameFlag'. |
static int |
ERROR
A message level value that denotes an error which causes the program to abort (3). |
static java.lang.String |
ERROR_STR
String version of a message level value that denotes an error which causes the program to abort. |
static java.lang.String |
FILE_DATE_PATTERNSTR
Pattern string for "file" date formatter ("yyyyMMdd"). |
static java.lang.String |
FNAME_DATE_SEPSTR
Separator used between file name and date code ("_"). |
static int |
INFO
A message level value that denotes an informational message (1). |
static java.lang.String |
INFO_STR
String version of a message level value that denotes an informational message. |
static java.lang.String |
LONG_DATE_PATTERNSTR
Pattern string for "long" date formatter ("MMMM dd, yyyy HH:mm:ss z"). |
static int |
NO_LEVEL
A message level value used to specify that no log-level indicator is to be output with the message (998). |
static int |
NO_MSGS
A message level value used to specify that no messages will be retained (999). |
static java.lang.String |
NO_MSGS_STR
String version of a message level value used to specify that no messages will be retained. |
static java.lang.String |
SHORT_DATE_PATTERNSTR
Pattern string for "short" date formatter ("MMM dd yyyy HH:mm:ss"). |
static int |
WARNING
A message level value that denotes an unexpected condition, but the program continues (2). |
static java.lang.String |
WARNING_STR
String version of a message level value that denotes an unexpected condition, but the program continues. |
Constructor Summary | |
LogFile(java.lang.String fName,
int logFileLevel,
int consoleLevel)
Creates a new LogFile object, using the local timezone for timestamps. |
|
LogFile(java.lang.String fName,
int logFileLevel,
int consoleLevel,
boolean gmtFlag)
Creates a new LogFile object. |
|
LogFile(java.lang.String fName,
int logFileLevel,
int consoleLevel,
boolean gmtFlag,
boolean useDateInFnameFlag)
Creates a new LogFile object. |
Method Summary | |
void |
addTrackedMsgListener(DataChangedListener listenerObj)
Adds the given tracked-message listener. |
void |
close()
Closes the log file. |
boolean |
debug(java.lang.String str)
Sends the given string to the log file with the message level set to 'DEBUG'. |
boolean |
debug2(java.lang.String str)
Sends the given string to the log file with the message level set to 'DEBUG2'. |
boolean |
debug3(java.lang.String str)
Sends the given string to the log file with the message level set to 'DEBUG3'. |
boolean |
debug4(java.lang.String str)
Sends the given string to the log file with the message level set to 'DEBUG4'. |
boolean |
debug5(java.lang.String str)
Sends the given string to the log file with the message level set to 'DEBUG5'. |
boolean |
error(java.lang.String str)
Sends the given string to the log file with the message level set to 'ERROR'. |
int |
getConsoleLevel()
Gets the current level for console output messages. |
static LogFile |
getConsoleLogObj()
Gets a handle to the console log file object. |
java.text.DateFormat |
getDateFormat()
Gets the date formatter for log file entries. |
java.lang.String |
getFileName()
Returns the current log file name in use. |
static LogFile |
getGlobalLogObj()
Gets a handle to the "global" log file object. |
static LogFile |
getGlobalLogObj(boolean consoleFlag)
Gets a handle to the "global" log file object. |
static java.lang.String[] |
getLevelNamesArray()
Returns an array containing all the valid log-level name strings. |
static java.lang.String |
getLevelNamesDisplayStr()
Returns an array containing all the valid log-level name strings. |
static java.util.Vector |
getLevelNamesVector()
Returns a Vector containing all the valid log-level name strings. |
static java.lang.String |
getLevelString(int level)
Returns a String corresponding to the given message level value. |
static java.lang.String |
getLevelStringNull(int level)
Returns a String corresponding to the given message level value. |
int |
getLogFileLevel()
Gets the current level for log file output messages. |
LogOutputStream |
getLogOutputStream()
Returns an 'OutputStream' object whose output is directed to this log file. |
int |
getMaxLogFileAge()
Gets the maximum log file age. |
static LogFile |
getNullLogObj()
Gets a handle to the null log file object. |
java.lang.String[] |
getTrackedMessages()
Returns an array of strings containing the tracked messages. |
java.lang.String[] |
getTrackedMessages(int maxAgeMs)
Returns an array of strings containing the tracked messages. |
java.lang.String |
getTrackedMsgsAsString(java.lang.String sepStr)
Returns a string containing the tracked messages. |
java.lang.String |
getTrackedMsgsAsString(java.lang.String sepStr,
int maxAgeMs)
Returns a string containing the tracked messages. |
boolean |
info(java.lang.String str)
Sends the given string to the log file with the message level set to 'INFO'. |
static LogFile |
initGlobalLogObj(LogFile logObj)
Initializes the "global" log file object. |
static LogFile |
initGlobalLogObj(java.lang.String fName,
int logFileLevel,
int consoleLevel)
Initializes the "global" log file object, using the local timezone for timestamps. |
static LogFile |
initGlobalLogObj(java.lang.String fName,
int logFileLevel,
int consoleLevel,
boolean gmtFlag)
Initializes the "global" log file object. |
static LogFile |
initGlobalLogObj(java.lang.String fName,
int logFileLevel,
int consoleLevel,
boolean gmtFlag,
boolean useDateInFnameFlag)
Initializes the "global" log file object. |
boolean |
isOpen()
Determines if the log file is open. |
static java.lang.Integer |
levelStringToValue(java.lang.String str)
Gets the integer value that corresponds to the given message level String. |
boolean |
println(int level,
java.lang.String str)
Sends the given string to the log file. |
boolean |
println(java.lang.String str)
Sends the given string to the log file. |
void |
removeTrackedMsgListener(DataChangedListener listenerObj)
Removes the given tracked-message listener. |
void |
setConsoleLevel(int level)
Sets the current level for console output messages. |
void |
setLogFileLevel(int level)
Sets the current level for console output messages. |
void |
setLogFileSwitchIntervalDays(int numDays)
Sets the minimum number of days between log file switches via date changes. |
void |
setMaxLogFileAge(int maxAge)
Sets the maximum log file age, in days. |
void |
setupMessageTracking(int msgLevel,
int msgCount)
Sets up message tracking. |
boolean |
warning(java.lang.String str)
Sends the given string to the log file with the message level set to 'WARNING'. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int ERROR
public static final int WARNING
public static final int INFO
public static final int DEBUG
public static final int DEBUG2
public static final int DEBUG3
public static final int DEBUG4
public static final int DEBUG5
public static final int ALL_MSGS
public static final int NO_MSGS
public static final int NO_LEVEL
public static final java.lang.String ERROR_STR
public static final java.lang.String WARNING_STR
public static final java.lang.String INFO_STR
public static final java.lang.String DEBUG_STR
public static final java.lang.String DEBUG2_STR
public static final java.lang.String DEBUG3_STR
public static final java.lang.String DEBUG4_STR
public static final java.lang.String DEBUG5_STR
public static final java.lang.String ALL_MSGS_STR
public static final java.lang.String NO_MSGS_STR
public static final boolean DEFAULT_GMT_FLAG
public static final boolean DEFAULT_USE_DATE_IN_FNAME_FLAG
public static final java.lang.String FNAME_DATE_SEPSTR
public static final java.lang.String FILE_DATE_PATTERNSTR
public static final java.lang.String SHORT_DATE_PATTERNSTR
public static final java.lang.String LONG_DATE_PATTERNSTR
Constructor Detail |
public LogFile(java.lang.String fName, int logFileLevel, int consoleLevel, boolean gmtFlag, boolean useDateInFnameFlag)
fName
- log file name to use (if a path name then any needed
parent directories will be created), or null for none.logFileLevel
- minimum level of messages to send to the
log file, such as NO_MSGS, INFO, etc.consoleLevel
- minimum level of messages to send to the
console, such as NO_MSGS, INFO, etc.gmtFlag
- true to use GMT for timestamps, false to use the
local timezone.useDateInFnameFlag
- true to use the date in the file name (and
create a new log file everytime the date changes).public LogFile(java.lang.String fName, int logFileLevel, int consoleLevel, boolean gmtFlag)
fName
- log file name to use (if a path name then any needed
parent directories will be created).logFileLevel
- minimum level of messages to send to the
log file, such as NO_MSGS, INFO, etc.consoleLevel
- minimum level of messages to send to the
console, such as NO_MSGS, INFO, etc.gmtFlag
- true to use GMT for timestamps, false to use the
local timezone.public LogFile(java.lang.String fName, int logFileLevel, int consoleLevel)
fName
- log file name to use (if a path name then any needed
parent directories will be created).logFileLevel
- minimum level of messages to send to the
log file, such as NO_MSGS, INFO, etc.consoleLevel
- minimum level of messages to send to the
console, such as NO_MSGS, INFO, etc.Method Detail |
public int getMaxLogFileAge()
public void setMaxLogFileAge(int maxAge)
maxAge
- maximum age (in days) or 0 to disable.public void setLogFileSwitchIntervalDays(int numDays)
numDays
- if > 0 then the minimum number of days between
log file switches; otherwise the log file switching feature is
disabled.public void setupMessageTracking(int msgLevel, int msgCount)
msgLevel
- minimum message level to be tracked, or NO_MSGS
for none.msgCount
- number of messages to be tracked.public java.lang.String[] getTrackedMessages(int maxAgeMs)
maxAgeMs
- maximum age (in milliseconds) of messages returned,
or 0 for all messages.
public java.lang.String[] getTrackedMessages()
public java.lang.String getTrackedMsgsAsString(java.lang.String sepStr, int maxAgeMs)
sepStr
- separator to be placed between each item.maxAgeMs
- maximum age (in milliseconds) of messages returned,
or 0 for all messages.
public java.lang.String getTrackedMsgsAsString(java.lang.String sepStr)
sepStr
- separator to be placed between each item.
public void addTrackedMsgListener(DataChangedListener listenerObj)
listenerObj
- the 'DataChangedListener' object to be added.public void removeTrackedMsgListener(DataChangedListener listenerObj)
listenerObj
- the 'DataChangedListener' object to be removed.public boolean println(int level, java.lang.String str)
level
- the message level to be used, or NO_LEVEL for none.str
- the string to be outputted.
public boolean println(java.lang.String str)
str
- the string to be outputted.
public boolean error(java.lang.String str)
str
- the string to be outputted.
public boolean warning(java.lang.String str)
str
- the string to be outputted.
public boolean info(java.lang.String str)
str
- the string to be outputted.
public boolean debug(java.lang.String str)
str
- the string to be outputted.
public boolean debug2(java.lang.String str)
str
- the string to be outputted.
public boolean debug3(java.lang.String str)
str
- the string to be outputted.
public boolean debug4(java.lang.String str)
str
- the string to be outputted.
public boolean debug5(java.lang.String str)
str
- the string to be outputted.
public void close()
public LogOutputStream getLogOutputStream()
public java.lang.String getFileName()
public boolean isOpen()
public int getConsoleLevel()
public void setConsoleLevel(int level)
level
- the console level to be used.public int getLogFileLevel()
public void setLogFileLevel(int level)
level
- the log file level to be used.public static java.lang.String getLevelString(int level)
level
- the message level.
public static java.lang.String getLevelStringNull(int level)
level
- the message level.
public static java.lang.Integer levelStringToValue(java.lang.String str)
str
- the message level string to interpret.
public static java.util.Vector getLevelNamesVector()
public static java.lang.String[] getLevelNamesArray()
public static java.lang.String getLevelNamesDisplayStr()
public static LogFile initGlobalLogObj(LogFile logObj)
logObj
- the log file object.
public static LogFile initGlobalLogObj(java.lang.String fName, int logFileLevel, int consoleLevel, boolean gmtFlag, boolean useDateInFnameFlag)
fName
- log file name to use (if a path name then any needed
parent directories will be created).consoleLevel
- minimum level of messages to send to the
console, such as NO_MSGS, INFO, etc.logFileLevel
- minimum level of messages to send to the
log file, such as NO_MSGS, INFO, etc.gmtFlag
- true to use GMT for timestamps, false to use the
local timezone.useDateInFnameFlag
- true to use the date in the file name (and
create a new log file everytime the date changes).
public static LogFile initGlobalLogObj(java.lang.String fName, int logFileLevel, int consoleLevel, boolean gmtFlag)
fName
- log file name to use (if a path name then any needed
parent directories will be created).consoleLevel
- minimum level of messages to send to the
console, such as NO_MSGS, INFO, etc.logFileLevel
- minimum level of messages to send to the
log file, such as NO_MSGS, INFO, etc.gmtFlag
- true to use GMT for timestamps, false to use the
local timezone.
public static LogFile initGlobalLogObj(java.lang.String fName, int logFileLevel, int consoleLevel)
fName
- log file name to use (if a path name then any needed
parent directories will be created).consoleLevel
- minimum level of messages to send to the
console, such as NO_MSGS, INFO, etc.logFileLevel
- minimum level of messages to send to the
log file, such as NO_MSGS, INFO, etc.
public static LogFile getGlobalLogObj()
public static LogFile getGlobalLogObj(boolean consoleFlag)
consoleFlag
- true to return a console log file if
'initGlobalLogObj()' was not called previously, otherwise a null log file
is returned.
NOTE: Console output should be limited to messages that will be displayed
infrequently.
public static LogFile getConsoleLogObj()
public static LogFile getNullLogObj()
public java.text.DateFormat getDateFormat()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |