All Downloads are FREE. Search and download functionalities are using the official Maven repository.

zio.test.ExecutionEventConsolePrinter.scala Maven / Gradle / Ivy

There is a newer version: 2.1.14
Show newest version
package zio.test

import zio._

private[test] trait ExecutionEventConsolePrinter {
  def print(event: ExecutionEvent): ZIO[Any, Nothing, Unit]
}

private[test] object ExecutionEventConsolePrinter {
  def live(renderer: ReporterEventRenderer): ZLayer[TestLogger, Nothing, ExecutionEventConsolePrinter] =
    ZLayer {
      for {
        testLogger <- ZIO.service[TestLogger]
      } yield Live(testLogger, renderer)
    }

  case class Live(logger: TestLogger, eventRenderer: ReporterEventRenderer) extends ExecutionEventConsolePrinter {
    override def print(event: ExecutionEvent): ZIO[Any, Nothing, Unit] = {
      val rendered = eventRenderer.render(event)
      ZIO
        .when(rendered.nonEmpty)(
          logger.logLine(
            rendered.mkString("\n")
          )
        )
        .unit
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy