ZTestLogger

zio.test.ZTestLogger
See theZTestLogger companion object
sealed trait ZTestLogger[-Message, +Output] extends ZLogger[Message, Output]

A ZTestLogger is an implementation of a ZLogger that writes all log messages to an internal data structure. The contents of this data structure can be accessed using the logOutput operator. This makes it easy to write tests to verify that expected messages are being logged.

test("logging works") {
 for {
   _      <- ZIO.logDebug("It's alive!")
   output <- ZTestLogger.logOutput
 } yield assertTrue(output.length == 1) &&
   assertTrue(output(0).message() == "It's alive!") &&
   assertTrue(output(0).logLevel == LogLevel.Debug)
}

Attributes

Companion:
object
Graph
Supertypes
trait ZLogger[Message, Output]
class Object
trait Matchable
class Any

Members list

Concise view

Value members

Abstract methods

Returns the contents of the log.

Returns the contents of the log.

Attributes

Inherited methods

def ++[M <: Message, O](that: ZLogger[M, O])(implicit zippable: Zippable[Output, O]): ZLogger[M, Out]

Combines this logger with the specified logger to produce a new logger that logs to both this logger and that logger.

Combines this logger with the specified logger to produce a new logger that logs to both this logger and that logger.

Attributes

Inherited from:
ZLogger
def +>[M <: Message, O](that: ZLogger[M, O]): ZLogger[M, O]

Attributes

Inherited from:
ZLogger
def <+[M <: Message](that: ZLogger[M, Any]): ZLogger[M, Output]

Attributes

Inherited from:
ZLogger

Attributes

Inherited from:
ZLogger
final def contramap[Message1](f: Message1 => Message): ZLogger[Message1, Output]

Attributes

Inherited from:
ZLogger
final def filterLogLevel(f: LogLevel => Boolean): ZLogger[Message, Option[Output]]

Returns a version of this logger that only logs messages when the log level satisfies the specified predicate.

Returns a version of this logger that only logs messages when the log level satisfies the specified predicate.

Attributes

Inherited from:
ZLogger
final def map[B](f: Output => B): ZLogger[Message, B]

Attributes

Inherited from:
ZLogger
final def test(input: => Message): Output

Attributes

Inherited from:
ZLogger