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
Constructors -
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
- Parameters:
loggerToFollow- this handler will be added to this logger.
-
-
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.
-