Class LoggingTestKit
Requires Logback.
See the static factory methods as starting point for creating LoggingTestKit.
Not for user extension.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic LoggingTestKitcustom(scala.Function1<LoggingEvent, Object> test) Create a custom event filter.static LoggingTestKitFilter for the logging of dead letters.static LoggingTestKitCreate a filter for DEBUG level events with a log message that contains the givenmessageIncludes.static LoggingTestKitempty()An empty filter that doesn't match any events.static LoggingTestKitCreate a filter for ERROR level events with an includedthrowablethat is a class or subclass of the given *Throwableclass.static LoggingTestKitCreate a filter for ERROR level events with a log message that contains the givenmessageIncludes.abstract <T> Texpect(ActorSystem<?> system, Supplier<T> code) Run the given code block and assert that the criteria of thisLoggingTestKithas matched within the configuredpekko.actor.testkit.typed.filter-leewayas often as requested by itsoccurrencesparameter specifies.static LoggingTestKitCreate a filter for INFO level events with a log message that contains the givenmessageIncludes.abstract booleanmatches(LoggingEvent event) static LoggingTestKitmessageContains(String str) Create a filter for events with a log message that contains the givenmessageIncludes.static LoggingTestKitCreate a filter for TRACE level events with a log message that contains the givenmessageIncludes.static LoggingTestKitCreate a filter for WARN level events with an includedthrowablethat is a class or subclass of the given *Throwableclass.static LoggingTestKitCreate a filter for WARN level events with a log message that contains the givenmessageIncludes.abstract LoggingTestKitMatching events with an includedthrowablethat is a class or subclass of the givenThrowableclass.abstract LoggingTestKitwithCheckExcess(boolean check) After matching the expected number of hits, check for excess messagesabstract LoggingTestKitwithCustom(scala.Function1<LoggingEvent, Object> newCustom) Matching events for which the supplied function returnstrue.abstract LoggingTestKitwithLoggerName(String newLoggerName) Matching events with the given logger name or sub-names in the same way as configuration loggers are configured in logback.xml.abstract LoggingTestKitwithLogLevel(org.slf4j.event.Level newLogLevel) Matching events with the given log level.abstract LoggingTestKitMatching events with MDC containing all entries of the givenMap.abstract LoggingTestKitwithMessageContains(String newMessageContains) Matching events with a message that contains the given value.abstract LoggingTestKitwithMessageRegex(String newMessageRegex) Matching events with a message that matches the given regular expression.abstract LoggingTestKitwithOccurrences(int newOccurrences) Number of events the testkit is supposed to match.abstract LoggingTestKitwithSource(String newSource) Matching events that have "pekkoSource" MDC value equal to the given value.
-
Constructor Details
-
LoggingTestKit
public LoggingTestKit()
-
-
Method Details
-
empty
An empty filter that doesn't match any events.More conditions can be added to the returned [LoggingEventFilter].
-
messageContains
Create a filter for events with a log message that contains the givenmessageIncludes.More conditions can be added to the returned [LoggingEventFilter].
-
trace
Create a filter for TRACE level events with a log message that contains the givenmessageIncludes.More conditions can be added to the returned [LoggingEventFilter].
-
debug
Create a filter for DEBUG level events with a log message that contains the givenmessageIncludes.More conditions can be added to the returned [LoggingEventFilter].
-
info
Create a filter for INFO level events with a log message that contains the givenmessageIncludes.More conditions can be added to the returned [LoggingEventFilter].
-
warn
Create a filter for WARN level events with a log message that contains the givenmessageIncludes.More conditions can be added to the returned [LoggingEventFilter].
-
warn
Create a filter for WARN level events with an includedthrowablethat is a class or subclass of the given *Throwableclass.More conditions can be added to the returned [LoggingEventFilter].
-
error
Create a filter for ERROR level events with a log message that contains the givenmessageIncludes.More conditions can be added to the returned [LoggingEventFilter].
-
error
Create a filter for ERROR level events with an includedthrowablethat is a class or subclass of the given *Throwableclass.More conditions can be added to the returned [LoggingEventFilter].
-
custom
Create a custom event filter. The filter will match those events for which for which the supplied function returnstrue. -
deadLetters
Filter for the logging of dead letters. -
withOccurrences
Number of events the testkit is supposed to match. By default 1.When occurrences > 0 it will not look for excess messages that are logged asynchronously outside (after) the
interceptthunk and it has already found expected number.When occurrences is 0 it will look for unexpected matching events, and then it will also look for excess messages during the configured
pekko.actor.testkit.typed.expect-no-message-defaultduration. -
withLogLevel
Matching events with the given log level. -
withLoggerName
Matching events with the given logger name or sub-names in the same way as configuration loggers are configured in logback.xml. By default the root logger is used. -
withSource
Matching events that have "pekkoSource" MDC value equal to the given value. "pekkoSource" is typically the actor path. -
withMessageContains
Matching events with a message that contains the given value. -
withMessageRegex
Matching events with a message that matches the given regular expression. -
withCause
Matching events with an includedthrowablethat is a class or subclass of the givenThrowableclass. -
withMdc
Matching events with MDC containing all entries of the givenMap. The event MDC may have more entries than the givenMap. -
withCheckExcess
After matching the expected number of hits, check for excess messages -
withCustom
Matching events for which the supplied function returnstrue. -
matches
- Returns:
trueif the event matches the conditions of the filter.
-
expect
Run the given code block and assert that the criteria of thisLoggingTestKithas matched within the configuredpekko.actor.testkit.typed.filter-leewayas often as requested by itsoccurrencesparameter specifies.Care is taken to remove the testkit when the block is finished or aborted.
-