|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.rabbitmq.tools.Tracer.AsyncLogger
public static class Tracer.AsyncLogger
A Tracer.Logger designed to print Strings to a designated OutputStream
on a private thread.
Strings are read from a private queue and printed to a buffered PrintStream
which is periodically flushed.
When instantiated the private queue is created (an in-memory ArrayBlockingQueue in this
implementation) and when start()ed the private thread is created and started unless it is
already present. An Tracer.AsyncLogger may be started many times, but only one thread is created.
When stop()ed either the number of starts is decremented, or, if this count reaches zero,
a special element is queued which causes the private thread to end when encountered.
If the private thread is interrupted, the thread will also end, and the count set to zero,
This will cause subsequent stop()s to be ignored, and the next start() will create a new thread.
log(String) never blocks unless the private queue is full; this may never un-block if the Tracer.Logger is stopped.
| Constructor Summary | |
|---|---|
Tracer.AsyncLogger(java.io.OutputStream os)
Same as Tracer.AsyncLogger(OutputStream, int) with a one-second flush interval. |
|
Tracer.AsyncLogger(java.io.OutputStream os,
int flushInterval)
Start/stoppable logger that prints to an OutputStream with flushes every flushInterval milliseconds. |
|
| Method Summary | |
|---|---|
void |
log(java.lang.String message)
Write msg to the log. |
boolean |
start()
Start logging, that is, printing log entries written using Tracer.Logger.log(String). |
boolean |
stop()
Stop logging, that is, stop printing log entries written using Tracer.Logger.log(String). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Tracer.AsyncLogger(java.io.OutputStream os)
Tracer.AsyncLogger(OutputStream, int) with a one-second flush interval.
os - OutputStream to print to.
public Tracer.AsyncLogger(java.io.OutputStream os,
int flushInterval)
OutputStream with flushes every flushInterval milliseconds.
os - OutputStream to print to.flushInterval - in milliseconds, time between flushes.| Method Detail |
|---|
public void log(java.lang.String message)
Tracer.Logger
log in interface Tracer.Loggerpublic boolean start()
Tracer.LoggerTracer.Logger.log(String). Multiple successive starts are equivalent to a
single start.
start in interface Tracer.Loggertrue if start actually started the logger;
false otherwise.public boolean stop()
Tracer.LoggerTracer.Logger.log(String). Flush preceding writes. The logger can only be
stopped if started. Multiple successive stops are equivalent to a
single stop.
stop in interface Tracer.Loggertrue if stop actually stopped the logger;
false otherwise.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||