java.lang.Object | |
↳ | com.rabbitmq.tools.Tracer.AsyncLogger |
A Tracer.Logger
designed to print Strings to a designated OutputStream
on a private thread.
String
s are read from a private queue and printed to a buffered PrintStream
which is periodically flushed, determined by a #flushInterval.
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() never blocks unless the private queue is full; this may never un-block if the Tracer.Logger
is stopped.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Same as #AsyncLogger(os, flushInterval) with a one-second flush interval.
| |||||||||||
Start/stoppable logger that prints to an
OutputStream with flushes every flushInterval milliseconds. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Write msg to the log.
| |||||||||||
Start logging, that is, printing log entries written using
log(String) . | |||||||||||
Stop logging, that is, stop printing log entries written using
log(String) . |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
com.rabbitmq.tools.Tracer.Logger
|
Same as #AsyncLogger(os, flushInterval) with a one-second flush interval.
os | OutputStream to print to. |
---|
Start/stoppable logger that prints to an OutputStream
with flushes every flushInterval
milliseconds.
os | OutputStream to print to. |
---|---|
flushInterval | in milliseconds, time between flushes. |
Write msg to the log. This may block, and may block indefinitely if the logger is stopped.
Start logging, that is, printing log entries written using
log(String)
. Multiple successive starts are equivalent to a
single start.
true
if start actually started the logger;
false
otherwise.
Stop logging, that is, stop printing log entries written using
log(String)
. Flush preceding writes. The logger can only be
stopped if started. Multiple successive stops are equivalent to a
single stop.
true
if stop actually stopped the logger;
false
otherwise.