Top Description Inners Fields Constructors Methods
org.jboss.logmanager.handlers

public Class ConsoleHandler

extends OutputStreamHandler
Class Inheritance
Imports
java.io.Console, .IOException, .InputStream, .OutputStream, .PrintWriter, .Writer, java.nio.charset.StandardCharsets, java.security.AccessController, .PrivilegedAction, java.util.Base64, .Objects, java.util.logging.ErrorManager, .Formatter, org.jboss.logmanager.errormanager.HandlerErrorManager, org.jboss.logmanager.formatters.Formatters

A console handler which writes to System.out by default.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
public static enum
ConsoleHandler.Target

The target stream type.

Field Summary

Modifier and TypeField and Description
private static final OutputStream
private static final String
private final ErrorManager
private static final OutputStream

Constructor Summary

AccessConstructor and Description
public
ConsoleHandler()

Construct a new instance.

public
ConsoleHandler(final Formatter
the formatter to use
formatter
)

Construct a new instance.

public
ConsoleHandler(final ConsoleHandler.Target
the target to write to, or null to start with an uninitialized target
target
)

Construct a new instance.

public
ConsoleHandler(final ConsoleHandler.Target
the target to write to, or null to start with an uninitialized target
target
,
final Formatter
the formatter to use
formatter
)

Construct a new instance.

Method Summary

Modifier and TypeMethod and Description
private static ConsoleHandler.Target
public ErrorManager

Returns:

the local error manager
getLocalErrorManager
()

Get the local error manager.

public static boolean

Returns:

true if there is a console, false otherwise
hasConsole
()

Determine whether the console exists.

public static boolean

Returns:

true if the console exists and supports graphical output; false otherwise or if graphical support cannot be passively detected
isGraphicsSupportPassivelyDetected
()

Determine whether the console can be passively detected to support graphical output.

public static boolean

Returns:

true if the console exists and supports truecolor output; false otherwise
isTrueColor
()

Determine whether the console supports truecolor output.

public void
setErrorManager(final ErrorManager
the new ErrorManager
em
)

Overrides org.jboss.logmanager.ExtHandler.setErrorManager.

Define an ErrorManager for this Handler.

public void
setOutputStream(final OutputStream
the new output stream or null for none
outputStream
)

Overrides org.jboss.logmanager.handlers.OutputStreamHandler.setOutputStream.

Set the output stream to write to.

public void
setTarget(ConsoleHandler.Target
the target to write to, or null to clear the target
target
)

Set the target for this console handler.

private static OutputStream
wrap(final OutputStream outputStream)

private static Writer
wrap(final Writer writer)

public boolean

Returns:

true if the image was written, or false if image support isn't found
writeImagePng
(InputStream
the PNG image data stream to write (must not be null)
imageData
,
int
the number of text columns to occupy (0 for automatic)
columns
,
int
the number of text rows to occupy (0 for automatic)
rows
)

Write a PNG image to the console log, if it is supported.

Inherited from org.jboss.logmanager.handlers.OutputStreamHandler:
getOutputStreamsetCharsetPrivatesetWriter

Field Detail

errback to summary
private static final OutputStream err
ESCback to summary
private static final String ESC
localErrorManagerback to summary
private final ErrorManager localErrorManager
outback to summary
private static final OutputStream out

Constructor Detail

ConsoleHandlerback to summary
public ConsoleHandler()

Construct a new instance.

ConsoleHandlerback to summary
public ConsoleHandler(final Formatter formatter)

Construct a new instance.

Parameters
formatter:Formatter

the formatter to use

ConsoleHandlerback to summary
public ConsoleHandler(final ConsoleHandler.Target target)

Construct a new instance.

Parameters
target:ConsoleHandler.Target

the target to write to, or null to start with an uninitialized target

ConsoleHandlerback to summary
public ConsoleHandler(final ConsoleHandler.Target target, final Formatter formatter)

Construct a new instance.

Parameters
target:ConsoleHandler.Target

the target to write to, or null to start with an uninitialized target

formatter:Formatter

the formatter to use

Method Detail

defaultTargetback to summary
private static ConsoleHandler.Target defaultTarget()
getLocalErrorManagerback to summary
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:ErrorManager

the local error manager

hasConsoleback to summary
public static boolean hasConsole()

Determine whether the console exists. If the console does not exist, then the standard output stream will be used when Target#CONSOLE is selected as the output target.

Returns:boolean

true if there is a console, false otherwise

isGraphicsSupportPassivelyDetectedback to summary
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:boolean

true if the console exists and supports graphical output; false otherwise or if graphical support cannot be passively detected

isTrueColorback to summary
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:boolean

true if the console exists and supports truecolor output; false otherwise

setErrorManagerback to summary
public void setErrorManager(final ErrorManager em)

Overrides org.jboss.logmanager.ExtHandler.setErrorManager.

Doc from java.util.logging.Handler.setErrorManager.

Define an ErrorManager for this Handler.

The ErrorManager's "error" method will be invoked if any errors occur while using this Handler.

Parameters
em:ErrorManager

the new ErrorManager

setOutputStreamback to summary
public void setOutputStream(final OutputStream outputStream)

Overrides org.jboss.logmanager.handlers.OutputStreamHandler.setOutputStream.

Doc from org.jboss.logmanager.handlers.OutputStreamHandler.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.

Parameters
outputStream:OutputStream

the new output stream or null for none

setTargetback to summary
public void setTarget(ConsoleHandler.Target target)

Set the target for this console handler.

Parameters
target:ConsoleHandler.Target

the target to write to, or null to clear the target

wrapback to summary
private static OutputStream wrap(final OutputStream outputStream)
wrapback to summary
private static Writer wrap(final Writer writer)
writeImagePngback to summary
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:InputStream

the PNG image data stream to write (must not be null)

columns:int

the number of text columns to occupy (0 for automatic)

rows:int

the number of text rows to occupy (0 for automatic)

Returns:boolean

true if the image was written, or false if image support isn't found

Exceptions
IOException:
if the stream failed while writing the image
org.jboss.logmanager.handlers back to summary

private final Class ConsoleHandler.ConsoleHolder

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final PrintWriter

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

consoleback to summary
private static final PrintWriter console

Constructor Detail

ConsoleHolderback to summary
private ConsoleHolder()
org.jboss.logmanager.handlers back to summary

public final Enum ConsoleHandler.Target

extends Enum<ConsoleHandler.Target>
Class Inheritance

The target stream type.

Field Summary

Modifier and TypeField and Description
public static final ConsoleHandler.Target
CONSOLE

The target for System#console().

public static final ConsoleHandler.Target
SYSTEM_ERR

The target for System#err.

public static final ConsoleHandler.Target
SYSTEM_OUT

The target for System#out.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ConsoleHandler.Target
public static ConsoleHandler.Target[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CONSOLEback to summary
public static final ConsoleHandler.Target CONSOLE

The target for System#console().

SYSTEM_ERRback to summary
public static final ConsoleHandler.Target SYSTEM_ERR

The target for System#err.

SYSTEM_OUTback to summary
public static final ConsoleHandler.Target SYSTEM_OUT

The target for System#out.

Constructor Detail

Targetback to summary
private Target()

Method Detail

valueOfback to summary
public static ConsoleHandler.Target valueOf(String name)
valuesback to summary
public static ConsoleHandler.Target[] values()