public static class Logging.ReacquiringConsoleHandler extends java.util.logging.ConsoleHandler
ConsoleHandler
with a couple of extra features, allowing it to be targeted at an
an arbitrary OutputStream
which it can be asked to reaquire the reference for on demand
through reacquireOutputStream()
. It can also prevent a LogRecord's output if a
specified prioritizedHandler
would have outputted it.Modifier and Type | Field and Description |
---|---|
private java.io.OutputStream |
outputStreamMemo |
private java.util.function.Supplier<java.io.OutputStream> |
outputStreamSupplier |
private java.util.logging.Handler |
prioritizedHandler |
Constructor and Description |
---|
ReacquiringConsoleHandler(java.util.function.Supplier<java.io.OutputStream> outputStreamSupplier,
java.util.logging.Handler prioritizedHandler)
Construct a new
Logging.ReacquiringConsoleHandler . |
Modifier and Type | Method and Description |
---|---|
void |
publish(java.util.logging.LogRecord record) |
void |
reacquireOutputStream()
Set output stream to one acquired from calling outputStreamSupplier
|
void |
setOutputStream(java.io.OutputStream outputStream) |
private final java.util.function.Supplier<java.io.OutputStream> outputStreamSupplier
private final java.util.logging.Handler prioritizedHandler
private java.io.OutputStream outputStreamMemo
public ReacquiringConsoleHandler(java.util.function.Supplier<java.io.OutputStream> outputStreamSupplier, java.util.logging.Handler prioritizedHandler)
Logging.ReacquiringConsoleHandler
.outputStreamSupplier
- A Supplier
which will return the desired
OutputStream
for this handler when called. Particularly useful if you happen to be
using a test framework which will switch out references to the stderr/stdout streams with
new dummy ones from time to time.prioritizedHandler
- If non-null, will suppress output of any log records which pass this
handler's Handler#isLoggable(LogRecord)
method.public void reacquireOutputStream()
public void setOutputStream(java.io.OutputStream outputStream)
setOutputStream
in class java.util.logging.StreamHandler
public void publish(java.util.logging.LogRecord record)
publish
in class java.util.logging.ConsoleHandler