Created
February 24, 2020 16:40
-
-
Save goyox86/a1d4df61a4ad5db09afc66ef244ad2e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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