Package com.helger.commons.log
Class InMemoryLogger
java.lang.Object
com.helger.commons.log.InMemoryLogger
- All Implemented Interfaces:
ICommonsIterable<LogMessage>,IHasErrorLevels<LogMessage>,IHasSize,IClearable,Iterable<LogMessage>
@NotThreadSafe
public class InMemoryLogger
extends Object
implements IHasErrorLevels<LogMessage>, IHasSize, IClearable
Keeps a set of
LogMessage objects in memory, offering an API similar
to SLF4J.- Author:
- Philip Helger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected LogMessagecreateLogMessage(IErrorLevel eErrorLevel, Serializable aMsg, Throwable t) Override this method to create a different LogMessage object or to filter certain log messages.voiderror(Serializable aMsg) voiderror(Serializable aMsg, Throwable t) voidinfo(Serializable aMsg) voidinfo(Serializable aMsg, Throwable t) booleanisEmpty()iterator()voidlog(IErrorLevel eErrorLevel, Serializable aMsg) voidlog(IErrorLevel eErrorLevel, Serializable aMsg, Throwable t) protected voidonAddLogMessage(LogMessage aLogMessage) Callback method that is invoked after a message was added.Reset the contents of the element to the after-construction state.intsize()voidsuccess(Serializable aMsg) voidsuccess(Serializable aMsg, Throwable t) toString()voidwarn(Serializable aMsg) voidwarn(Serializable aMsg, Throwable t) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.commons.collection.impl.ICommonsIterable
containsAny, containsNone, containsOnly, findAll, findAllInstanceOf, findAllMapped, findAllMapped, findAllMapped, findFirst, findFirst, findFirstIndex, findFirstMapped, findFirstMapped, findLastIndex, forEachBreakable, forEachByIndex, forEachThrowing, getCount, getCountMethods inherited from interface com.helger.commons.error.level.IHasErrorLevels
containsAtLeastOneError, containsAtLeastOneFailure, containsAtLeastOneSuccess, containsAtLeastOneWarningOrError, containsNoError, containsNoFailure, containsNoSuccess, containsOnlyError, containsOnlyFailure, containsOnlySuccess, getErrorCount, getFailureCount, getMostSevereErrorLevel, getSuccessCountMethods inherited from interface com.helger.commons.lang.IHasSize
isNotEmptyMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
InMemoryLogger
public InMemoryLogger()
-
-
Method Details
-
createLogMessage
@Nullable @OverrideOnDemand protected LogMessage createLogMessage(@Nonnull IErrorLevel eErrorLevel, @Nonnull Serializable aMsg, @Nullable Throwable t) Override this method to create a different LogMessage object or to filter certain log messages.- Parameters:
eErrorLevel- Error level. Nevernull.aMsg- The message object. Nevernull.t- An optional exception. May benull.- Returns:
- The returned value. May be
nullin which case the message will not be logged.
-
onAddLogMessage
Callback method that is invoked after a message was added.- Parameters:
aLogMessage- The added log message. Nevernull.
-
log
-
log
public void log(@Nonnull IErrorLevel eErrorLevel, @Nonnull Serializable aMsg, @Nullable Throwable t) -
error
-
error
-
warn
-
warn
-
info
-
info
-
success
-
success
-
getAllMessages
-
iterator
- Specified by:
iteratorin interfaceIterable<LogMessage>
-
size
-
isEmpty
public boolean isEmpty() -
removeAll
Description copied from interface:IClearableReset the contents of the element to the after-construction state.- Specified by:
removeAllin interfaceIClearable- Returns:
EChange.CHANGEDif at least one element was cleared,EChange.UNCHANGEDotherwise.
-
toString
-