Class InMemoryAppender
- java.lang.Object
-
- ch.qos.logback.core.spi.ContextAwareBase
-
- ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
-
- org.kiwiproject.beta.test.logback.InMemoryAppender
-
- All Implemented Interfaces:
ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent>,ch.qos.logback.core.spi.ContextAware,ch.qos.logback.core.spi.FilterAttachable<ch.qos.logback.classic.spi.ILoggingEvent>,ch.qos.logback.core.spi.LifeCycle
@Beta public class InMemoryAppender extends ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>A logback appender that stores logging events in an in-memory map.This is for testing purposes only, and is not at all intended for production use!
-
-
Constructor Summary
Constructors Constructor Description InMemoryAppender()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidappend(ch.qos.logback.classic.spi.ILoggingEvent eventObject)voidclearEvents()Clear all the events that are stored in-memory.Map<Integer,ch.qos.logback.classic.spi.ILoggingEvent>getEventMap()Return a copy of the internal event map.List<String>getOrderedEventMessages()Return the logged messages.List<ch.qos.logback.classic.spi.ILoggingEvent>getOrderedEvents()Return the loggedILoggingEventinstances.Stream<ch.qos.logback.classic.spi.ILoggingEvent>getOrderedEventStream()Return a stream containing the logged events.-
Methods inherited from class ch.qos.logback.core.AppenderBase
addFilter, clearAllFilters, doAppend, getCopyOfAttachedFiltersList, getFilterChainDecision, getName, isStarted, setName, start, stop, toString
-
Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
-
-
-
-
Method Detail
-
append
protected void append(ch.qos.logback.classic.spi.ILoggingEvent eventObject)
- Specified by:
appendin classch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
-
clearEvents
public void clearEvents()
Clear all the events that are stored in-memory.
-
getEventMap
public Map<Integer,ch.qos.logback.classic.spi.ILoggingEvent> getEventMap()
Return a copy of the internal event map. The keys are the message order starting at one, and the values are the corresponding logging events.- Returns:
- an unmodifiable copy of the event map
-
getOrderedEvents
public List<ch.qos.logback.classic.spi.ILoggingEvent> getOrderedEvents()
Return the loggedILoggingEventinstances.- Returns:
- a list containing the logged events
-
getOrderedEventMessages
public List<String> getOrderedEventMessages()
Return the logged messages.- Returns:
- a list containing the logged event messages
-
getOrderedEventStream
public Stream<ch.qos.logback.classic.spi.ILoggingEvent> getOrderedEventStream()
Return a stream containing the logged events.- Returns:
- a stream of the logged events
-
-