java.lang.Object
java.util.logging.Handler
org.glassfish.main.jul.handler.LogCollectorHandler
This special
Handler can be used for testing purposes.
It collects log records passing through the given Logger instance.- Author:
- David Matejcek
-
Constructor Summary
ConstructorsConstructorDescriptionLogCollectorHandler(Logger loggerToFollow) Creates aLogRecordcollector handler with the capacity of 100 records and maximal wait time 5 seconds.LogCollectorHandler(Logger loggerToFollow, int capacity, int maxWait) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Unattaches the handler from the logger and drops all collected log records.voidflush()getAll()Creates a list of all records and resets the buffer.<R> List<R> Creates a list of all records and resets the buffer.pop()Removes the first record in the buffer and returns it.voidvoidreset()Drops all collected records.Methods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
-
Constructor Details
-
LogCollectorHandler
Creates aLogRecordcollector handler with the capacity of 100 records and maximal wait time 5 seconds.- Parameters:
loggerToFollow- this handler will be added to this logger.- See Also:
-
LogCollectorHandler
- Parameters:
loggerToFollow- this handler will be added to this logger.capacity- capacity of the buffer.maxWait- maximal time in seconds to wait for the free capacity. If < 1, can wait forever.- See Also:
-
-
Method Details
-
publish
-
flush
public void flush() -
close
Unattaches the handler from the logger and drops all collected log records.- Specified by:
closein classHandler- Throws:
SecurityException
-
pop
Removes the first record in the buffer and returns it.- Returns:
- the first
GlassFishLogRecordin the buffer or null if the buffer is empty.
-
getAll
Creates a list of all records and resets the buffer.- Returns:
- all collected records
-
getAll
Creates a list of all records and resets the buffer.- Type Parameters:
R- expected item type- Parameters:
mappingFunction-- Returns:
- all collected records
-
reset
public void reset()Drops all collected records.
-