|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.isti.util.ThreadLogger
public class ThreadLogger
Class ThreadLogger defines a debugging utility that generates periodic log messages showing information about the current threads running in a program. A new thread is created to generate the log messages. The default behavior is that log messages are only generated when a change in the threads is detected. This behavior may be changed via the 'setOutputOnChangeFlag()' method.
Nested Class Summary | |
---|---|
protected class |
ThreadLogger.LoggerRunningThread
Class LoggerRunningThread defines a separate thread used to build and output the log file entries. |
Field Summary | |
---|---|
protected boolean |
closeOnTerminateFlag
|
protected java.lang.String |
errorMessageString
|
protected int |
intervalMSecs
|
protected ThreadLogger.LoggerRunningThread |
loggerRunningThreadObj
|
protected int |
logLevelVal
|
protected LogFile |
logObj
|
protected static java.lang.String |
newlineStr
|
protected boolean |
outputOnChangeFlag
|
protected java.lang.ThreadGroup |
rootThreadGroupObj
|
protected java.lang.StringBuffer |
stringBufferObj
|
protected int |
totalThreadCount
|
Constructor Summary | |
---|---|
ThreadLogger()
Creates a thread logger object with no log output file. |
|
ThreadLogger(LogFile logObj,
int intervalMSecs)
Creates a thread logger object and starts a new log-message-generation thread. |
|
ThreadLogger(java.lang.String logFileName,
int intervalMSecs)
Creates a thread logger object and starts a new log-message-generation thread. |
|
ThreadLogger(java.lang.String logFileName,
int intervalMSecs,
boolean useDateInFnameFlag)
Creates a thread logger object and starts a new log-message-generation thread. |
|
ThreadLogger(java.lang.String logFileName,
int intervalMSecs,
int maxLogFileAgeDays)
Creates a thread logger object and starts a new log-message-generation thread. |
|
ThreadLogger(java.lang.String logFileName,
int intervalMSecs,
int maxLogFileAgeDays,
int logFileSwitchIntervalDays)
Creates a thread logger object and starts a new log-message-generation thread. |
Method Summary | |
---|---|
void |
clearErrorMessageString()
Clears any current error message. |
protected boolean |
fetchThreadsInfo(java.lang.ThreadGroup threadGroupObj,
java.lang.String indentStr)
Enters information for all of the threads in the given ThreadGroup and all of its subgroups into the StringBuffer object. |
java.lang.String |
getErrorMessageString()
Returns the current error message (if any). |
static java.lang.ThreadGroup |
getRootThreadGroup()
Returns the root ThreadGroup object. |
static java.lang.String |
getThreadGroupInfoStr(java.lang.ThreadGroup threadGroupObj)
Returns an informational string about the given thread group. |
static java.lang.String |
getThreadInfoStr(java.lang.Thread threadObj)
Returns an informational string about the given thread. |
java.lang.String |
getThreadsInfoStr()
Returns an information string for all of the current threads. |
java.lang.String |
getThreadsInfoStr(boolean outChangeFlag)
Returns an information string for all of the current threads. |
boolean |
logThreadsInfo()
Logs information for all of the current threads. |
void |
setCloseLogOnTerminateFlag(boolean flgVal)
Sets whether or not the log file is closed when the logging thread terminates. |
void |
setConsoleOutputFlag(boolean flgVal)
Sets the flag to enable console output of log messages. |
void |
setLogLevelVal(int levelVal)
Sets the log-level value to be used. |
void |
setOutputOnChangeFlag(boolean flgVal)
Sets the flag that determines if threads information is logged only when a change is detected or all the time regardless. |
protected boolean |
setupRootThreadGroupObj()
Sets up the 'rootThreadGroupObj' handle. |
protected void |
startLoggerThread(int intervalMSecs)
Starts the thread-logging thread. |
void |
terminate()
Terminates the logging thread created by this ThreadLogger. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final LogFile logObj
protected int intervalMSecs
protected java.lang.StringBuffer stringBufferObj
protected boolean outputOnChangeFlag
protected java.lang.ThreadGroup rootThreadGroupObj
protected int totalThreadCount
protected java.lang.String errorMessageString
protected ThreadLogger.LoggerRunningThread loggerRunningThreadObj
protected static final java.lang.String newlineStr
protected int logLevelVal
protected boolean closeOnTerminateFlag
Constructor Detail |
---|
public ThreadLogger(LogFile logObj, int intervalMSecs)
logObj
- the LogFile object to use for output.intervalMSecs
- the number of milliseconds between log outputs.public ThreadLogger(java.lang.String logFileName, int intervalMSecs)
logFileName
- the name of the log file to be created and used
for output.intervalMSecs
- the number of milliseconds between log outputs.public ThreadLogger(java.lang.String logFileName, int intervalMSecs, boolean useDateInFnameFlag)
logFileName
- the name of the log file to be created and used
for output.intervalMSecs
- the number of milliseconds between log outputs.useDateInFnameFlag
- true to use the date in the file name (and
create a new log file every time the date changes).public ThreadLogger(java.lang.String logFileName, int intervalMSecs, int maxLogFileAgeDays)
logFileName
- the name of the log file to be created and used
for output.intervalMSecs
- the number of milliseconds between log outputs.maxLogFileAgeDays
- the maximum log file age, in days.public ThreadLogger(java.lang.String logFileName, int intervalMSecs, int maxLogFileAgeDays, int logFileSwitchIntervalDays)
logFileName
- the name of the log file to be created and used
for output.intervalMSecs
- the number of milliseconds between log outputs.maxLogFileAgeDays
- the maximum log file age, in days.logFileSwitchIntervalDays
- the minimum number of days between
log file switches via date changes.public ThreadLogger()
Method Detail |
---|
protected void startLoggerThread(int intervalMSecs)
intervalMSecs
- the number of milliseconds between log outputs.protected boolean setupRootThreadGroupObj()
public void setConsoleOutputFlag(boolean flgVal)
flgVal
- true to enable console output, false to disable.public void setOutputOnChangeFlag(boolean flgVal)
flgVal
- true to log only when a change is detected (the default),
false to send a log message at each interval regardless.public void setLogLevelVal(int levelVal)
levelVal
- the log-level value to be used.public void setCloseLogOnTerminateFlag(boolean flgVal)
flgVal
- true to close the log file on terminate, false to not.public void terminate()
public java.lang.String getThreadsInfoStr(boolean outChangeFlag)
outChangeFlag
- if false then the information string will always
be returned; if true then the information string will only be
returned when a change in the threads is detected, otherwise
'null' will be returned. If an error occurs while fetching the
thread information then 'null' will be returned. The error status
may be determined via the 'getErrorMessageString()' method.
public java.lang.String getThreadsInfoStr()
public boolean logThreadsInfo()
protected boolean fetchThreadsInfo(java.lang.ThreadGroup threadGroupObj, java.lang.String indentStr)
threadGroupObj
- the ThreadGroup to use.indentStr
- the indentation string to place in front of each
line of log output.
public java.lang.String getErrorMessageString()
public void clearErrorMessageString()
public static java.lang.ThreadGroup getRootThreadGroup()
public static java.lang.String getThreadInfoStr(java.lang.Thread threadObj)
threadObj
- the thread to use.
public static java.lang.String getThreadGroupInfoStr(java.lang.ThreadGroup threadGroupObj)
threadGroupObj
- the thread group to use.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |