de.lmu.ifi.dbs.elki.logging
Class LoggingUtil

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.logging.LoggingUtil

public final class LoggingUtil
extends Object

This final class contains some static convenience methods for logging. logExpensive(java.util.logging.Level, java.lang.String, java.lang.Throwable) allows the programmer to easily emit a log message, however the function is rather expensive and thus should not be used within loop constructs.


Constructor Summary
LoggingUtil()
           
 
Method Summary
static void exception(String message, Throwable e)
          Static version to log a severe exception.
static void exception(Throwable e)
          Static version to log a severe exception.
private static String[] inferCaller()
          Infer which class has called the logging helper.
static void logExpensive(Level level, String message)
          Expensive logging function that is convenient, but should only be used in rare conditions.
static void logExpensive(Level level, String message, Throwable e)
          Expensive logging function that is convenient, but should only be used in rare conditions.
static void message(String message)
          Static version to log a 'info' message.
static void message(String message, Throwable e)
          Static version to log a 'info' message.
static void parseDebugParameter(StringParameter param)
          Parse the option string to configure logging.
static void warning(String message)
          Static version to log a warning message.
static void warning(String message, Throwable e)
          Static version to log a warning message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggingUtil

public LoggingUtil()
Method Detail

logExpensive

public static final void logExpensive(Level level,
                                      String message,
                                      Throwable e)
Expensive logging function that is convenient, but should only be used in rare conditions. For 'frequent' logging, use more efficient techniques, such as explained in the logging package documentation.

Parameters:
level - Logging level
message - Message to log.
e - Exception to report.

logExpensive

public static final void logExpensive(Level level,
                                      String message)
Expensive logging function that is convenient, but should only be used in rare conditions. For 'frequent' logging, use more efficient techniques, such as explained in the logging package documentation.

Parameters:
level - Logging level
message - Message to log.

exception

public static final void exception(Throwable e)
Static version to log a severe exception.

Parameters:
e - Exception to log

exception

public static final void exception(String message,
                                   Throwable e)
Static version to log a severe exception.

Parameters:
message - Exception message, may be null (defaults to e.getMessage())
e - causing exception

warning

public static final void warning(String message)
Static version to log a warning message.

Parameters:
message - Warning message.

warning

public static final void warning(String message,
                                 Throwable e)
Static version to log a warning message.

Parameters:
message - Warning message, may be null (defaults to e.getMessage())
e - causing exception

message

public static final void message(String message)
Static version to log a 'info' message.

Parameters:
message - Warning message.

message

public static final void message(String message,
                                 Throwable e)
Static version to log a 'info' message.

Parameters:
message - Warning message, may be null (defaults to e.getMessage())
e - causing exception

inferCaller

private static final String[] inferCaller()
Infer which class has called the logging helper. While this looks like duplicated code from ELKILogRecord, it is needed here to find an appropriate Logger (and check the logging level) for the calling class, not just to log the right class and method name.

Returns:
calling class name and calling method name

parseDebugParameter

public static final void parseDebugParameter(StringParameter param)
                                      throws WrongParameterValueException
Parse the option string to configure logging.

Parameters:
param - Parameter to process.
Throws:
WrongParameterValueException - On parsing errors

Release 0.4.0 (2011-09-20_1324)