public class InMemoryLogger extends AbstractLogger
This of course is not reasonable for a production system, but could be helpful for unit testing.
ANONYMOUS_LOGGER_NAME, LL_DEBUG, LL_ERROR, LL_INFO, LL_NONE, LL_WARNING| Constructor and Description |
|---|
InMemoryLogger(java.lang.String loggerName) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
add(LogLevel level,
java.lang.String message,
java.lang.Object... params) |
protected void |
add(LogLevel level,
java.lang.Throwable exception,
java.lang.String message,
java.lang.Object... params) |
void |
clear() |
java.util.List<LogRecord> |
findEntriesContaining(java.lang.String text)
Returns a list of all log records with a message that contains
the given text.
|
java.util.List<LogRecord> |
getLogEntries() |
protected LogLevel |
getLogLevel() |
void |
initialize(java.util.Properties properties)
Initialize the logger from the given properties settings.
|
boolean |
isEmpty() |
boolean |
isLoggingDebugs()
Returns true, if debug messages will be written to the output device(s).
|
boolean |
isLoggingErrors()
Returns true, if errors will be written to the output device(s).
|
boolean |
isLoggingInfos()
Returns true, if info messages will be written to the output device(s).
|
boolean |
isLoggingWarnings()
Returns true, if warnings will be written to the output device(s).
|
void |
logDebug(java.lang.String message,
java.lang.Object... params)
If the logging level is DEBUG the given message will be written to
the log output device(s).
|
void |
logError(java.lang.String message,
java.lang.Object... params)
If the logging level is DEBUG, INFO, WARNING or ERROR the given message
will be written to the log output device(s).
|
void |
logError(java.lang.String message,
java.lang.Throwable exception)
If the logging level is DEBUG, INFO, WARNING or ERROR the given message
and the exception will be written to the log output device(s).
|
void |
logException(java.lang.Throwable exception)
Writes the given exception to the log output device(s).
|
void |
logInfo(java.lang.String message,
java.lang.Object... params)
If the logging level is INFO or DEBUG the given message will be
written to the log output device(s).
|
void |
logWarning(java.lang.String message,
java.lang.Object... params)
If the logging level is DEBUG, INFO or WARNING the given message will
be written to the log output device(s).
|
void |
logWarning(java.lang.String message,
java.lang.Throwable exception)
If the logging level is DEBUG, INFO or WARNING the given message
and the exception will be written to the log output device(s).
|
protected void |
setLogLevel(LogLevel logLevel) |
boolean |
setLogLevel(java.lang.String level)
Changes the log level to the specified level.
|
int |
size() |
getLoggerName, getName, isNullOrBlank, isNullOrEmpty, replacePlaceholders, setLoggerNamepublic void initialize(java.util.Properties properties)
Loggerpublic boolean isLoggingDebugs()
Loggerpublic boolean isLoggingInfos()
Loggerpublic boolean isLoggingWarnings()
Loggerpublic boolean isLoggingErrors()
Loggerpublic void logDebug(java.lang.String message,
java.lang.Object... params)
Loggermessage - The message to log. It may contain placeholders like {0}, {1} etc.params - Optional parameters to be used for replacing placeholders in the message text.public void logInfo(java.lang.String message,
java.lang.Object... params)
Loggermessage - The message to log. It may contain placeholders like {0}, {1} etc.params - Optional parameters to be used for replacing placeholders in the message text.public void logWarning(java.lang.String message,
java.lang.Object... params)
Loggermessage - The message to log. It may contain placeholders like {0}, {1} etc.params - Optional parameters to be used for replacing placeholders in the message text.public void logWarning(java.lang.String message,
java.lang.Throwable exception)
Loggerpublic void logError(java.lang.String message,
java.lang.Object... params)
Loggermessage - The message to log. It may contain placeholders like {0}, {1} etc.params - Optional parameters to be used for replacing placeholders in the message text.public void logError(java.lang.String message,
java.lang.Throwable exception)
Loggerpublic void logException(java.lang.Throwable exception)
Loggerpublic boolean setLogLevel(java.lang.String level)
Loggerlevel - One of the LL_ constants defined in this interface (e.g. Logger.LL_ERROR).public int size()
public boolean isEmpty()
public void clear()
public java.util.List<LogRecord> findEntriesContaining(java.lang.String text)
text - The text to search for (must not be null).public java.util.List<LogRecord> getLogEntries()
protected void add(LogLevel level, java.lang.String message, java.lang.Object... params)
protected void add(LogLevel level, java.lang.Throwable exception, java.lang.String message, java.lang.Object... params)
protected LogLevel getLogLevel()
protected void setLogLevel(LogLevel logLevel)