Package org.openstreetmap.josm.tools
Class Logging.ReacquiringConsoleHandler
java.lang.Object
java.util.logging.Handler
java.util.logging.StreamHandler
java.util.logging.ConsoleHandler
org.openstreetmap.josm.tools.Logging.ReacquiringConsoleHandler
- Enclosing class:
- Logging
A
ConsoleHandler with a couple of extra features, allowing it to be targeted at an
an arbitrary OutputStream which it can be asked to reacquire the reference for on demand
through reacquireOutputStream(). It can also prevent a LogRecord's output if a
specified prioritizedHandler would have outputted it.- Since:
- 14052
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate OutputStreamprivate final Supplier<OutputStream>private final Handlerprivate final booleanThis variables is set to true as soon as the superconstructor has completed. -
Constructor Summary
ConstructorsConstructorDescriptionReacquiringConsoleHandler(Supplier<OutputStream> outputStreamSupplier, Handler prioritizedHandler) Construct a newLogging.ReacquiringConsoleHandler. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidSet output stream to one acquired from calling outputStreamSuppliervoidsetOutputStream(OutputStream outputStream) Methods inherited from class java.util.logging.ConsoleHandler
closeMethods inherited from class java.util.logging.StreamHandler
flush, isLoggable, setEncodingMethods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, reportError, setErrorManager, setFilter, setFormatter, setLevel
-
Field Details
-
outputStreamSupplier
-
prioritizedHandler
-
outputStreamMemo
-
superCompleted
This variables is set to true as soon as the superconstructor has completed. The superconstructor callssetOutputStream(System.err), any subsequent call ofsetOutputStream(OutputStream)would then flush and closeSystem.err. To avoid this, we overridesetOutputStream(OutputStream)to completely ignore all calls from the superconstructor.
-
-
Constructor Details
-
ReacquiringConsoleHandler
public ReacquiringConsoleHandler(Supplier<OutputStream> outputStreamSupplier, Handler prioritizedHandler) Construct a newLogging.ReacquiringConsoleHandler.- Parameters:
outputStreamSupplier- ASupplierwhich will return the desiredOutputStreamfor 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'sHandler#isLoggable(LogRecord)method.
-
-
Method Details
-
reacquireOutputStream
Set output stream to one acquired from calling outputStreamSupplier -
setOutputStream
- Overrides:
setOutputStreamin classStreamHandler
-
publish
- Overrides:
publishin classConsoleHandler
-