Quickstart
This is a set of tools for logging. Configurable, concise, handy.
Installation
Section titled “Installation”Add these dependencies into your project:
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:
"tf.tofu" %% "tofu-core-ce3" % "0.14.0"
and Cats Effect 2 users should add:
"tf.tofu" %% "tofu-core-ce2" % "0.14.0"
For ZIO users the following is enough:
"tf.tofu" %% "tofu-zio2-logging" % "0.14.0" // OR:"tf.tofu" %% "tofu-zio-logging" % "0.14.0"
See also ZIO1, ZIO2 Logging sections.
Quick demo
Section titled “Quick demo”import tofu.syntax.logging._import tofu.logging.Loggingimport derevo.deriveimport tofu.logging.derivation.loggable
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] = 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"(_)) } yield result
What’s next
Section titled “What’s next”- Discover the key features
- Get to know the core concepts
- Learn how to use the syntax
- Find a way to use
logging
suitable for you in the recipes - Check out the examples
Old documentation
Section titled “Old documentation”You can also visit obsolete documentation here.