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

public Class WriterHandler

extends ExtHandler
Class Inheritance
Known Direct Subclasses
org.jboss.logmanager.handlers.OutputStreamHandler
Imports
java.io.BufferedWriter, .Closeable, .Flushable, .Writer, java.nio.charset.Charset, .StandardCharsets, java.util.logging.ErrorManager, .Formatter, org.jboss.logmanager.ExtHandler, .ExtLogRecord

A handler which writes to any Writer.

Field Summary

Modifier and TypeField and Description
private volatile boolean
private volatile boolean
private Writer
Inherited from org.jboss.logmanager.ExtHandler:
handlershandlersUpdaterlock

Constructor Summary

AccessConstructor and Description
public
WriterHandler()

Construct a new instance.

Method Summary

Modifier and TypeMethod and Description
public void
protected void
doPublish(final ExtLogRecord
the log record to publish
record
)

Overrides org.jboss.logmanager.ExtHandler.doPublish.

Do the actual work of publication; the record will have been filtered already.

public void
flush()

Overrides org.jboss.logmanager.ExtHandler.flush.

Implements java.io.Flushable.flush.

Flush this logger.

pack-priv Writer
public boolean

Returns:

true to check and report head encoding problems, or false to ignore them
isCheckHeadEncoding
()

Determine whether head encoding checking is turned on.

public boolean

Returns:

true to check and report tail encoding problems, or false to ignore them
isCheckTailEncoding
()

Determine whether tail encoding checking is turned on.

protected void
preWrite(final ExtLogRecord
the record about to be logged
record
)

Execute any pre-write policy, such as file rotation.

protected void
safeClose(Closeable
the resource
c
)

Safely close the resource, reporting an error if the close fails.

pack-priv void
public WriterHandler

Returns:

this handler
setCheckHeadEncoding
(boolean
true to check and report head encoding problems, or false to ignore them
checkHeadEncoding
)

Establish whether head encoding checking is turned on.

public WriterHandler

Returns:

this handler
setCheckTailEncoding
(boolean
true to check and report tail encoding problems, or false to ignore them
checkTailEncoding
)

Establish whether tail encoding checking is turned on.

public void
setWriter(final Writer
the new writer, or null to disable logging
writer
)

Set the writer.

private void
writeHead(final Writer writer)

private void
writeTail(final Writer writer)

Inherited from org.jboss.logmanager.ExtHandler:
addHandlercheckAccesscheckAccessclearHandlersgetCharsetgetEncodinggetErrorManagergetFiltergetFormattergetHandlersgetLevelisAutoFlushisCallerCalculationRequiredisCloseChildrenisEnabledpublishpublishpublishToNestedHandlersremoveHandlerreportErrorreportErrorsetAutoFlushsetCharsetsetCharsetPrivatesetCloseChildrensetEnabledsetEncodingsetErrorManagersetFiltersetFormattersetHandlerssetLevel

Field Detail

checkHeadEncodingback to summary
private volatile boolean checkHeadEncoding
checkTailEncodingback to summary
private volatile boolean checkTailEncoding
writerback to summary
private Writer writer

Constructor Detail

WriterHandlerback to summary
public WriterHandler()

Construct a new instance.

Method Detail

closeback to summary
public void close() throws SecurityException

Overrides org.jboss.logmanager.ExtHandler.close.

Implements java.lang.AutoCloseable.close.

Close this logger.

Exceptions
SecurityException:
if the caller does not have sufficient permission
doPublishback to summary
protected void doPublish(final ExtLogRecord record)

Overrides org.jboss.logmanager.ExtHandler.doPublish.

Doc from org.jboss.logmanager.ExtHandler.doPublish.

Do the actual work of publication; the record will have been filtered already. The default implementation does nothing except to flush if the autoFlush property is set to true; if this behavior is to be preserved in a subclass then this method should be called after the record is physically written.

Parameters
record:ExtLogRecord

the log record to publish

flushback to summary
public void flush()

Overrides org.jboss.logmanager.ExtHandler.flush.

Implements java.io.Flushable.flush.

Flush this logger.

getWriterback to summary
pack-priv Writer getWriter()
isCheckHeadEncodingback to summary
public boolean isCheckHeadEncoding()

Determine whether head encoding checking is turned on.

Returns:boolean

true to check and report head encoding problems, or false to ignore them

isCheckTailEncodingback to summary
public boolean isCheckTailEncoding()

Determine whether tail encoding checking is turned on.

Returns:boolean

true to check and report tail encoding problems, or false to ignore them

preWriteback to summary
protected void preWrite(final ExtLogRecord record)

Execute any pre-write policy, such as file rotation. The write lock is held during this method, so make it quick. The default implementation does nothing.

Parameters
record:ExtLogRecord

the record about to be logged

safeCloseback to summary
protected void safeClose(Closeable c)

Safely close the resource, reporting an error if the close fails.

Parameters
c:Closeable

the resource

safeFlushback to summary
pack-priv void safeFlush(Flushable f)
setCheckHeadEncodingback to summary
public WriterHandler setCheckHeadEncoding(boolean checkHeadEncoding)

Establish whether head encoding checking is turned on.

Parameters
checkHeadEncoding:boolean

true to check and report head encoding problems, or false to ignore them

Returns:WriterHandler

this handler

setCheckTailEncodingback to summary
public WriterHandler setCheckTailEncoding(boolean checkTailEncoding)

Establish whether tail encoding checking is turned on.

Parameters
checkTailEncoding:boolean

true to check and report tail encoding problems, or false to ignore them

Returns:WriterHandler

this handler

setWriterback to summary
public void setWriter(final Writer writer)

Set the writer. The writer will then belong to this handler; when the handler is closed or a new writer is set, this writer will be closed.

Parameters
writer:Writer

the new writer, or null to disable logging

writeHeadback to summary
private void writeHead(final Writer writer)
writeTailback to summary
private void writeTail(final Writer writer)