LogCollector

interface LogCollector

Collects log messages, so they may be asserted on for testing.

Use the optional parameters of takeMessages to constrain which log messages are returned.

Functions

Link copied to clipboard
abstract fun takeEvent(loggerClass: KClass<*>? = null, minLevel: Level = Level.INFO, pattern: Regex? = null): ILoggingEvent

Waits until a matching event is logged, and returns it. The returned event and all preceding events are also removed.

abstract fun takeEvent(loggerClass: KClass<*>? = null, minLevel: Level = Level.INFO, pattern: Regex? = null, consumeUnmatchedLogs: Boolean = false): ILoggingEvent

Take the first matching event, optionally leaving unmatched logs in this collector.

Link copied to clipboard
abstract fun takeEvents(loggerClass: KClass<*>? = null, minLevel: Level = Level.INFO, pattern: Regex? = null): List<ILoggingEvent>

Removes all currently-collected log events and returns those that match the requested criteria.

abstract fun takeEvents(loggerClass: KClass<*>? = null, minLevel: Level = Level.INFO, pattern: Regex? = null, consumeUnmatchedLogs: Boolean = false): List<ILoggingEvent>

Takes all matching events, optionally leaving unmatched logs in this collector.

Link copied to clipboard
abstract fun takeMessage(loggerClass: KClass<*>? = null, minLevel: Level = Level.INFO, pattern: Regex? = null): String

Waits until a matching event is logged, and returns its message. The returned event and all preceding events are also removed.

abstract fun takeMessage(loggerClass: KClass<*>? = null, minLevel: Level = Level.INFO, pattern: Regex? = null, consumeUnmatchedLogs: Boolean = false): String

Takes the first matching message, optionally leaving unmatched logs in this collector.

Link copied to clipboard
abstract fun takeMessages(loggerClass: KClass<*>? = null, minLevel: Level = Level.INFO, pattern: Regex? = null): List<String>

Removes all currently-collected log messages and returns those that match the requested criteria.

abstract fun takeMessages(loggerClass: KClass<*>? = null, minLevel: Level = Level.INFO, pattern: Regex? = null, consumeUnmatchedLogs: Boolean = false): List<String>

Takes all matching messages, optionally leaving unmatched logs in this collector.

Inheritors

Link copied to clipboard