Skip to content

Commit

Permalink
Make header value computation in request logging lazy (#2367)
Browse files Browse the repository at this point in the history
  • Loading branch information
987Nabil authored Aug 12, 2023
1 parent 5911532 commit 05158cd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions zio-http/src/main/scala/zio/http/HandlerAspect.scala
Original file line number Diff line number Diff line change
Expand Up @@ -705,12 +705,12 @@ private[http] trait HandlerAspects extends zio.http.internal.HeaderModifier[Hand

ZIO
.logLevel(level(response.status)) {
val requestHeaders =
def requestHeaders =
request.headers.collect {
case header: Header if loggedRequestHeaderNames.contains(header.headerName.toLowerCase) =>
LogAnnotation(header.headerName, header.renderedValue)
}.toSet
val responseHeaders =
def responseHeaders =
response.headers.collect {
case header: Header if loggedResponseHeaderNames.contains(header.headerName.toLowerCase) =>
LogAnnotation(header.headerName, header.renderedValue)
Expand Down
4 changes: 2 additions & 2 deletions zio-http/src/main/scala/zio/http/ZClientAspect.scala
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,12 @@ object ZClientAspect {
case (duration, Exit.Success(response)) =>
ZIO
.logLevel(level(response.status)) {
val requestHeaders =
def requestHeaders =
headers.collect {
case header: Header if loggedRequestHeaderNames.contains(header.headerName.toLowerCase) =>
LogAnnotation(header.headerName, header.renderedValue)
}.toSet
val responseHeaders =
def responseHeaders =
response.headers.collect {
case header: Header if loggedResponseHeaderNames.contains(header.headerName.toLowerCase) =>
LogAnnotation(header.headerName, header.renderedValue)
Expand Down

0 comments on commit 05158cd

Please sign in to comment.