Class BlockingQueueLogger

  extended by logahawk.AbstractLogger
      extended by logahawk.ProxyLogger
          extended by logahawk.BlockingQueueLogger
All Implemented Interfaces:

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
Fields inherited from interface logahawk.Logger
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


protected final BlockingQueue<LogEntry> queue


protected Thread thread
Constructor Detail


public BlockingQueueLogger(Logger logger)


public BlockingQueueLogger(Logger logger,
                           BlockingQueue<LogEntry> queue)
Method Detail


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


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.


public void stop()


protected void threadRun()