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

public Class QueueHandler

extends ExtHandler
Class Inheritance
Imports
java.util.ArrayDeque, .Deque, java.util.logging.ErrorManager, .Formatter, .Handler, .LogRecord, org.jboss.logmanager.ExtHandler, .ExtLogRecord, io.smallrye.common.constraint.Assert

A queue handler which retains the last few messages logged. The handler can be used as-is to remember recent messages, or one or more handlers may be nested, which allows this handler to "replay" messages to the child handler(s) upon request.
Author
David M. Lloyd

Field Summary

Modifier and TypeField and Description
private final Deque<ExtLogRecord>
private int
Inherited from org.jboss.logmanager.ExtHandler:
handlershandlersUpdaterlock

Constructor Summary

AccessConstructor and Description
public
QueueHandler()

Construct a new instance with a default queue length.

public
QueueHandler(final int
the queue length to use
limit
)

Construct a new instance.

Method Summary

Modifier and TypeMethod and Description
public void
addHandler(Handler
the handler to add
handler
)

Overrides org.jboss.logmanager.ExtHandler.addHandler.

Add a sub-handler to this handler.

public void
addHandler(Handler
the handler to add (must not be null)
handler
,
boolean
true to replay the prior messages, or false to add the handler without replaying
replay
)

Add the given handler, optionally atomically replaying the queue, allowing the delegate handler to receive all queued messages as well as all subsequent messages with no loss or reorder in between.

private static IllegalArgumentException
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 int

Returns:

the queue length limit
getLimit
()

Get the queue length limit.

public ExtLogRecord[]

Returns:

the copy of the queue
getQueue
()

Get a copy of the queue as it is at an exact moment in time.

public String[]

Returns:

the copy of the queue rendered as strings
getQueueAsStrings
()

Get a copy of the queue, rendering each record as a string.

public void
publish(final ExtLogRecord
the log record to publish
record
)

Overrides org.jboss.logmanager.ExtHandler.publish.

Publish an ExtLogRecord.

public void
publish(final LogRecord
description of the log event. A null record is silently ignored and is not published
record
)

Overrides org.jboss.logmanager.ExtHandler.publish.

Publish a LogRecord.

public void
replay()

Replay the stored queue to the nested handlers.

public void
setLimit(final int
the queue length limit
limit
)

Set the queue length limit.

Inherited from org.jboss.logmanager.ExtHandler:
checkAccesscheckAccessclearHandlerscloseflushgetCharsetgetEncodinggetErrorManagergetFiltergetFormattergetHandlersgetLevelisAutoFlushisCallerCalculationRequiredisCloseChildrenisEnabledpublishToNestedHandlersremoveHandlerreportErrorreportErrorsetAutoFlushsetCharsetsetCharsetPrivatesetCloseChildrensetEnabledsetEncodingsetErrorManagersetFiltersetFormattersetHandlerssetLevel

Field Detail

bufferback to summary
private final Deque<ExtLogRecord> buffer
limitback to summary
private int limit

Constructor Detail

QueueHandlerback to summary
public QueueHandler()

Construct a new instance with a default queue length.

QueueHandlerback to summary
public QueueHandler(final int limit)

Construct a new instance.

Parameters
limit:int

the queue length to use

Method Detail

addHandlerback to summary
public void addHandler(Handler handler) throws SecurityException

Overrides org.jboss.logmanager.ExtHandler.addHandler.

Doc from org.jboss.logmanager.ExtHandler.addHandler.

Add a sub-handler to this handler. Some handler types do not utilize sub-handlers.

Parameters
handler:Handler

the handler to add

Annotations
@Override
Exceptions
SecurityException:
if a security manager exists and if the caller does not have LoggingPermission(control)
addHandlerback to summary
public void addHandler(Handler handler, boolean replay) throws SecurityException

Add the given handler, optionally atomically replaying the queue, allowing the delegate handler to receive all queued messages as well as all subsequent messages with no loss or reorder in between.

Parameters
handler:Handler

the handler to add (must not be null)

replay:boolean

true to replay the prior messages, or false to add the handler without replaying

Exceptions
SecurityException:
if the handler was not allowed to be added
badQueueLengthback to summary
private static IllegalArgumentException badQueueLength()
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

getLimitback to summary
public int getLimit()

Get the queue length limit. This is the number of messages that will be saved before old messages roll off of the queue.

Returns:int

the queue length limit

getQueueback to summary
public ExtLogRecord[] getQueue()

Get a copy of the queue as it is at an exact moment in time.

Returns:ExtLogRecord[]

the copy of the queue

getQueueAsStringsback to summary
public String[] getQueueAsStrings()

Get a copy of the queue, rendering each record as a string.

Returns:String[]

the copy of the queue rendered as strings

publishback to summary
public void publish(final ExtLogRecord record)

Overrides org.jboss.logmanager.ExtHandler.publish.

Doc from org.jboss.logmanager.ExtHandler.publish.

Publish an ExtLogRecord.

The logging request was made initially to a Logger object, which initialized the LogRecord and forwarded it here.

The ExtHandler is responsible for formatting the message, when and if necessary. The formatting should include localization.

Parameters
record:ExtLogRecord

the log record to publish

publishback to summary
public void publish(final LogRecord record)

Overrides org.jboss.logmanager.ExtHandler.publish.

Doc from org.jboss.logmanager.ExtHandler.publish.

Publish a LogRecord.

The logging request was made initially to a Logger object, which initialized the LogRecord and forwarded it here.

The Handler is responsible for formatting the message, when and if necessary. The formatting should include localization.

Parameters
record:LogRecord

Doc from java.util.logging.Handler.publish.

description of the log event. A null record is silently ignored and is not published

replayback to summary
public void replay()

Replay the stored queue to the nested handlers.

setLimitback to summary
public void setLimit(final int limit)

Set the queue length limit. This is the number of messages that will be saved before old messages roll off of the queue.

Parameters
limit:int

the queue length limit