diff --git a/client/testserver/src/main/scala/sttp/tapir/client/tests/HttpServer.scala b/client/testserver/src/main/scala/sttp/tapir/client/tests/HttpServer.scala index f280c7e700..99afcfa38d 100644 --- a/client/testserver/src/main/scala/sttp/tapir/client/tests/HttpServer.scala +++ b/client/testserver/src/main/scala/sttp/tapir/client/tests/HttpServer.scala @@ -12,7 +12,8 @@ import org.http4s.blaze.server.BlazeServerBuilder import org.http4s.server.middleware._ import org.http4s.server.websocket.WebSocketBuilder2 import org.http4s.websocket.WebSocketFrame -import org.http4s.{multipart, _} +import org.http4s._ +import org.slf4j.LoggerFactory import org.typelevel.ci.CIString import scodec.bits.ByteVector import sttp.tapir.client.tests.HttpServer._ @@ -30,7 +31,7 @@ object HttpServer { class HttpServer(port: Port) { - private val logger = org.log4s.getLogger + private val logger = LoggerFactory.getLogger(getClass) private var stopServer: IO[Unit] = _ diff --git a/server/http4s-server/src/main/scalajvm/sttp/tapir/server/http4s/Http4sDefaultServerLog.scala b/server/http4s-server/src/main/scalajvm/sttp/tapir/server/http4s/Http4sDefaultServerLog.scala index 341e430e72..a82563fa90 100644 --- a/server/http4s-server/src/main/scalajvm/sttp/tapir/server/http4s/Http4sDefaultServerLog.scala +++ b/server/http4s-server/src/main/scalajvm/sttp/tapir/server/http4s/Http4sDefaultServerLog.scala @@ -1,25 +1,26 @@ package sttp.tapir.server.http4s import cats.effect.Sync +import org.typelevel.log4cats.Logger +import org.typelevel.log4cats.slf4j.Slf4jLogger import sttp.tapir.server.interceptor.log.DefaultServerLog -import org.log4s.{Logger, getLogger} object Http4sDefaultServerLog { - private[http4s] val log: Logger = getLogger def apply[F[_]: Sync]: DefaultServerLog[F] = { + val log = Slf4jLogger.getLogger[F] DefaultServerLog( - doLogWhenReceived = debugLog(_, None), - doLogWhenHandled = debugLog[F], - doLogAllDecodeFailures = debugLog[F], - doLogExceptions = (msg: String, ex: Throwable) => Sync[F].delay(log.error(ex)(msg)), + doLogWhenReceived = msg => debugLog(log)(msg, None), + doLogWhenHandled = debugLog(log), + doLogAllDecodeFailures = debugLog(log), + doLogExceptions = (msg: String, ex: Throwable) => log.error(ex)(msg), noLog = Sync[F].pure(()) ) } - private def debugLog[F[_]](msg: String, exOpt: Option[Throwable])(implicit sync: Sync[F]): F[Unit] = + private def debugLog[F[_]](log: Logger[F])(msg: String, exOpt: Option[Throwable]): F[Unit] = exOpt match { - case None => Sync[F].delay(log.debug(msg)) - case Some(ex) => Sync[F].delay(log.debug(ex)(msg)) + case None => log.debug(msg) + case Some(ex) => log.debug(ex)(msg) } }