logahawk
Class BlockingQueueLogger
java.lang.Object
logahawk.AbstractLogger
logahawk.ProxyLogger
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 Listener
s in a separate Thread
. Log requests are captured as LogEntry
s and queued from the calling
thread, and a Thread
controlled by this class dequeues the LogEntry
s 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.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
queue
protected final BlockingQueue<LogEntry> queue
thread
protected Thread thread
BlockingQueueLogger
public BlockingQueueLogger(Logger logger)
BlockingQueueLogger
public BlockingQueueLogger(Logger logger,
BlockingQueue<LogEntry> queue)
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()