java.lang.Object
java.util.logging.Handler
org.jboss.logmanager.ExtHandler
org.jboss.logmanager.handlers.WriterHandler
org.jboss.logmanager.handlers.OutputStreamHandler
org.jboss.logmanager.handlers.ConsoleHandler
- All Implemented Interfaces:
Flushable,AutoCloseable
A console handler which writes to
System.out by default.-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class org.jboss.logmanager.ExtHandler
handlers, handlersUpdater, lock -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new instance.ConsoleHandler(Formatter formatter) Construct a new instance.ConsoleHandler(ConsoleHandler.Target target) Construct a new instance.ConsoleHandler(ConsoleHandler.Target target, Formatter formatter) Construct a new instance. -
Method Summary
Modifier and TypeMethodDescriptionGet the local error manager.static booleanDetermine whether the console exists.static booleanDetermine whether the console can be passively detected to support graphical output.static booleanDetermine whether the console supports truecolor output.voidvoidsetOutputStream(OutputStream outputStream) Set the output stream to write to.voidsetTarget(ConsoleHandler.Target target) Set the target for this console handler.booleanwriteImagePng(InputStream imageData, int columns, int rows) Write a PNG image to the console log, if it is supported.Methods inherited from class org.jboss.logmanager.handlers.OutputStreamHandler
setCharsetPrivate, setWriterMethods inherited from class org.jboss.logmanager.handlers.WriterHandler
close, doPublish, flush, isCheckHeadEncoding, isCheckTailEncoding, preWrite, safeClose, setCheckHeadEncoding, setCheckTailEncodingMethods inherited from class org.jboss.logmanager.ExtHandler
addHandler, checkAccess, checkAccess, clearHandlers, getCharset, getEncoding, getErrorManager, getFilter, getFormatter, getHandlers, getLevel, isAutoFlush, isCallerCalculationRequired, isCloseChildren, isEnabled, publish, publish, publishToNestedHandlers, removeHandler, reportError, reportError, setAutoFlush, setCharset, setCloseChildren, setEnabled, setEncoding, setFilter, setFormatter, setHandlers, setLevelMethods inherited from class java.util.logging.Handler
isLoggable
-
Constructor Details
-
ConsoleHandler
public ConsoleHandler()Construct a new instance. -
ConsoleHandler
Construct a new instance.- Parameters:
formatter- the formatter to use
-
ConsoleHandler
Construct a new instance.- Parameters:
target- the target to write to, ornullto start with an uninitialized target
-
ConsoleHandler
Construct a new instance.- Parameters:
target- the target to write to, ornullto start with an uninitialized targetformatter- the formatter to use
-
-
Method Details
-
setTarget
Set the target for this console handler.- Parameters:
target- the target to write to, ornullto clear the target
-
setErrorManager
- Overrides:
setErrorManagerin classExtHandler
-
writeImagePng
Write a PNG image to the console log, if it is supported. The image data stream must be closed by the caller.- Parameters:
imageData- the PNG image data stream to write (must not benull)columns- the number of text columns to occupy (0 for automatic)rows- the number of text rows to occupy (0 for automatic)- Returns:
trueif the image was written, orfalseif image support isn't found- Throws:
IOException- if the stream failed while writing the image
-
getLocalErrorManager
Get the local error manager. This is an error manager that will publish errors to this console handler. The console handler itself should not use this error manager.- Returns:
- the local error manager
-
setOutputStream
Set the output stream to write to. The output stream will then belong to this handler; when the handler is closed or a new writer or output stream is set, this output stream will be closed.- Overrides:
setOutputStreamin classOutputStreamHandler- Parameters:
outputStream- the new output stream ornullfor none
-
hasConsole
public static boolean hasConsole()Determine whether the console exists. If the console does not exist, then the standard output stream will be used whenConsoleHandler.Target.CONSOLEis selected as the output target.- Returns:
trueif there is a console,falseotherwise
-
isTrueColor
public static boolean isTrueColor()Determine whether the console supports truecolor output. This call may be expensive, so the result should be captured for the lifetime of any formatter making use of this information.- Returns:
trueif the console exists and supports truecolor output;falseotherwise
-
isGraphicsSupportPassivelyDetected
public static boolean isGraphicsSupportPassivelyDetected()Determine whether the console can be passively detected to support graphical output. This call may be expensive, so the result should be captured for the lifetime of any formatter making use of this information.- Returns:
trueif the console exists and supports graphical output;falseotherwise or if graphical support cannot be passively detected
-