Skip to content

Commit

Permalink
aws/client: Update client to only log request headers when enabled (#…
Browse files Browse the repository at this point in the history
…4084)

Updates the SDK's base client to only log request headers when logging
is enabled. This fixes an issue where event stream API operations would
always log request headers. Regardless if logging was enabled or not.
  • Loading branch information
jasdel authored Sep 14, 2021
1 parent aa6517e commit dc8260e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
* Updates the documentation for API parameters that will be suppressed in structures' String and GoString methods.

### SDK Bugs
* `aws/client`: Update client logging to only log request headers when logging is enabled
* Updates the SDK's base client to only log request headers when logging is enabled. This fixes an issue where event stream API operations would always log request headers. Regardless if logging was enabled or not.
10 changes: 7 additions & 3 deletions aws/client/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var LogHTTPRequestHandler = request.NamedHandler{
}

func logRequest(r *request.Request) {
if !r.Config.LogLevel.AtLeast(aws.LogDebug) {
if !r.Config.LogLevel.AtLeast(aws.LogDebug) || r.Config.Logger == nil {
return
}

Expand Down Expand Up @@ -94,6 +94,10 @@ var LogHTTPRequestHeaderHandler = request.NamedHandler{
}

func logRequestHeader(r *request.Request) {
if !r.Config.LogLevel.AtLeast(aws.LogDebug) || r.Config.Logger == nil {
return
}

b, err := httputil.DumpRequestOut(r.HTTPRequest, false)
if err != nil {
r.Config.Logger.Log(fmt.Sprintf(logReqErrMsg,
Expand Down Expand Up @@ -124,7 +128,7 @@ var LogHTTPResponseHandler = request.NamedHandler{
}

func logResponse(r *request.Request) {
if !r.Config.LogLevel.AtLeast(aws.LogDebug) {
if !r.Config.LogLevel.AtLeast(aws.LogDebug) || r.Config.Logger == nil {
return
}

Expand Down Expand Up @@ -186,7 +190,7 @@ var LogHTTPResponseHeaderHandler = request.NamedHandler{
}

func logResponseHeader(r *request.Request) {
if r.Config.Logger == nil {
if !r.Config.LogLevel.AtLeast(aws.LogDebug) || r.Config.Logger == nil {
return
}

Expand Down

0 comments on commit dc8260e

Please sign in to comment.