Enterprise Information Portal APIs

com.ibm.mm.beans.util
Class CMBTraceLog

java.lang.Object
  |
  +--com.ibm.mm.beans.util.CMBTraceLog
All Implemented Interfaces:
CMBTraceListener, CMBUtilConstant, java.util.EventListener, java.beans.PropertyChangeListener, java.io.Serializable

public class CMBTraceLog
extends java.lang.Object
implements java.io.Serializable, java.beans.PropertyChangeListener, CMBTraceListener, CMBUtilConstant

The CMBTraceLog utility bean handles trace events generated by other beans. The user of the bean can configure the handling of trace messages at each level individually. For each level, trace messages can be:

Summary of properties and events:

   imported properties   GUI look and feel style, use default GUI literal,
                         will not veto
   exported properties   none
   standalone properties window title, mute when trace message displayed,
                         message display mode, display enabled for each level,
                         log enalbed for each level, and button labels
   interested in events  CMBTraceEvent            - to service trace
                         PropertyChangeEvent      - to import traceEnabled
   source of events      none
 

Since:
6.1
See Also:
CMBTraceEvent, Serialized Form

Field Summary
static int CMB_LOG_DEBUG
           
static int CMB_LOG_ERROR
           
static int CMB_LOG_TRACE
           
static java.lang.String LOG_FILE_NAME
          The default trace log file name.
 
Fields inherited from interface com.ibm.mm.beans.util.CMBUtilConstant
DISPLAY_MESSAGE_IN_WINDOW, DISPLAY_MESSAGE_ON_STDERR, DISPLAY_MESSAGE_ON_STDOUT, LOOK_AND_FEEL_METAL, LOOK_AND_FEEL_MOTIF, LOOK_AND_FEEL_WINDOWS, PROP_CANCEL_LABEL, PROP_CLEAR_LABEL, PROP_CLOSE_LABEL, PROP_DEBUG_DISPLAY_ENABLED, PROP_DEBUG_LOG_ENABLED, PROP_DEFAULT_GUI_LITERAL, PROP_ERROR_DISPLAY_ENABLED, PROP_ERROR_LOG_ENABLED, PROP_LOG_FULLPATH, PROP_LOG_SESSION_EPILOGUE, PROP_LOG_SESSION_PROLOGUE, PROP_LOOK_AND_FEEL_STYLE, PROP_MESSAGE_DISPLAY_MODE, PROP_MESSAGE_MUTE, PROP_MUTE_LABEL, PROP_OK_LABEL, PROP_PROGRESS_DISPLAY_ENABLED, PROP_PROGRESS_LOG_ENABLED, PROP_SAVE_AS_LABEL, PROP_SAVE_LABEL, PROP_STACK_LABEL, PROP_WINDOW_TITLE, TRACE_LEVEL_DEBUG, TRACE_LEVEL_ERROR, TRACE_LEVEL_PROGRESS
 
Constructor Summary
CMBTraceLog()
          Constructor.
 
Method Summary
 boolean closeLogFile()
          Write the closing messages and close the log file with a timestamp.
 void finalize()
          Destructor, close the log file, dispose the window.
 java.lang.String getClearLabel()
          Get clear button label.
 java.lang.String getCloseLabel()
          Get close button label.
 int getDisplayMode()
          Get message display mode property.
 java.lang.String getLogFullpath()
          Get the log file fullpath property.
 java.lang.String getLogSessionEpilogue()
          Get the log session ending message property.
 java.lang.String getLogSessionPrologue()
          Get the log session starting message property.
 java.lang.String getMuteLabel()
          Get mute checkbox label.
 int getPriority()
          returns logging priority
 java.awt.Component getRootNode()
          Get the window frame, may be used for updating GUI look and feel style.
 java.lang.String getWindowTitle()
          Get window title.
 boolean isDebugDisplayEnabled()
          Get display enabled option for debugging message.
 boolean isDebugLogEnabled()
          Get log enabled option for debugging messages.
 boolean isDefaultGuiLiteral()
          Get use default GUI literal property value.
 boolean isErrorDisplayEnabled()
          Get display enabled option for error information.
 boolean isErrorLogEnabled()
          Get log enabled option for error information.
 boolean isMute()
          Get mute when display messages property value.
 boolean isProgressDisplayEnabled()
          Get display enabled option for progress information.
 boolean isProgressLogEnabled()
          Get log enabled option for progress information.
 boolean isVisible()
          Query if the trace console is visiable.
 boolean logMessage(java.lang.String message)
          Log the trace messages.
 void onCMBTrace(CMBTraceEvent evt)
          When a MessageEvent received, this is the method that gets called.
 boolean openLogFile()
          Open the log file and write starting messages with a timestamp for each application session.
 void propertyChange(java.beans.PropertyChangeEvent evt)
          PropertyChangeEvent service routine, to import the "GUI look and feel" and "use default GUI literal" property values.
 void setClearLabel(java.lang.String newValue)
          Set clear button label.
 void setCloseLabel(java.lang.String newValue)
          Set close button label.
 void setDebugDisplayEnabled(boolean newValue)
          Set display enabled option for debugging message.
 void setDebugLogEnabled(boolean newValue)
          Set log enabled option for debugging messages.
 void setDefaultGuiLiteral(boolean newValue)
          When turned on, all the GUI literal will be re-loaded from the resource file.
 void setDisplayMode(int newValue)
          Set message display mode property.
 void setErrorDisplayEnabled(boolean newValue)
          Set display enabled option for error information.
 void setErrorLogEnabled(boolean newValue)
          Set log enabled option for error information.
 void setLogFullpath(java.lang.String newValue)
          Set the log file fullpath property.
 void setLogSessionEpilogue(java.lang.String newValue)
          Set the log session ending message property.
 void setLogSessionPrologue(java.lang.String newValue)
          set the log session starting message property.
 void setMute(boolean newValue)
          Set mute property.
 void setMuteLabel(java.lang.String newValue)
          Set mute checkbox label.
 void setPriority(int priority)
          sets logging priority log level supported: CMB_LOG_ERROR, CMB_LOG_TRACE, CMB_LOG_DEBUG
 void setProgressDisplayEnabled(boolean newValue)
          Set display enabled option for progress information.
 void setProgressLogEnabled(boolean newValue)
          Set log enabled option for progress information.
 void setVisible(boolean visible)
          Show or hide the trace console.
 void setWindowTitle(java.lang.String newValue)
          Set window title.
 void showMessage(java.lang.String message)
          Display the trace messages, in the way specified in the display mode property.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_FILE_NAME

public static final java.lang.String LOG_FILE_NAME
The default trace log file name. Defaulting current directory.

CMB_LOG_TRACE

public static final int CMB_LOG_TRACE

CMB_LOG_DEBUG

public static final int CMB_LOG_DEBUG

CMB_LOG_ERROR

public static final int CMB_LOG_ERROR
Constructor Detail

CMBTraceLog

public CMBTraceLog()
Constructor. Will open the log file.
Method Detail

finalize

public void finalize()
Destructor, close the log file, dispose the window. Bean user is responsible to call this method to close the log file and dispose the window.
Overrides:
finalize in class java.lang.Object

onCMBTrace

public void onCMBTrace(CMBTraceEvent evt)
When a MessageEvent received, this is the method that gets called. It identifies the trace level from the event and display/log the trace messages depending on that level's settings.
Specified by:
onCMBTrace in interface CMBTraceListener
Parameters:
evt - a message event

setPriority

public void setPriority(int priority)
sets logging priority log level supported: CMB_LOG_ERROR, CMB_LOG_TRACE, CMB_LOG_DEBUG
Parameters:
priority - the logging priority
Since:
8.1

getPriority

public int getPriority()
returns logging priority
Since:
8.1

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
PropertyChangeEvent service routine, to import the "GUI look and feel" and "use default GUI literal" property values.
Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
evt - a prpoerty changed event

getLogSessionPrologue

public java.lang.String getLogSessionPrologue()
Get the log session starting message property.
Returns:
log session starting message

setLogSessionPrologue

public void setLogSessionPrologue(java.lang.String newValue)
set the log session starting message property.
Parameters:
newValue - new log session starting message

getLogSessionEpilogue

public java.lang.String getLogSessionEpilogue()
Get the log session ending message property.

setLogSessionEpilogue

public void setLogSessionEpilogue(java.lang.String newValue)
Set the log session ending message property.
Parameters:
newValue - new log session ending message

getLogFullpath

public java.lang.String getLogFullpath()
Get the log file fullpath property.
Returns:
the log file name with fullpath

setLogFullpath

public void setLogFullpath(java.lang.String newValue)
Set the log file fullpath property.
Parameters:
newValue - the new log file name with fullpath

isProgressLogEnabled

public boolean isProgressLogEnabled()
Get log enabled option for progress information.
Returns:
progress information log option value

setProgressLogEnabled

public void setProgressLogEnabled(boolean newValue)
Set log enabled option for progress information.
Parameters:
newValue - new progress information log option value

isDebugLogEnabled

public boolean isDebugLogEnabled()
Get log enabled option for debugging messages.
Returns:
debug message log option value

setDebugLogEnabled

public void setDebugLogEnabled(boolean newValue)
Set log enabled option for debugging messages.
Parameters:
newValue - new debug message log option value

isErrorLogEnabled

public boolean isErrorLogEnabled()
Get log enabled option for error information.
Returns:
error information log option value

setErrorLogEnabled

public void setErrorLogEnabled(boolean newValue)
Set log enabled option for error information.
Parameters:
newValue - new error information log option value

isProgressDisplayEnabled

public boolean isProgressDisplayEnabled()
Get display enabled option for progress information.
Returns:
progress information visually display option value

setProgressDisplayEnabled

public void setProgressDisplayEnabled(boolean newValue)
Set display enabled option for progress information.
Parameters:
newValue - new progress information visually display option value

isDebugDisplayEnabled

public boolean isDebugDisplayEnabled()
Get display enabled option for debugging message.
Returns:
debug message visually display option value

setDebugDisplayEnabled

public void setDebugDisplayEnabled(boolean newValue)
Set display enabled option for debugging message.
Parameters:
newValue - new debug message visually display option value

isErrorDisplayEnabled

public boolean isErrorDisplayEnabled()
Get display enabled option for error information.
Returns:
error information visually display option value

setErrorDisplayEnabled

public void setErrorDisplayEnabled(boolean newValue)
Set display enabled option for error information.
Parameters:
newValue - new error information visually display option value

getDisplayMode

public int getDisplayMode()
Get message display mode property.
Returns:
message display mode

setDisplayMode

public void setDisplayMode(int newValue)
Set message display mode property. Can be: DISPLAY_MESSAGE_ON_STDERR or DISPLAY_MESSAGE_ON_STDOUT or DISPLAY_MESSAGE_IN_WINDOW This method also show/hide the window accordingly.
Parameters:
newValue - new message display mode

isDefaultGuiLiteral

public boolean isDefaultGuiLiteral()
Get use default GUI literal property value.
Returns:
use the default GUI literal

setDefaultGuiLiteral

public void setDefaultGuiLiteral(boolean newValue)
When turned on, all the GUI literal will be re-loaded from the resource file.
Parameters:
newValue - new use default GUI literal option

getWindowTitle

public java.lang.String getWindowTitle()
Get window title.
Returns:
window title

setWindowTitle

public void setWindowTitle(java.lang.String newValue)
Set window title.
Parameters:
newValue - new window title

isMute

public boolean isMute()
Get mute when display messages property value.
Returns:
mute setting

setMute

public void setMute(boolean newValue)
Set mute property.
Parameters:
newValue - new mute setting value

getCloseLabel

public java.lang.String getCloseLabel()
Get close button label.
Returns:
close button label

setCloseLabel

public void setCloseLabel(java.lang.String newValue)
Set close button label.
Parameters:
newValue - new close button label

getMuteLabel

public java.lang.String getMuteLabel()
Get mute checkbox label.
Returns:
mute checkbox label

setMuteLabel

public void setMuteLabel(java.lang.String newValue)
Set mute checkbox label.
Parameters:
newValue - new mute checkbox label

getClearLabel

public java.lang.String getClearLabel()
Get clear button label.
Returns:
clear button label

setClearLabel

public void setClearLabel(java.lang.String newValue)
Set clear button label.
Parameters:
newValue - new clear button label

openLogFile

public boolean openLogFile()
Open the log file and write starting messages with a timestamp for each application session. Will append data if log file exists. Method resolves exceptions, if any. Note, each session will have starting message recorded as a minimum, even if all levels of trace log options are disabled.
Returns:
true if open succeeds, otherwise false

logMessage

public boolean logMessage(java.lang.String message)
Log the trace messages. Will start with current date time and end with a newline for each call. Method resolves exceptions, if any.
Parameters:
message - the message to record
Returns:
true if write succeeds, otherwise false

closeLogFile

public boolean closeLogFile()
Write the closing messages and close the log file with a timestamp. Method resolves exceptions, if any. Note, application is responsible to call this method to close the log file before exits.
Returns:
true if close succeeds, otherwise false

showMessage

public void showMessage(java.lang.String message)
Display the trace messages, in the way specified in the display mode property.
Parameters:
message - the message text string

setVisible

public void setVisible(boolean visible)
Show or hide the trace console. Effective only if the display mode is DISPLAY_MESSAGE_IN_WINDOW.
Parameters:
visible - true or false

isVisible

public boolean isVisible()
Query if the trace console is visiable.
Returns:
true or false

getRootNode

public java.awt.Component getRootNode()
Get the window frame, may be used for updating GUI look and feel style.
Returns:
the window frame

EIP JavaBeans

(c) Copyright International Business Machines Corporation 1996, 2002. IBM Corp. All rights reserved.