logahawk
Class BlockingQueueLogger

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

@ThreadSafe
public class BlockingQueueLogger
extends Object
implements Logger

Queues log requests in a BlockingQueue, and a separate Logger to format and broadcast to Listeners in a separate Thread. Log requests are captured as LogEntrys and queued from the calling thread, and a Thread controlled by this class dequeues the LogEntrys and processes them. This class is useful where performance* of the calling thread is very important. The drawback is that the timestamps for messages may be slightly off.


Field Summary
protected  Logger logger
           
protected  BlockingQueue<LogEntry> queue
           
protected  Thread thread
           
 
Fields inherited from interface logahawk.Logger
LINE_SEPARATOR
 
Constructor Summary
BlockingQueueLogger(Logger logger)
           
BlockingQueueLogger(Logger logger, BlockingQueue<LogEntry> queue)
           
 
Method Summary
 void alert(Object... data)
           
 void debug(Object... data)
           
 void error(Object... data)
           
 void fatal(Object... data)
           
 void info(Object... data)
           
 void log(Severity severity, Object... data)
           
 void panic(Object... data)
           
 void start()
          Starts the Thread that will dequeue log messages and pass them to the constructor provided Logger.
 void stop()
           
 void warn(Object... data)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Logger logger

queue

protected final BlockingQueue<LogEntry> queue

thread

protected Thread thread
Constructor Detail

BlockingQueueLogger

public BlockingQueueLogger(Logger logger)

BlockingQueueLogger

public BlockingQueueLogger(Logger logger,
                           BlockingQueue<LogEntry> queue)
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

start

public void start()
Starts the Thread that will dequeue log messages and pass them to the constructor provided Logger. If a thread is already started this will do nothing.


stop

public void stop()