|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.logging.Handler
com.neeve.trace.TraceHistoryHandler
public final class TraceHistoryHandler
Implements a 'history' handler.
A history handler is as an intermediary trace handler that forwards trace to downstream handlers while also maintaining a history of the trace. Trace log records are only forwarded to downstream handlers if they pass any installed filters and level checks.
Method Summary | |
---|---|
void |
close()
Implementation of Handler.close()
This method closes the downstream handler. |
static TraceHistoryHandler |
create(Handler handler,
int maxRecords)
Create a new trace history handler |
void |
flush()
Implementation of Handler.flush()
This method flushes the downstream handler. |
Object |
getHistoryLock()
Get the history lock object. |
Iterator<LogRecord> |
iterator()
Create an iterator to traverse the history records |
void |
publish(LogRecord record)
Implementation of Handler.publish(java.util.logging.LogRecord)
This method stores the supplied log record into the history buffer
and then publishes the record to the downstream handler. |
Methods inherited from class java.util.logging.Handler |
---|
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, setEncoding, setErrorManager, setFilter, setFormatter, setLevel |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static TraceHistoryHandler create(Handler handler, int maxRecords)
handler
- The downstream handler to forward log records to. This
parameter can be null in which case published records are not forwarded
downstream.maxRecords
- The maximum size, in trace records, of the history
buffer.public final void publish(LogRecord record)
Handler.publish(java.util.logging.LogRecord)
This method stores the supplied log record into the history buffer and then publishes the record to the downstream handler. Log records are only recorded in the history buffer if it passes any installed filters and level checks.
publish
in class Handler
public final void flush()
Handler.flush()
This method flushes the downstream handler.
flush
in class Handler
public final void close()
Handler.close()
This method closes the downstream handler.
close
in class Handler
public final Object getHistoryLock()
This method returns the object used to protect against concurrent modification of the history buffer by multiple threads. The user should lock the object returned by this method while traversing the trace history.
public final Iterator<LogRecord> iterator()
getHistoryLock()
while traversing the list to prevent
concurrent modification by other threads during the traversal
All trace generated while the user is traversing the history buffer is ignored. To detect this, the handler invoked hasNext() on the iterator returned to the caller. If it returns true, the published trace is not recorded. Therefore, it is mandatory that the caller walk through the entire history buffer using an iterator returned from this method
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |