Class MockLogger
Example:
See Also:
-
Field Summary
Fields inherited from class java.util.logging.Logger
global, GLOBAL_LOGGER_NAME
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAllows you to perform fluent-style assertions on the contents of the log file.assertLastLevel
(Level level) Asserts that the last message was logged at the specified level.Asserts that the last message matched the specified message.Asserts that this logger was called.Asserts that the specified number of messages have been logged.static MockLogger
create()
Creator.Specifies the format for messages sent to the log file.Overrides the formatter to use for formatting messages.Sets the level for this logger.void
reset()
Resets this logger.toString()
Returns the contents of this log file as a string.Methods inherited from class java.util.logging.Logger
addHandler, config, config, entering, entering, entering, exiting, exiting, fine, fine, finer, finer, finest, finest, getAnonymousLogger, getAnonymousLogger, getFilter, getGlobal, getHandlers, getLevel, getLogger, getLogger, getName, getParent, getResourceBundle, getResourceBundleName, getUseParentHandlers, info, info, isLoggable, log, log, log, log, log, log, logp, logp, logp, logp, logp, logp, logrb, logrb, logrb, logrb, logrb, logrb, logrb, logrb, removeHandler, setFilter, setLevel, setParent, setResourceBundle, setUseParentHandlers, severe, severe, throwing, warning, warning
-
Constructor Details
-
MockLogger
public MockLogger()Constructor.
-
-
Method Details
-
create
Creator.- Returns:
- A new
MockLogger
object.
-
log
-
level
Sets the level for this logger.- Parameters:
level
- The new level for this logger.- Returns:
- This object.
-
format
Specifies the format for messages sent to the log file.See
SimpleFormatter.format(LogRecord)
for the syntax of this string.- Parameters:
format
- The format string.- Returns:
- This object.
-
formatter
Overrides the formatter to use for formatting messages.The default uses
SimpleFormatter
.- Parameters:
formatter
- The log record formatter.- Returns:
- This object.
-
reset
Resets this logger.- Returns:
- This object.
-
assertLogged
Asserts that this logger was called.- Returns:
- This object.
-
assertLastLevel
Asserts that the last message was logged at the specified level.- Parameters:
level
- The level to match against.- Returns:
- This object.
-
assertLastMessage
Asserts that the last message matched the specified message.- Returns:
- This object.
-
assertRecordCount
Asserts that the specified number of messages have been logged.- Returns:
- This object.
-
assertContents
Allows you to perform fluent-style assertions on the contents of the log file.- Returns:
- A new fluent-style assertion object.
-
toString
Returns the contents of this log file as a string.
-