logahawk
Class BufferedLogger

java.lang.Object
  extended by logahawk.BufferedLogger
All Implemented Interfaces:
Logger

@ThreadSafe
public class BufferedLogger
extends Object
implements Logger

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


Field Summary
protected  Queue<List<Object>> entries
          The Queue used to hold log arguments.
 
Fields inherited from interface logahawk.Logger
LINE_SEPARATOR
 
Constructor Summary
BufferedLogger()
          Initializes the entries field with a ConcurrentLinkedQueue, which ensure the thread-safety of this class.
BufferedLogger(Queue<List<Object>> queue)
           
 
Method Summary
 void alert(Object... data)
           
 void debug(Object... data)
           
 void error(Object... data)
           
 void fatal(Object... data)
           
 Queue<List<Object>> getEntries()
           
 void info(Object... data)
           
 void log(Severity severity, Object... data)
           
 void panic(Object... data)
           
 void warn(Object... data)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entries

protected final Queue<List<Object>> entries
The Queue used to hold log arguments. The Queue should be thread-safe, as this class does no additional synchronizing beyond what the Queue provides. The default constructor initializes this to a ConcurrentLinkedQueue which ensures thread-safety. Each entry the log arguments from a single call to one of the various log messages, which is converted to a List using Arrays.asList(Object[])

Constructor Detail

BufferedLogger

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


BufferedLogger

public BufferedLogger(Queue<List<Object>> 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

alert

public void alert(Object... data)
Specified by:
alert in interface Logger

debug

public void debug(Object... data)
Specified by:
debug in interface Logger

error

public void error(Object... data)
Specified by:
error in interface Logger

fatal

public void fatal(Object... data)
Specified by:
fatal in interface Logger

info

public void info(Object... data)
Specified by:
info in interface Logger

log

public void log(Severity severity,
                Object... data)
Specified by:
log in interface Logger

panic

public void panic(Object... data)
Specified by:
panic in interface Logger

warn

public void warn(Object... data)
Specified by:
warn in interface Logger

getEntries

public Queue<List<Object>> getEntries()