logahawk.listeners
Class BufferedListener

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

@ThreadSafe
public class BufferedListener
extends Object
implements Listener

A Listener implementation that buffers all log arguments (prior to any formatting). This class does not flush its entries


Nested Class Summary
static class BufferedListener.Entry
          A pure-data class that holds all the parts of each formatted log message.
 
Field Summary
protected  Queue<BufferedListener.Entry> entries
           
 
Constructor Summary
BufferedListener()
          Initializes the entries field with a ConcurrentLinkedQueue, which ensure the thread-safety of this class.
BufferedListener(Queue<BufferedListener.Entry> queue)
           
 
Method Summary
 Queue<BufferedListener.Entry> getEntries()
           
 void log(Severity severity, Date epoch, 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

entries

protected final Queue<BufferedListener.Entry> entries
Constructor Detail

BufferedListener

public BufferedListener()
Initializes the entries field with a ConcurrentLinkedQueue, which ensure the thread-safety of this class.


BufferedListener

public BufferedListener(Queue<BufferedListener.Entry> queue)
Parameters:
queue - The Queue instance to be used for the entries field. Note that this Queue must be thread-safe for this class to be thread-safe.
Method Detail

log

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

Specified by:
log in interface Listener

getEntries

public Queue<BufferedListener.Entry> getEntries()