com.ibm.as400.opnav
Class Monitor

java.lang.Object
  |
  +--com.ibm.as400.opnav.Monitor

public class Monitor
extends java.lang.Object

A utility class which provides centralized activity logging and error logging. Monitor is re-implemented on each UI platform so that Operations Navigator components needn't concern themselves with the details of how to log errors, exceptions, and activity traces.

During development, error messages and exceptions are logged to the Operations Navigator Java console. The console is enabled by setting the following Windows registry entry:

 HKEY_CURRENT_USER
   Software
     IBM
       Client Access
         CurrentVersion
           AS400 Operations Navigator
             Trace
               "JETRACE"="ON"
 
The console may also be enabled from within Java code by calling setConsoleEnabled.

In production, error messages and exceptions may be redirected to a specific log file or OutputStream.

Monitor is also the repository for information passed across the JNI interface from Operations Navigator. For example, the installation path for Operations Navigator Java native services is maintained by this object.

Since:
v4r2m0
See Also:
UIServices

Field Summary
static java.lang.String SHARED_LOG_FILE_NAME
          The name of the shared service log file to which Operations Navigator components should log information for use in problem determination.
 
Method Summary
static java.lang.String getInstallPath()
          Returns the install path.
static java.lang.String getLogFileName()
          Returns the log file name.
static java.io.OutputStream getLogStream()
          Returns the log stream.
static boolean isConsoleEnabled()
          Determines whether the Operations Navigator Java console is enabled.
static void logError(java.lang.Object errorData)
          Logs an error string to the current logging destination.
static void logThrowable(java.lang.Throwable e)
          Logs an exception to the current logging destination.
static void setConsoleEnabled(boolean enabled)
          Enables the Operations Navigator Java console.
static void setConsoleTitle(java.lang.String consoleTitle)
          Sets the title used for the Java console window.
static void setInstallPath(java.lang.String installPath)
          Sets the install path.
static void setLogFileName(java.lang.String fileName)
          Sets the log file name.
static void setLogStream(java.io.OutputStream stream)
          Sets the log stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHARED_LOG_FILE_NAME

public static java.lang.String SHARED_LOG_FILE_NAME
The name of the shared service log file to which Operations Navigator components should log information for use in problem determination.
Since:
v4r5m0
Method Detail

setLogFileName

public static void setLogFileName(java.lang.String fileName)
                           throws java.io.IOException
Sets the log file name. If the file exists, error data is appended to it. If the file does not exist, it is created.
Parameters:
fileName - the log file name. If null, output is written to the Java console if it is enabled; otherwise output is suppressed.
Throws:
java.io.IOException - if the file cannot be accessed
Since:
v4r2m0
See Also:
getLogFileName()

getLogFileName

public static java.lang.String getLogFileName()
Returns the log file name. Returns null if errors are being logged to the Java console, or if an OutputStream was specified on a call to setLogStream.
Returns:
the log file name
Since:
v4r2m0
See Also:
setLogFileName(java.lang.String), setLogStream(java.io.OutputStream)

setLogStream

public static void setLogStream(java.io.OutputStream stream)
                         throws java.io.IOException
Sets the log stream. This method allows Operations Navigator plugins to redirect errors generated by this package to the same OutputStream used by the plugin itself for logging errors.
Parameters:
stream - the OutputStream to which error data should be sent. If null, output goes to the Java console if it is enabled; otherwise output is suppressed.
Since:
v4r2m0
See Also:
getLogStream()

getLogStream

public static java.io.OutputStream getLogStream()
Returns the log stream. Returns null if errors are being logged to the Java console.
Returns:
the OutputStream to which error data is being sent
Since:
v4r2m0
See Also:
setLogStream(java.io.OutputStream)

logError

public static void logError(java.lang.Object errorData)
Logs an error string to the current logging destination.
Parameters:
errorData - the data to be logged
Since:
v4r2m0

logThrowable

public static void logThrowable(java.lang.Throwable e)
Logs an exception to the current logging destination.
Parameters:
e - the exception to be logged. The message will include the exception class name, the exception message if any, and a printout of the call stack.
Since:
v4r2m0

setConsoleEnabled

public static void setConsoleEnabled(boolean enabled)
Enables the Operations Navigator Java console. The console window allows developers to monitor activity in Java methods. Enabling the Java console redirects stdout and stderr to the console window. In addition, the output of logError and logThrowable are written to the console if no log stream has been set.
Parameters:
enabled - indicates whether the Java console should be enabled.
Since:
v4r2m0
See Also:
isConsoleEnabled(), setLogFileName(java.lang.String), setLogStream(java.io.OutputStream)

isConsoleEnabled

public static boolean isConsoleEnabled()
Determines whether the Operations Navigator Java console is enabled.
Returns:
true if the Java console is enabled; false otherwise.
Since:
v4r2m0
See Also:
setConsoleEnabled(boolean)

getInstallPath

public static java.lang.String getInstallPath()
Returns the install path. The install path identifies the local directory where the native services DLL resides. This is needed by UIServices.
Returns:
the install path for Operations Navigator native services.
Since:
v4r2m0
See Also:
UIServices

setInstallPath

public static void setInstallPath(java.lang.String installPath)
Sets the install path. The install path identifies the local directory where the native services DLL resides. This is passed across the JNI interface by Operations Navigator.
Parameters:
installPath - the install path for Operations Navigator native services.
Since:
v4r2m0
See Also:
UIServices

setConsoleTitle

public static void setConsoleTitle(java.lang.String consoleTitle)
Sets the title used for the Java console window. This string is passed in from C++ so that we don't have to define any MRI for this package.
Parameters:
consoleTitle - the title to be used for the Operations Navigator Java console window.
Since:
v4r2m0