logahawk
Class BlockingQueueLogger

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

@ThreadSafe
public class BlockingQueueLogger
extends ProxyLogger

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

Field Detail

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

log

public void log(Severity severity,
                Object... data)
Description copied from interface: Logger
Logs message with a provide Severity. Useful for dynamically determined Severity messages.

Specified by:
log in interface Logger
Specified by:
log in class AbstractLogger

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()

threadRun

protected void threadRun()