Package org.jboss.logmanager.handlers
Class ConsoleHandler
- 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
public class ConsoleHandler extends OutputStreamHandler
A console handler which writes toSystem.out
by default.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ConsoleHandler.Target
The target stream type.
-
Field Summary
-
Fields inherited from class org.jboss.logmanager.ExtHandler
handlers, handlersUpdater, lock
-
-
Constructor Summary
Constructors Constructor Description ConsoleHandler()
Construct 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ErrorManager
getLocalErrorManager()
Get the local error manager.static boolean
hasConsole()
Determine whether the console exists.static boolean
isGraphicsSupportPassivelyDetected()
Determine whether the console can be passively detected to support graphical output.static boolean
isTrueColor()
Determine whether the console supports truecolor output.void
setErrorManager(ErrorManager em)
void
setOutputStream(OutputStream outputStream)
Set the output stream to write to.void
setTarget(ConsoleHandler.Target target)
Set the target for this console handler.boolean
writeImagePng(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
getCharset, setCharsetPrivate, setWriter
-
Methods inherited from class org.jboss.logmanager.handlers.WriterHandler
close, doPublish, flush, isCheckHeadEncoding, isCheckTailEncoding, preWrite, safeClose, setCheckHeadEncoding, setCheckTailEncoding
-
Methods inherited from class org.jboss.logmanager.ExtHandler
addHandler, checkAccess, checkAccess, clearHandlers, getEncoding, getErrorManager, getFilter, getFormatter, getHandlers, getLevel, isAutoFlush, isCallerCalculationRequired, isCloseChildren, isEnabled, publish, publish, publishToNestedHandlers, removeHandler, reportError, reportError, setAutoFlush, setCharset, setCloseChildren, setEnabled, setEncoding, setFilter, setFormatter, setHandlers, setLevel
-
Methods inherited from class java.util.logging.Handler
isLoggable
-
-
-
-
Constructor Detail
-
ConsoleHandler
public ConsoleHandler()
Construct a new instance.
-
ConsoleHandler
public ConsoleHandler(Formatter formatter)
Construct a new instance.- Parameters:
formatter
- the formatter to use
-
ConsoleHandler
public ConsoleHandler(ConsoleHandler.Target target)
Construct a new instance.- Parameters:
target
- the target to write to, ornull
to start with an uninitialized target
-
ConsoleHandler
public ConsoleHandler(ConsoleHandler.Target target, Formatter formatter)
Construct a new instance.- Parameters:
target
- the target to write to, ornull
to start with an uninitialized targetformatter
- the formatter to use
-
-
Method Detail
-
setTarget
public void setTarget(ConsoleHandler.Target target)
Set the target for this console handler.- Parameters:
target
- the target to write to, ornull
to clear the target
-
setErrorManager
public void setErrorManager(ErrorManager em)
- Overrides:
setErrorManager
in classExtHandler
-
writeImagePng
public boolean writeImagePng(InputStream imageData, int columns, int rows) throws IOException
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:
true
if the image was written, orfalse
if image support isn't found- Throws:
IOException
- if the stream failed while writing the image
-
getLocalErrorManager
public ErrorManager 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
public void setOutputStream(OutputStream outputStream)
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:
setOutputStream
in classOutputStreamHandler
- Parameters:
outputStream
- the new output stream ornull
for 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.CONSOLE
is selected as the output target.- Returns:
true
if there is a console,false
otherwise
-
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:
true
if the console exists and supports truecolor output;false
otherwise
-
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:
true
if the console exists and supports graphical output;false
otherwise or if graphical support cannot be passively detected
-
-