sup has a log4cats module:

libraryDependencies += "com.kubukoz" %% "sup-log4cats" % "0.7.0"


import sup._, sup.modules.log4cats._

What’s included


The log4cats module of sup provides a simple modifier that logs a message before the check and a message with the result of the healthcheck:

import cats._, cats.implicits._, cats.effect._,
import io.chrisdavenport.log4cats.Logger, io.chrisdavenport.log4cats.extras._

val healthCheck: HealthCheck[Id, Id] = HealthCheck.const(Health.Healthy)
// healthCheck: HealthCheck[Id, Id] = sup.HealthCheck$$anon$1@7a5daad1

implicit val logger: Logger[Writer[Chain[LogMessage], ?]] = WriterLogger()
// logger: Logger[WriterT[A, Chain[LogMessage], β$0$]] = io.chrisdavenport.log4cats.extras.WriterLogger$$anon$1@51513562
val loggedCheck = healthCheck.leftMapK(WriterT.liftK[Id, Chain[LogMessage]]).through(logged("foo"))
// loggedCheck: HealthCheck[WriterT[Id, Chain[LogMessage], V], Id] = sup.HealthCheck$$anon$1@6a50e9b0
val (logs, result) =
// logs: List[LogMessage] = List(
//   LogMessage(Debug, None, "Checking health for foo"),
//   LogMessage(Debug, None, "Health result for foo: Healthy")
// )
// result: HealthResult[Id] = HealthResult(Healthy)