Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Commit

Permalink
Add trace-logs for request- and response-headers
Browse files Browse the repository at this point in the history
  • Loading branch information
JannikArndt committed Sep 29, 2020
1 parent 4dfe3ba commit 895099e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/scala/io/moia/scalaHttpClient/HttpClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ abstract class HttpLayer[LoggingContext](

private[this] def logRequest[T](implicit ctx: LoggingContext): PartialFunction[Try[HttpRequest], Unit] = { case Success(request) =>
logger.debug(s"[$name] Sending request to ${request.method.value} ${request.uri}.")
logger.trace(s"[$name] Request headers: ${request.headers.map(h => s"[${h.name()} -> ${h.value()}]").mkString(", ")}")
}

private[this] def logRetryAfter(implicit ctx: LoggingContext): PartialFunction[Try[HttpResponse], Unit] = {
Expand All @@ -202,6 +203,7 @@ abstract class HttpLayer[LoggingContext](
case Success(response) =>
httpMetrics.meterResponse(request.method, request.uri.path, response)
logger.debug(s"[$name] Received response ${response.status} from ${request.method.value} ${request.uri}.")
logger.trace(s"[$name] Response headers: ${response.headers.map(h => s"[${h.name()} -> ${h.value()}]").mkString(", ")}")
case Failure(e) =>
logger.info(s"[$name] Exception for ${request.method.value} ${request.uri}: ${e.getMessage}", e)
}
Expand Down

0 comments on commit 895099e

Please sign in to comment.