com.isti.util
Class MemoryInfoLogger

java.lang.Object
  extended by com.isti.util.MemoryInfoLogger

public class MemoryInfoLogger
extends java.lang.Object

Class MemoryInfoLogger defines a debugging utility that generates periodic log messages showing information about memory usage in a program. The messages are in the form "Memory info: total=#, free=#, diff=#", with each value in bytes. A new thread is created to generate the log messages.


Nested Class Summary
protected  class MemoryInfoLogger.LoggerRunningThread
          Class LoggerRunningThread defines a separate thread used to build and output the log file entries.
 
Field Summary
protected  java.io.PrintStream altOutputStream
           
protected  boolean closeOnTerminateFlag
           
protected  int intervalSeconds
           
protected  MemoryInfoLogger.LoggerRunningThread loggerRunningThreadObj
           
protected  int logLevelVal
           
protected  LogFile logObj
           
protected  java.lang.StringBuffer stringBufferObj
           
 
Constructor Summary
MemoryInfoLogger(LogFile logObj, int intervalSeconds)
          Creates a memory information logger object and starts a new log-message-generation thread.
MemoryInfoLogger(java.io.PrintStream stmObj, int intervalSeconds)
          Creates a memory information logger object and starts a new message-generation thread.
MemoryInfoLogger(java.lang.String logFileName, int intervalSeconds)
          Creates a memory information logger object and starts a new log-message-generation thread.
MemoryInfoLogger(java.lang.String logFileName, int intervalSeconds, boolean useDateInFnameFlag)
          Creates a memory information logger object and starts a new log-message-generation thread.
MemoryInfoLogger(java.lang.String logFileName, int intervalSeconds, int maxLogFileAgeDays)
          Creates a memory information logger object and starts a new log-message-generation thread.
MemoryInfoLogger(java.lang.String logFileName, int intervalSeconds, int maxLogFileAgeDays, int logFileSwitchIntervalDays)
          Creates a memory information logger object and starts a new log-message-generation thread.
 
Method Summary
protected  void logOutputStr(java.lang.String msgStr)
          Sends the given message to the output log file or stream.
 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.
protected  void startLoggerThread(int intervalSeconds)
          Starts the memory-information-logging thread.
 void terminate()
          Terminates the logging thread created by this MemoryInfoLogger.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logObj

protected final LogFile logObj

altOutputStream

protected final java.io.PrintStream altOutputStream

intervalSeconds

protected int intervalSeconds

stringBufferObj

protected java.lang.StringBuffer stringBufferObj

loggerRunningThreadObj

protected MemoryInfoLogger.LoggerRunningThread loggerRunningThreadObj

logLevelVal

protected int logLevelVal

closeOnTerminateFlag

protected boolean closeOnTerminateFlag
Constructor Detail

MemoryInfoLogger

public MemoryInfoLogger(LogFile logObj,
                        int intervalSeconds)
Creates a memory information logger object and starts a new log-message-generation thread.

Parameters:
logObj - the LogFile object to use for output.
intervalSeconds - the number of seconds between log outputs.

MemoryInfoLogger

public MemoryInfoLogger(java.lang.String logFileName,
                        int intervalSeconds)
Creates a memory information logger object and starts a new log-message-generation thread.

Parameters:
logFileName - the name of the log file to be created and used for output.
intervalSeconds - the number of seconds between log outputs.

MemoryInfoLogger

public MemoryInfoLogger(java.lang.String logFileName,
                        int intervalSeconds,
                        boolean useDateInFnameFlag)
Creates a memory information logger object and starts a new log-message-generation thread.

Parameters:
logFileName - the name of the log file to be created and used for output.
intervalSeconds - the number of seconds between log outputs.
useDateInFnameFlag - true to use the date in the file name (and create a new log file every time the date changes).

MemoryInfoLogger

public MemoryInfoLogger(java.lang.String logFileName,
                        int intervalSeconds,
                        int maxLogFileAgeDays)
Creates a memory information logger object and starts a new log-message-generation thread. The date is used in the file name and a new log file is created every time the date changes).

Parameters:
logFileName - the name of the log file to be created and used for output.
intervalSeconds - the number of seconds between log outputs.
maxLogFileAgeDays - the maximum log file age, in days.

MemoryInfoLogger

public MemoryInfoLogger(java.lang.String logFileName,
                        int intervalSeconds,
                        int maxLogFileAgeDays,
                        int logFileSwitchIntervalDays)
Creates a memory information logger object and starts a new log-message-generation thread. The date is used in the file name and a new log file is created every time the date changes).

Parameters:
logFileName - the name of the log file to be created and used for output.
intervalSeconds - the number of seconds between log outputs.
maxLogFileAgeDays - the maximum log file age, in days.
logFileSwitchIntervalDays - the minimum number of days between log file switches via date changes.

MemoryInfoLogger

public MemoryInfoLogger(java.io.PrintStream stmObj,
                        int intervalSeconds)
Creates a memory information logger object and starts a new message-generation thread.

Parameters:
stmObj - the stream object to use for output.
intervalSeconds - the number of seconds between log outputs.
Method Detail

startLoggerThread

protected void startLoggerThread(int intervalSeconds)
Starts the memory-information-logging thread.

Parameters:
intervalSeconds - the number of seconds between log outputs.

setConsoleOutputFlag

public void setConsoleOutputFlag(boolean flgVal)
Sets the flag to enable console output of log messages.

Parameters:
flgVal - true to enable console output, false to disable.

setLogLevelVal

public void setLogLevelVal(int levelVal)
Sets the log-level value to be used. The default value is 'LogFile.DEBUG'.

Parameters:
levelVal - the log-level value to be used.

setCloseLogOnTerminateFlag

public void setCloseLogOnTerminateFlag(boolean flgVal)
Sets whether or not the log file is closed when the logging thread terminates.

Parameters:
flgVal - true to close the log file on terminate, false to not.

terminate

public void terminate()
Terminates the logging thread created by this MemoryInfoLogger.


logOutputStr

protected void logOutputStr(java.lang.String msgStr)
Sends the given message to the output log file or stream.

Parameters:
msgStr - the message string to send.