All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sttp.client3.logging.slf4j.Slf4jLoggingBackend.scala Maven / Gradle / Ivy

There is a newer version: 3.10.0
Show newest version
package sttp.client3.logging.slf4j

import sttp.client3._
import sttp.client3.logging.{DefaultLog, LogLevel, LoggingBackend}
import sttp.model.{HeaderNames, StatusCode}

object Slf4jLoggingBackend {
  def apply[F[_], S](
      delegate: SttpBackend[F, S],
      includeTiming: Boolean = true,
      beforeCurlInsteadOfShow: Boolean = false,
      logRequestBody: Boolean = false,
      logRequestHeaders: Boolean = true,
      logResponseBody: Boolean = false,
      logResponseHeaders: Boolean = true,
      sensitiveHeaders: Set[String] = HeaderNames.SensitiveHeaders,
      beforeRequestSendLogLevel: LogLevel = LogLevel.Debug,
      responseLogLevel: StatusCode => LogLevel = DefaultLog.defaultResponseLogLevel,
      responseExceptionLogLevel: LogLevel = LogLevel.Error
  ): SttpBackend[F, S] = {
    val logger = new Slf4jLogger("sttp.client3.logging.slf4j.Slf4jLoggingBackend", delegate.responseMonad)
    LoggingBackend(
      delegate,
      logger,
      includeTiming,
      beforeCurlInsteadOfShow,
      logRequestBody,
      logRequestHeaders,
      logResponseBody,
      logResponseHeaders,
      sensitiveHeaders,
      beforeRequestSendLogLevel,
      responseLogLevel,
      responseExceptionLogLevel
    )
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy