logahawk.listeners
Class StreamListener

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

@ThreadSafe
public class StreamListener
extends Object
implements Listener

A Listener that outputs log messages to the provided stream. This does not add a new-line or any other characters to the messages that are logged. This class is thread-safe if the Appendable and MessageFormatter are thread-safe.


Field Summary
protected  MessageFormatter formatter
           
protected  OutputStream out
           
 
Constructor Summary
StreamListener(OutputStream out)
           
StreamListener(OutputStream out, MessageFormatter formatter)
           
 
Method Summary
 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 final MessageFormatter formatter

out

protected final OutputStream out
Constructor Detail

StreamListener

public StreamListener(OutputStream out)

StreamListener

public StreamListener(OutputStream out,
                      MessageFormatter formatter)
Method Detail

log

public void log(LogMeta meta,
                String text)
         throws RuntimeException
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
Throws:
RuntimeException - Any Exceptions caught during a log attempt will be re-thrown as the inner exception of a RuntimeException.