@NotThreadSafe public class InMemoryLogger extends Object implements Iterable<LogMessage>, IHasSize, IClearable, IHasErrorLevels, Serializable
LogMessage objects in memory, offering an API similar
to SLF4J.| Constructor and Description |
|---|
InMemoryLogger() |
| Modifier and Type | Method and Description |
|---|---|
EChange |
clear()
Reset the contents of the element to the after-construction state.
|
boolean |
containsAtLeastOneError()
Check if this group contains at least one error or fatal error message.
|
boolean |
containsAtLeastOneFailure()
Check if this group contains at least one failure message.
|
boolean |
containsAtLeastOneSuccess()
Check if this group contains at least one success message.
|
boolean |
containsNoError()
Check if this group contains no error or fatal error message.
|
boolean |
containsNoFailure()
Check if this group contains no failure message.
|
boolean |
containsNoSuccess()
Check if this group contains no success message.
|
boolean |
containsOnlyError()
Check if this group contains only error or fatal error messages.
|
boolean |
containsOnlyFailure()
Check if this group contains only failure messages.
|
boolean |
containsOnlySuccess()
Check if this group contains only success messages.
|
protected LogMessage |
createLogMessage(IErrorLevel eErrorLevel,
Serializable aMsg,
Throwable t)
Override this method to create a different LogMessage object or to filter
certain log messages.
|
void |
error(Serializable aMsg) |
void |
error(Serializable aMsg,
Throwable t) |
List<LogMessage> |
getAllMessages() |
int |
getErrorCount() |
int |
getFailureCount() |
IErrorLevel |
getMostSevereErrorLevel()
Get the most severe error level within this object.
|
int |
getSize() |
int |
getSuccessCount() |
void |
info(Serializable aMsg) |
boolean |
isEmpty() |
Iterator<LogMessage> |
iterator() |
void |
log(IErrorLevel eErrorLevel,
Serializable aMsg) |
void |
log(IErrorLevel eErrorLevel,
Serializable aMsg,
Throwable t) |
protected void |
onAddLogMessage(LogMessage aLogMessage)
Callback method that is invoked after a message was added.
|
String |
toString() |
void |
warn(Serializable aMsg) |
void |
warn(Serializable aMsg,
Throwable t) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliterator@Nullable @OverrideOnDemand protected LogMessage createLogMessage(@Nonnull IErrorLevel eErrorLevel, @Nonnull Serializable aMsg, @Nullable Throwable t)
eErrorLevel - Error level. Never null.aMsg - The message object. Never null.t - An optional exception. May be null.null in which case the
message will not be logged.@OverrideOnDemand protected void onAddLogMessage(@Nonnull LogMessage aLogMessage)
aLogMessage - The added log message. Never null.public void log(@Nonnull IErrorLevel eErrorLevel, @Nonnull Serializable aMsg)
public void log(@Nonnull IErrorLevel eErrorLevel, @Nonnull Serializable aMsg, @Nullable Throwable t)
public void error(@Nonnull Serializable aMsg)
public void error(@Nonnull Serializable aMsg, @Nullable Throwable t)
public void warn(@Nonnull Serializable aMsg)
public void warn(@Nonnull Serializable aMsg, @Nullable Throwable t)
public void info(@Nonnull Serializable aMsg)
@Nonnull @ReturnsMutableCopy public List<LogMessage> getAllMessages()
@Nonnull public Iterator<LogMessage> iterator()
iterator in interface Iterable<LogMessage>@Nonnegative public int getSize()
public boolean isEmpty()
isEmpty in interface IHasSizetrue if no items are present, false if at
least a single item is present.IHasSize.getSize()public boolean containsOnlySuccess()
IHasErrorLevelsfalse is returned, since no success message is contained. If
you want to check, if the list is empty or contains only success messages,
use IHasErrorLevels.containsNoFailure() instead.containsOnlySuccess in interface IHasErrorLevelstrue if at least one item is present, and if all items
have the error level success, false otherwise.IHasErrorLevels.containsNoFailure()public boolean containsAtLeastOneSuccess()
IHasErrorLevelscontainsAtLeastOneSuccess in interface IHasErrorLevelstrue if at least one success item is present,
false otherwise.public boolean containsNoSuccess()
IHasErrorLevelscontainsNoSuccess in interface IHasErrorLevelstrue if no success item is present, false
otherwise.@Nonnegative public int getSuccessCount()
getSuccessCount in interface IHasErrorLevelspublic boolean containsOnlyFailure()
IHasErrorLevelsfalse is returned. All error levels except
EErrorLevel.SUCCESS are considered to be a failure!containsOnlyFailure in interface IHasErrorLevelstrue if at least one item is present, and if all items
have an error level indicating failure, false
otherwise.public boolean containsAtLeastOneFailure()
IHasErrorLevelsEErrorLevel.SUCCESS are considered to be a failure!containsAtLeastOneFailure in interface IHasErrorLevelstrue if at least one failure item is present,
false otherwise.public boolean containsNoFailure()
IHasErrorLevelsEErrorLevel.SUCCESS are considered to be a failure!containsNoFailure in interface IHasErrorLevelstrue if no failure item is present, false
otherwise.@Nonnegative public int getFailureCount()
getFailureCount in interface IHasErrorLevelspublic boolean containsOnlyError()
IHasErrorLevelsfalse is returned. All error levels ≥
EErrorLevel.ERROR are considered to be an error!containsOnlyError in interface IHasErrorLevelstrue if at least one item is present, and if all items
have an error level indicating error or fatal error,
false otherwise.public boolean containsAtLeastOneError()
IHasErrorLevelsEErrorLevel.ERROR are considered to be an error!containsAtLeastOneError in interface IHasErrorLevelstrue if at least one error or fatal error item is
present, false otherwise.public boolean containsNoError()
IHasErrorLevelsEErrorLevel.ERROR are considered to be an error!containsNoError in interface IHasErrorLevelstrue if no error or fatal error item is present,
false otherwise.@Nonnegative public int getErrorCount()
getErrorCount in interface IHasErrorLevelsEErrorLevel.ERROR are considered to be an
error!@Nonnull public IErrorLevel getMostSevereErrorLevel()
IHasErrorLevelsEErrorLevel's severity model.getMostSevereErrorLevel in interface IHasErrorLevelsEErrorLevel.SUCCESS if no resource error is contained, the
most severe contained error level otherwise.@Nonnull public EChange clear()
IClearableclear in interface IClearableEChange.CHANGED if at least one element was cleared,
EChange.UNCHANGED otherwise.Copyright © 2014–2016 Philip Helger. All rights reserved.