ZTestLogger

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)
}
Companion:
object
trait ZLogger[Message, Output]
class Object
trait Matchable
class Any

Value members

Abstract methods

Returns the contents of the log.

Returns the contents of the log.

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.

Inherited from:
ZLogger
def +>[M <: Message, O](that: ZLogger[M, O]): ZLogger[M, O]
Inherited from:
ZLogger
def <+[M <: Message](that: ZLogger[M, Any]): ZLogger[M, Output]
Inherited from:
ZLogger
def apply(trace: Trace, fiberId: FiberId, logLevel: LogLevel, message: () => Message, cause: Cause[Any], context: FiberRefs, spans: List[LogSpan], annotations: Map[String, String]): Output
Inherited from:
ZLogger
final def contramap[Message1](f: Message1 => Message): ZLogger[Message1, Output]
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.

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