Skip to content

Instantly share code, notes, and snippets.

@goyox86
Created February 24, 2020 16:40
Show Gist options
  • Save goyox86/a1d4df61a4ad5db09afc66ef244ad2e0 to your computer and use it in GitHub Desktop.
Save goyox86/a1d4df61a4ad5db09afc66ef244ad2e0 to your computer and use it in GitHub Desktop.
import zio._
import zio.console._
import zio.logging._
import zio.ZEnv
object Main extends App {
type Env = Logging with Console
val program: ZIO[Env, Nothing, Unit] = {
putStrLn("Hello ZIO! from Console") *>
log("Hello from ZIO from logger")
}
val programLive = {
val consoleLogging = Logging.console((_, logEntry) =>
logEntry
)
val consoleLoggingLayer = ZLayer.fromEffect(consoleLogging)
program.provideCustomLayer(consoleLoggingLayer)
}
override def run(args: List[String]): ZIO[ZEnv, Nothing, Int] = {
programLive.as(0)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment