EventFilter

Facilities for selectively filtering out expected events from logging so that you can keep your test run’s console output clean and do not miss real error messages.

'''Also have a look at the akka.testkit package object’s filterEvents and filterException methods.'''

The source filters do accept Class[_] arguments, matching any object which is an instance of the given class, e.g.

EventFilter.info(source = classOf[MyActor]) // will match Info events from any MyActor instance

The message object will be converted to a string before matching ("null" if it is null).

Companion:
class
Source:
TestEventListener.scala
class Object
trait Matchable
class Any

Value members

Concrete methods

def apply[A <: Throwable : ClassTag](message: String, source: String, start: String, pattern: String, occurrences: Int): EventFilter

Create a filter for Error events. Give up to one of start and pattern:

Create a filter for Error events. Give up to one of start and pattern:

EventFilter[MyException]()                                         // filter only on exception type
EventFilter[MyException]("message")                                // filter on exactly matching message
EventFilter[MyException](source = obj)                             // filter on event source
EventFilter[MyException](start = "Expected")                       // filter on start of message
EventFilter[MyException](source = obj, pattern = "weird.*message") // filter on pattern and message

''Please note that filtering on the source being null does NOT work (passing null disables the source filter).''

Source:
TestEventListener.scala

Create a custom event filter. The filter will affect those events for which the supplied partial function is defined and returns true.

Create a custom event filter. The filter will affect those events for which the supplied partial function is defined and returns true.

EventFilter.custom {
 case Warning(ref, "my warning") if ref == actor || ref == null => true
}
Source:
TestEventListener.scala
def debug(message: String, source: String, start: String, pattern: String, occurrences: Int): EventFilter

Create a filter for Debug events. Give up to one of start and pattern:

Create a filter for Debug events. Give up to one of start and pattern:

EventFilter.debug()                                         // filter only on debug type
EventFilter.debug(source = obj)                             // filter on event source
EventFilter.debug(start = "Expected")                       // filter on start of message
EventFilter.debug(source = obj, pattern = "weird.*message") // filter on pattern and message

''Please note that filtering on the source being null does NOT work (passing null disables the source filter).''

Source:
TestEventListener.scala
def error(message: String, source: String, start: String, pattern: String, occurrences: Int): EventFilter

Create a filter for Error events. See apply() for more details.

Create a filter for Error events. See apply() for more details.

Source:
TestEventListener.scala
def info(message: String, source: String, start: String, pattern: String, occurrences: Int): EventFilter

Create a filter for Info events. Give up to one of start and pattern:

Create a filter for Info events. Give up to one of start and pattern:

EventFilter.info()                                         // filter only on info event
EventFilter.info(source = obj)                             // filter on event source
EventFilter.info(start = "Expected")                       // filter on start of message
EventFilter.info(source = obj, pattern = "weird.*message") // filter on pattern and message

''Please note that filtering on the source being null does NOT work (passing null disables the source filter).''

Source:
TestEventListener.scala
def warning(message: String, source: String, start: String, pattern: String, occurrences: Int): EventFilter

Create a filter for Warning events. Give up to one of start and pattern:

Create a filter for Warning events. Give up to one of start and pattern:

EventFilter.warning()                                         // filter only on warning event
EventFilter.warning(source = obj)                             // filter on event source
EventFilter.warning(start = "Expected")                       // filter on start of message
EventFilter.warning(source = obj, pattern = "weird.*message") // filter on pattern and message

''Please note that filtering on the source being null does NOT work (passing null disables the source filter).''

Source:
TestEventListener.scala