Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

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.

Author:
Erich Schubert

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 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

Release 0.2.1 (2009-07-13_1605)