RSE
Release 1.0

org.eclipse.rse.logging
Class Logger

java.lang.Object
  extended byorg.eclipse.rse.logging.Logger
All Implemented Interfaces:
EventListener, Preferences.IPropertyChangeListener

public class Logger
extends Object
implements Preferences.IPropertyChangeListener

Generic Logger class for handling Remote Systems logging and tracing.

The debug level is determined by a "debug_level" key in the preferences store of the plugin that owns this Logger instance.

The debug location is determined by a "log_location" key in the preferences store of the plugin that owns this Logger instance.

The valid values for these keys can be found in the javadocs for IRemoteSystemsLogging.
. This means that these keys could have been defined through hardcoding in your plugin startup code, through preferences.ini in the plugin install directory, OR from pref_store.ini in the plugin read/write metadata area.
The default behavior is to log to file, and to log only errors.
A typical usage of this class is as follows:

public class myPlugin extends AbstractUIPlugin {

// a cached Logger inst for convenience.
public static Logger out = null;

public myPlugin(IPluginDescriptor descriptor) {
super(descriptor);
......
......
out = LoggerFactory.getInst(this);
out.logInfo("loading myPlugin class.");
//out.logWarning("This is a warning message.");
//out.logError("This is an error.", new Exception());
//out.logDebugMessage(
// "myPlugin",
// "this is a debug message from class myPlugin.");
......
......
}


public void shutdown() throws CoreException {
super.shutdown();
LoggerFactory.freeInst(this);
}


Field Summary
static boolean DEBUG
          Constant can be used to surround debugging code.
 
Method Summary
 void freeResources()
           
 int getDebugLevel()
           
 void logDebugMessage(String className, String message)
          Log a Debug message.
 void logError(String message, Throwable ex)
          Log an Error message with an exception.
 void logInfo(String message)
          Log an Information message.
 void logInfo(String message, Throwable ex)
          Log an Information message.
 void logWarning(String message)
          Log a Warning message.
 void logWarning(String message, Throwable ex)
          Log a Warning message.
 void propertyChange(Preferences.PropertyChangeEvent event)
          Handle changes from a Preferences page.
 void setDebugLevel(int level)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static final boolean DEBUG
Constant can be used to surround debugging code. Optimizing compilers have the possibility of removing the code from a production copy. Should be set false normally. Only set to true when testing.

See Also:
Constant Field Values
Method Detail

logDebugMessage

public void logDebugMessage(String className,
                            String message)
Log a Debug message. This is intended to be used as follows:
Logger.logDebugMessage("someClassName", "someMessage");

and the output will be:

---------------------------------------------------------------
DEBUG org.eclipse.rse.logging someClassName
someMessage
---------------------------------------------------------------


Note that since this message is only for developer debugging, it does not need to be localized to proper local.


logError

public void logError(String message,
                     Throwable ex)
Log an Error message with an exception. Note that the message should already be localized to proper locale.

Parameters:
message - the message to log.
ex - the exception that caused the condition, may be null.

logInfo

public void logInfo(String message)
Log an Information message. Note that the message should already be localized to proper local.
ie: Resource.getString() should already have been called


logInfo

public void logInfo(String message,
                    Throwable ex)
Log an Information message. Note that the message should already be localized to proper local.
ie: Resource.getString() should already have been called


logWarning

public void logWarning(String message)
Log a Warning message. Note that the message should already be localized to proper local.
ie: Resource.getString() should already have been called


logWarning

public void logWarning(String message,
                       Throwable ex)
Log a Warning message. Note that the message should already be localized to proper local.
ie: Resource.getString() should already have been called


setDebugLevel

public void setDebugLevel(int level)

getDebugLevel

public int getDebugLevel()

freeResources

public void freeResources()

propertyChange

public void propertyChange(Preferences.PropertyChangeEvent event)
Handle changes from a Preferences page.

Specified by:
propertyChange in interface Preferences.IPropertyChangeListener

RSE
Release 1.0

Copyright (c) IBM Corporation and others 2000, 2006. All Rights Reserved.