Service Activator Toolkit
Version 1.1.0 (20081206)

org.eclipse.soda.sat.core.util
Class LogUtility

java.lang.Object
  extended by org.eclipse.soda.sat.core.util.LogUtility

public final class LogUtility
extends Object

The LogUtility class provides access to an instance of the OSGi defined interface LogService that is guaranteed to never change identity.

The class provides an implementation of the LogService whose identity never changes. This implementation must wrap a target instance of the LogService that can be changed. Operations on the LogService provided by this class will be delegated to the target LogService. The class also provides a way for the target LogService to be changed.

This class is an anomaly and should never needs to be used under normal circumstances. While coupling an application to the OSGi framework is rarely a good design choice, arguably there are benefits to allowing an application's business model to use the LogService. Therefore, this utility class provides static access to an implementation of the LogService.

This class also includes static methods as a convenient way of logging the four categories of message as defined by the LogService, namely:

For example, the following methods are provided for logging errors:

In addition to the following convenience static method have been provided for querying the current logging level:

The static method setLoggingLevel(int) may be used to set the current logging level to one of the LogService values defined above.

Note: This is a singleton class, accessible only via the static method getInstance(). For example:

 LogUtility utility = LogUtility.getInstance();
 LogService log = utility.getLog();
 

See Also:
LogService

Method Summary
static LogUtility getInstance()
          Public getter for the LogUtility singleton instance.
 LogService getLog()
          Get the org.osgi.service.log.LogService.
static int getLoggingLevel()
          Get the current logging level.
static boolean isLoggingDebug()
          Query whether debug messages are being logged.
static boolean isLoggingError()
          Query whether error messages are being logged.
static boolean isLoggingInfo()
          Query whether info messages are being logged.
static boolean isLoggingWarning()
          Query whether debug messages are being logged.
static boolean isTracing()
          Query the tracing field.
static void logDebug(Object id, String message)
          Log a LogService.LOG_DEBUG message.
static void logDebug(Object id, String message, Throwable throwable)
          Log a LogService.LOG_DEBUG level message.
static void logDebug(String message)
          Log a LogService.LOG_DEBUG message.
static void logDebug(String message, Throwable throwable)
          Log a LogService.LOG_DEBUG level message.
static void logError(Object id, String message)
          Log a LogService.LOG_ERROR message.
static void logError(Object id, String message, Throwable throwable)
          Log a LogService.LOG_ERROR level message.
static void logError(String message)
          Log a LogService.LOG_ERROR message.
static void logError(String message, Throwable throwable)
          Log a LogService.LOG_ERROR level message.
static void logInfo(Object id, String message)
          Log a LogService.LOG_INFO message.
static void logInfo(Object id, String message, Throwable throwable)
          Log a LogService.LOG_INFO level message.
static void logInfo(String message)
          Log a LogService.LOG_INFO message.
static void logInfo(String message, Throwable throwable)
          Log a LogService.LOG_INFO level message.
static void logTrace(Object id, String message)
          Log a LogService.DEBUG_INFO level trace message.
static void logTrace(Object id, String message, Throwable throwable)
          Log a LogService.DEBUG_INFO level trace message.
static void logTrace(String message)
          Log a LogService.DEBUG_INFO level trace message.
static void logTrace(String message, Throwable throwable)
          Log a LogService.DEBUG_INFO level trace message.
static void logWarning(Object id, String message)
          Log a LogService.LOG_INFO message.
static void logWarning(Object id, String message, Throwable throwable)
          Log a LogService.LOG_WARNING level message.
static void logWarning(String message)
          Log a LogService.LOG_WARNING message.
static void logWarning(String message, Throwable throwable)
          Log a LogService.LOG_WARNING level message.
 void setLog(LogService log)
          Set the org.osgi.service.log.LogService.
static void setLoggingLevel(int level)
          Set the current logging level.
static void setTracing(boolean tracing)
          Set the tracing field to true or false.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static LogUtility getInstance()
Public getter for the LogUtility singleton instance.

Returns:
The LogUtility singleton instance.

getLoggingLevel

public static int getLoggingLevel()
Get the current logging level.

Returns:
One of the org.osgi.service.log.LogService constants.

isLoggingDebug

public static boolean isLoggingDebug()
Query whether debug messages are being logged.

Returns:
True if debug message are being logged, otherwise false.

isLoggingError

public static boolean isLoggingError()
Query whether error messages are being logged.

Returns:
True if error message are being logged, otherwise false.

isLoggingInfo

public static boolean isLoggingInfo()
Query whether info messages are being logged.

Returns:
True if info message are being logged, otherwise false.

isLoggingWarning

public static boolean isLoggingWarning()
Query whether debug messages are being logged.

Returns:
True if debug message are being logged, otherwise false.

isTracing

public static boolean isTracing()
Query the tracing field. Answers true when tracing in on, and false when tracing is off.

Returns:
True if tracing is enabled, otherwise false.

logDebug

public static void logDebug(Object id,
                            String message)
Log a LogService.LOG_DEBUG message.

Parameters:
id - An object that uniquely identifies the source of the message to logged.
message - The message to log.

logDebug

public static void logDebug(Object id,
                            String message,
                            Throwable throwable)
Log a LogService.LOG_DEBUG level message.

Parameters:
id - An object that identifies who is logging the message.
message - The message that will be logged.
throwable - An accompanying Throwable.

logDebug

public static void logDebug(String message)
Log a LogService.LOG_DEBUG message.

Parameters:
message - The message to log.

logDebug

public static void logDebug(String message,
                            Throwable throwable)
Log a LogService.LOG_DEBUG level message.

Parameters:
message - The message that will be logged.
throwable - An accompanying Throwable.

logError

public static void logError(Object id,
                            String message)
Log a LogService.LOG_ERROR message.

Parameters:
id - An object that uniquely identifies the source of the message to logged.
message - The message to log.

logError

public static void logError(Object id,
                            String message,
                            Throwable throwable)
Log a LogService.LOG_ERROR level message.

Parameters:
id - An object that identifies who is logging the message.
message - The message that will be logged.
throwable - An accompanying Throwable.

logError

public static void logError(String message)
Log a LogService.LOG_ERROR message.

Parameters:
message - The message to log.

logError

public static void logError(String message,
                            Throwable throwable)
Log a LogService.LOG_ERROR level message.

Parameters:
message - The message that will be logged.
throwable - An accompanying Throwable.

logInfo

public static void logInfo(Object id,
                           String message)
Log a LogService.LOG_INFO message.

Parameters:
id - An object that uniquely identifies the source of the message to logged.
message - The message to log.

logInfo

public static void logInfo(Object id,
                           String message,
                           Throwable throwable)
Log a LogService.LOG_INFO level message.

Parameters:
id - An object that identifies who is logging the message.
message - The message that will be logged.
throwable - An accompanying Throwable.

logInfo

public static void logInfo(String message)
Log a LogService.LOG_INFO message.

Parameters:
message - The message to log.

logInfo

public static void logInfo(String message,
                           Throwable throwable)
Log a LogService.LOG_INFO level message.

Parameters:
message - The message that will be logged.
throwable - An accompanying Throwable.

logTrace

public static void logTrace(Object id,
                            String message)
Log a LogService.DEBUG_INFO level trace message.

Parameters:
id - An object that identifies who is logging the message.
message - The message that will be logged.

logTrace

public static void logTrace(Object id,
                            String message,
                            Throwable throwable)
Log a LogService.DEBUG_INFO level trace message.

Parameters:
id - An object that identifies who is logging the message.
message - The message that will be logged.
throwable - An accompanying Throwable.

logTrace

public static void logTrace(String message)
Log a LogService.DEBUG_INFO level trace message.

Parameters:
message - The message that will be logged.

logTrace

public static void logTrace(String message,
                            Throwable throwable)
Log a LogService.DEBUG_INFO level trace message.

Parameters:
message - The message that will be logged.
throwable - An accompanying Throwable.

logWarning

public static void logWarning(Object id,
                              String message)
Log a LogService.LOG_INFO message.

Parameters:
id - An object that uniquely identifies the source of the message to logged.
message - The message to log.

logWarning

public static void logWarning(Object id,
                              String message,
                              Throwable throwable)
Log a LogService.LOG_WARNING level message.

Parameters:
id - An object that identifies who is logging the message.
message - The message that will be logged.
throwable - An accompanying Throwable.

logWarning

public static void logWarning(String message)
Log a LogService.LOG_WARNING message.

Parameters:
message - The message to log.

logWarning

public static void logWarning(String message,
                              Throwable throwable)
Log a LogService.LOG_WARNING level message.

Parameters:
message - The message that will be logged.
throwable - An accompanying Throwable.

setLoggingLevel

public static void setLoggingLevel(int level)
Set the current logging level.

Parameters:
level - One of the org.osgi.service.log.LogService constants.

setTracing

public static void setTracing(boolean tracing)
Set the tracing field to true or false.

Parameters:
tracing - The value of true turns tracing on, and a value of false turns tracing off.

getLog

public LogService getLog()
Get the org.osgi.service.log.LogService.

Returns:
The log service.

setLog

public void setLog(LogService log)
Set the org.osgi.service.log.LogService.

Parameters:
log - A log service.

Service Activator Toolkit
Version 1.1.0 (20081206)