Package org.jboss.logmanager.handlers
Class QueueHandler
java.lang.Object
java.util.logging.Handler
org.jboss.logmanager.ExtHandler
org.jboss.logmanager.handlers.QueueHandler
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
,FlushableCloseable
,Protectable
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.
-
Field Summary
FieldsFields inherited from class org.jboss.logmanager.ExtHandler
handlers, handlersUpdater
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new instance with a default queue length.QueueHandler
(int limit) Construct a new instance. -
Method Summary
Modifier and TypeMethodDescriptionprivate static IllegalArgumentException
protected void
doPublish
(ExtLogRecord record) Do the actual work of publication; the record will have been filtered already.int
getLimit()
Get the queue length limit.getQueue()
Get a copy of the queue as it is at an exact moment in time.String[]
Get a copy of the queue, rendering each record as a string.void
void
publish
(ExtLogRecord record) Publish anExtLogRecord
.void
replay()
Replay the stored queue to the nested handlers.void
setLimit
(int limit) Set the queue length limit.Methods inherited from class org.jboss.logmanager.ExtHandler
addHandler, checkAccess, checkAccess, clearHandlers, close, disableAccess, enableAccess, flush, getHandlers, isAutoFlush, isEnabled, protect, removeHandler, setAutoFlush, setEnabled, setEncoding, setErrorManager, setFilter, setFormatter, setHandlers, setLevel, unprotect
Methods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError
-
Field Details
-
buffer
-
limit
private int limit
-
-
Constructor Details
-
QueueHandler
public QueueHandler()Construct a new instance with a default queue length. -
QueueHandler
public QueueHandler(int limit) Construct a new instance.- Parameters:
limit
- the queue length to use
-
-
Method Details
-
publish
Description copied from class:ExtHandler
Publish anExtLogRecord
. The logging request was made initially to a Logger object, which initialized the LogRecord and forwarded it here. TheExtHandler
is responsible for formatting the message, when and if necessary. The formatting should include localization.- Overrides:
publish
in classExtHandler
- Parameters:
record
- the log record to publish
-
publish
Description copied from class:ExtHandler
- Overrides:
publish
in classExtHandler
-
doPublish
Description copied from class:ExtHandler
Do the actual work of publication; the record will have been filtered already. The default implementation does nothing except to flush if theautoFlush
property is set totrue
; if this behavior is to be preserved in a subclass then this method should be called after the record is physically written.- Overrides:
doPublish
in classExtHandler
- Parameters:
record
- the log record to publish
-
getLimit
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:
- the queue length limit
-
setLimit
public void setLimit(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
- the queue length limit
-
getQueue
Get a copy of the queue as it is at an exact moment in time.- Returns:
- the copy of the queue
-
getQueueAsStrings
Get a copy of the queue, rendering each record as a string.- Returns:
- the copy of the queue rendered as strings
-
replay
public void replay()Replay the stored queue to the nested handlers. -
badQueueLength
-