com.sun.sgs.impl.sharedutil
Class LoggerWrapper

java.lang.Object
  extended by com.sun.sgs.impl.sharedutil.LoggerWrapper

public class LoggerWrapper
extends Object

Wrapper around a Logger that provides convenience methods for logging exceptions and messages with multiple arguments, and that insulates the caller from unchecked exceptions thrown during the act of logging.


Constructor Summary
LoggerWrapper(Logger logger)
          Creates an instance that delegates to the given Logger.
 
Method Summary
 Logger getLogger()
          Returns the wrapped Logger.
 boolean isLoggable(Level level)
          Returns the result of invoking isLoggable on the wrapped Logger.
 void log(Level level, String message)
          If calling isLoggable with the given level value on the wrapped Logger returns true, invokes the log method of the wrapped Logger, passing a LogRecord constructed with the given level and message values.
 void log(Level level, String message, Object... params)
          If calling isLoggable with the given level value on the wrapped Logger returns true, invokes the log method of the wrapped Logger, passing a LogRecord constructed with the given level and message values.
 void log(Level level, String message, Object param)
          If calling isLoggable with the given level value on the wrapped Logger returns true, invokes the log method of the wrapped Logger, passing a LogRecord constructed with the given level and message values.
 void log(Level level, String message, Throwable param)
          Deprecated. 
 void log(Level level, String message, Throwable param, Object... otherParams)
          Deprecated. 
 void logThrow(Level level, Throwable thrown, String message)
          If calling isLoggable with the given level value on the wrapped Logger returns true, invokes the log method of the wrapped Logger, passing a LogRecord constructed with the given level and message values.
 void logThrow(Level level, Throwable thrown, String message, Object... params)
          If calling isLoggable with the given level value on the wrapped Logger returns true, invokes the log method of the wrapped Logger, passing a LogRecord constructed with the given level and message values.
 void logThrow(Level level, Throwable thrown, String message, Object param)
          If calling isLoggable with the given level value on the wrapped Logger returns true, invokes the log method of the wrapped Logger, passing a LogRecord constructed with the given level and message values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggerWrapper

public LoggerWrapper(Logger logger)
Creates an instance that delegates to the given Logger.

Parameters:
logger - the Logger to wrap
Method Detail

getLogger

public Logger getLogger()
Returns the wrapped Logger.

Returns:
the wrapped Logger

isLoggable

public boolean isLoggable(Level level)
Returns the result of invoking isLoggable on the wrapped Logger.

Parameters:
level - the level at which to check if logging is enabled
Returns:
the result of invoking isLoggable on the wrapped Logger

log

public void log(Level level,
                String message)
If calling isLoggable with the given level value on the wrapped Logger returns true, invokes the log method of the wrapped Logger, passing a LogRecord constructed with the given level and message values. The source class name and source method name of the LogRecord are set to the class and method names of the caller of this method, if they can be determined. Any exceptions or errors thrown by the underlying log call are swallowed.

Parameters:
level - the level at which to log
message - the log message, which can be null

log

public void log(Level level,
                String message,
                Object param)
If calling isLoggable with the given level value on the wrapped Logger returns true, invokes the log method of the wrapped Logger, passing a LogRecord constructed with the given level and message values. The given param value is set as the sole parameter of the LogRecord. The source class name and source method name of the LogRecord are set to the class and method names of the caller of this method, if they can be determined. Any exceptions or errors thrown by the underlying log call are swallowed.

Parameters:
level - the level at which to log
message - the log message, which can be null
param - the parameter value for the log message, which can be null

log

public void log(Level level,
                String message,
                Object... params)
If calling isLoggable with the given level value on the wrapped Logger returns true, invokes the log method of the wrapped Logger, passing a LogRecord constructed with the given level and message values. The given params values are set as the parameters of the LogRecord. The source class name and source method name of the LogRecord are set to the class and method names of the caller of this method, if they can be determined. Any exceptions or errors thrown by the underlying log call are swallowed.

Parameters:
level - the level at which to log
message - the log message, which can be null
params - the parameter values for the log message, which can be null

logThrow

public void logThrow(Level level,
                     Throwable thrown,
                     String message)
If calling isLoggable with the given level value on the wrapped Logger returns true, invokes the log method of the wrapped Logger, passing a LogRecord constructed with the given level and message values. The thrown value is set as the Throwable value associated with the LogRecord. The source class name and source method name of the LogRecord are set to the class and method names of the caller of this method, if they can be determined. Any exceptions or errors thrown by the underlying log call are swallowed.

Parameters:
level - the level at which to log
thrown - the Throwable associated with the log message
message - the log message, which can be null

logThrow

public void logThrow(Level level,
                     Throwable thrown,
                     String message,
                     Object param)
If calling isLoggable with the given level value on the wrapped Logger returns true, invokes the log method of the wrapped Logger, passing a LogRecord constructed with the given level and message values. The thrown value is set as the Throwable value associated with the LogRecord. The given param value is set as the sole parameter of the LogRecord. The source class name and source method name of the LogRecord are set to the class and method names of the caller of this method, if they can be determined. Any exceptions or errors thrown by the underlying log call are swallowed.

Parameters:
level - the level at which to log
thrown - the Throwable associated with the log message
message - the log message, which can be null
param - the parameter value for the log message, which can be null

logThrow

public void logThrow(Level level,
                     Throwable thrown,
                     String message,
                     Object... params)
If calling isLoggable with the given level value on the wrapped Logger returns true, invokes the log method of the wrapped Logger, passing a LogRecord constructed with the given level and message values. The thrown value is set as the Throwable value associated with the LogRecord. The given params values are set as the parameters of the LogRecord. The source class name and source method name of the LogRecord are set to the class and method names of the caller of this method, if they can be determined. Any exceptions or errors thrown by the underlying log call are swallowed.

Parameters:
level - the level at which to log
thrown - the Throwable associated with the log message
message - the log message, which can be null
params - the parameter values for the log message, which can be null

log

@Deprecated
public void log(Level level,
                           String message,
                           Throwable param)
Deprecated. 

If calling isLoggable with the given level value on the wrapped Logger returns true, invokes the log method of the wrapped Logger, passing a LogRecord constructed with the given level and message values. The given param value is set as the sole parameter of the LogRecord. The source class name and source method name of the LogRecord are set to the class and method names of the caller of this method, if they can be determined. Any exceptions or errors thrown by the underlying log call are swallowed.

This method is deprecated to flag any possible confusion of this method with the logThrow method. If the caller intends to include a Throwable as a parameter value in the log method, rather than including its stack trace by calling logThrow, it can cast the parameter to type Object to avoid the deprecation warning.

Parameters:
level - the level at which to log
message - the log message, which can be null
param - the parameter value for the log message, which can be null

log

@Deprecated
public void log(Level level,
                           String message,
                           Throwable param,
                           Object... otherParams)
Deprecated. 

If calling isLoggable with the given level value on the wrapped Logger returns true, invokes the log method of the wrapped Logger, passing a LogRecord constructed with the given level and message values. The given param and otherParams values are set as the parameters of the LogRecord. The source class name and source method name of the LogRecord are set to the class and method names of the caller of this method, if they can be determined. Any exceptions or errors thrown by the underlying log call are swallowed.

This method is deprecated to flag any possible confusion of this method with the logThrow method. If the caller intends to include a Throwable as a parameter value in the log method, rather than including its stack trace by calling logThrow, it can cast the first parameter to type Object to avoid the deprecation warning.

Parameters:
level - the level at which to log
message - the log message, which can be null
param - the parameter value for the log message, which can be null
otherParams - additional parameter values for the log message, which can be null

Project Darkstar, Version 0.9.9.4
2013-07-29 20:49:18

Copyright © 2007-2013 Sun Microsystems, Inc. All rights reserved