logahawk.listeners
Class JavaLoggerListener

java.lang.Object
  extended by logahawk.listeners.JavaLoggerListener
All Implemented Interfaces:
Listener

@ThreadSafe
public class JavaLoggerListener
extends Object
implements Listener

A Listener that uses the Java Logging API to perform the actual logging. This implementation immediately checks Logger.isLoggable(Level) to circumvent doing any unnecessary logging and formatting.


Field Summary
protected  MessageFormatter formatter
           
protected  Logger logger
           
 
Constructor Summary
JavaLoggerListener(Logger logger)
           
JavaLoggerListener(Logger logger, MessageFormatter formatter)
           
JavaLoggerListener(String name)
           
JavaLoggerListener(String name, MessageFormatter formatter)
           
 
Method Summary
protected  Level convert(Severity severity)
          Converts our "Severity" into a Java Logging API "Level" object.
 void log(LogMeta meta, String text)
          Logs the provided statement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

formatter

protected volatile MessageFormatter formatter

logger

protected volatile Logger logger
Constructor Detail

JavaLoggerListener

public JavaLoggerListener(Logger logger)

JavaLoggerListener

public JavaLoggerListener(String name)

JavaLoggerListener

public JavaLoggerListener(String name,
                          MessageFormatter formatter)

JavaLoggerListener

public JavaLoggerListener(Logger logger,
                          MessageFormatter formatter)
Method Detail

log

public void log(LogMeta meta,
                String text)
Description copied from interface: Listener
Logs the provided statement. Normally this method should not throw any exceptions. If exceptions are expected it is recommend to wrap this Listener with a FailSafeListener.

Specified by:
log in interface Listener

convert

protected Level convert(Severity severity)
Converts our "Severity" into a Java Logging API "Level" object. This will do the best job it can in providing a correct mapping, but there may be a single "Level" may be used for multiple "Severity" objects.