Skip to content

Commit

Permalink
fix zio2 logging docs (#1075)
Browse files Browse the repository at this point in the history
Co-authored-by: Ivan Malyshev <[email protected]>
  • Loading branch information
vagroz and Ivan Malyshev authored Dec 28, 2022
1 parent 6b38d4c commit 3738145
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
6 changes: 4 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ lazy val coreModules =
lazy val ce3CoreModules = Vector(coreCE3)

lazy val commonModules =
Vector(observable, logging, loggingEnumeratum, config, zio1Interop, zio2Logging, fs2CE2Interop, doobie, doobieLogging)
Vector(observable, logging, loggingEnumeratum, config, zio1Interop, fs2CE2Interop, doobie, doobieLogging)

lazy val ce3CommonModules =
Vector(loggingStr, loggingDer, loggingLayout, doobieCE3, doobieLoggingCE3, fs2CE3Interop)
Expand All @@ -396,6 +396,8 @@ lazy val mainModuleDeps = (coreModules ++ commonModules).map(x => x: ClasspathDe
lazy val ce3AllModuleRefs = (ce3CoreModules ++ ce3CommonModules).map(x => x: ProjectReference)
lazy val ce3MainModuleDeps = (ce3CoreModules ++ ce3CommonModules).map(x => x: ClasspathDep[ProjectReference])

lazy val zio2Modules = Vector(zio2Logging)

lazy val docs = project // new documentation project
.in(file("tofu-docs"))
.settings(
Expand All @@ -419,7 +421,7 @@ lazy val tofu = project
name := "tofu"
)
.aggregate(
(coreModules ++ commonModules ++ ce3CoreModules ++ ce3CommonModules :+ docs :+ examplesCE2 :+ examplesCE3 :+ examplesZIO2)
(coreModules ++ commonModules ++ ce3CoreModules ++ ce3CommonModules ++ zio2Modules :+ docs :+ examplesCE2 :+ examplesCE3 :+ examplesZIO2)
.map(x => x: ProjectReference): _*
)
.dependsOn(coreModules.map(x => x: ClasspathDep[ProjectReference]): _*)
Expand Down
18 changes: 12 additions & 6 deletions docs/tofu.logging.home.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,31 @@ Add these dependencies into your project:
libraryDependencies += "tf.tofu" %% "tofu-logging" % "<latest version in the badge in README>"
libraryDependencies += "tf.tofu" %% "tofu-logging-derivation" % "<latest version in the badge in README>"
```
`logging` requires an instance of the `Delay` typeclass, which can be created by hand, or can be imported from an according package:

`logging` requires an instance of the `Delay` typeclass, which can be created by hand, or can be imported from an
according package:

Cats Effect 3 users should add the following dependency:

```sbt
libraryDependencies += "tf.tofu" %% "tofu-kernel-ce3-interop" % "<latest version in the badge in README>"
```

and Cats Effect 2 users should add:

```sbt
libraryDependencies += "tf.tofu" %% "tofu-kernel-ce2-interop" % "<latest version in the badge in README>"
```

For ZIO users the following is enough:

```sbt
libraryDependencies += "tf.tofu" %% "tofu-zio2-logging" % "<latest version in the badge in README>" // OR:
libraryDependencies += "tf.tofu" %% "tofu-zio-logging" % "<latest version in the badge in README>"

```
See also [ZIO Logging](./tofu.logging.recipes.zio.md) section.

See also [ZIO1](./tofu.logging.recipes.zio.md), [ZIO2](./tofu.logging.recipes.zio2.md) Logging sections.

## Quick demo

Expand All @@ -48,12 +54,12 @@ type CardNumber = String //could be a newtype
@derive(loggable)
case class Client(name: String, @hidden cardNumber: CardNumber, id: UUID)

def processPayment[F[_]: Monad: Logging](client: Client, amount: Long): F[Result] =
def processPayment[F[_] : Monad : Logging](client: Client, amount: Long): F[Result] =
for {
_ <- info"Processing payment for $client"
_ <- warn"Amount $amount is lower than zero!".whenA(amount < 0)
result <- processData(client, amount, "USD")
.onError(errorCause"Got error on processing payment for $client"(_))
.onError(errorCause"Got error on processing payment for $client"(_))
} yield result
```

Expand All @@ -63,8 +69,8 @@ def processPayment[F[_]: Monad: Logging](client: Client, amount: Long): F[Result
- Get to know [the core concepts](tofu.logging.main.entities.md)
- Learn how to use [the syntax](tofu.logging.syntax.md)
- Find a way to use `logging` suitable for you in the [recipes](tofu.logging.recipes.md)
- Check out [the examples](.././examples/src/main/scala/tofu/example)
- Check out [the examples](.././examples/ce2/src/main/scala-2/tofu/example)

## Old documentation

You can also visit obsolete documentation [here](./logging.old.md).
You can also visit obsolete documentation [here](./logging.old.md).
2 changes: 1 addition & 1 deletion docs/tofu.logging.recipes.zio2.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: ZIO2 Logging

Tofu provides an implementation of `zio.ZLogger` and special annotations called `ZLogAnnotation`
for [ZIO logging facade](https://zio.dev/guides/tutorials/enable-logging-in-a-zio-application).
If you feel more confident with [Tofu Logging](./tofu.logging.main.entities.md#Logging) interface, `ULogging`
If you feel more confident with [Tofu Logging](./tofu.logging.main.entities.md#logging) interface, `ULogging`
, `ZLogging.Make`, `ZLogs` are at your service.

First add the following dependency:
Expand Down

0 comments on commit 3738145

Please sign in to comment.