@NotThreadSafe public class InMemoryLogger extends Object implements IHasErrorLevels<LogMessage>, IHasSize, IClearable
LogMessage objects in memory, offering an API similar
to SLF4J.| Constructor and Description |
|---|
InMemoryLogger() |
| Modifier and Type | Method and Description |
|---|---|
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) |
ICommonsList<LogMessage> |
getAllMessages() |
void |
info(Serializable aMsg) |
void |
info(Serializable aMsg,
Throwable t) |
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.
|
EChange |
removeAll()
Reset the contents of the element to the after-construction state.
|
int |
size() |
void |
success(Serializable aMsg) |
void |
success(Serializable aMsg,
Throwable t) |
String |
toString() |
void |
warn(Serializable aMsg) |
void |
warn(Serializable aMsg,
Throwable t) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcontainsAtLeastOneError, containsAtLeastOneFailure, containsAtLeastOneSuccess, containsAtLeastOneWarningOrError, containsNoError, containsNoFailure, containsNoSuccess, containsOnlyError, containsOnlyFailure, containsOnlySuccess, getErrorCount, getFailureCount, getMostSevereErrorLevel, getSuccessCountcontainsAny, containsNone, containsOnly, findAll, findAllInstanceOf, findAllMapped, findAllMapped, findAllMapped, findFirst, findFirst, findFirstMapped, findFirstMapped, forEach, forEachBreakable, forEachByIndex, getCount, getCountforEach, spliteratorisNotEmpty@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)
public void info(@Nonnull Serializable aMsg, @Nullable Throwable t)
public void success(@Nonnull Serializable aMsg)
public void success(@Nonnull Serializable aMsg, @Nullable Throwable t)
@Nonnull @ReturnsMutableCopy public ICommonsList<LogMessage> getAllMessages()
@Nonnull public Iterator<LogMessage> iterator()
iterator in interface Iterable<LogMessage>@Nonnegative public int size()
public boolean isEmpty()
isEmpty in interface IHasSizetrue if no items are present, false if at
least a single item is present.IHasSize.size(),
IHasSize.isNotEmpty()@Nonnull public EChange removeAll()
IClearableremoveAll in interface IClearableEChange.CHANGED if at least one element was cleared,
EChange.UNCHANGED otherwise.Copyright © 2014–2017 Philip Helger. All rights reserved.