Skip to content

Commit

Permalink
provider/azurerm: dump entire Request/Response in autorest Decorator (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
pmcatominey authored and stack72 committed Jul 20, 2016
1 parent b4fa54e commit c9138da
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions builtin/providers/azurerm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"
"net/http"
"net/http/httputil"

"github.com/Azure/azure-sdk-for-go/arm/cdn"
"github.com/Azure/azure-sdk-for-go/arm/compute"
Expand Down Expand Up @@ -65,10 +66,23 @@ type ArmClient struct {
func withRequestLogging() autorest.SendDecorator {
return func(s autorest.Sender) autorest.Sender {
return autorest.SenderFunc(func(r *http.Request) (*http.Response, error) {
log.Printf("[DEBUG] Sending Azure RM Request %q to %q\n", r.Method, r.URL)
// dump request to wire format
if dump, err := httputil.DumpRequestOut(r, true); err == nil {
log.Printf("[DEBUG] AzureRM Request: \n%s\n", dump)
} else {
// fallback to basic message
log.Printf("[DEBUG] AzureRM Request: %s to %s\n", r.Method, r.URL)
}

resp, err := s.Do(r)
if resp != nil {
log.Printf("[DEBUG] Received Azure RM Request status code %s for %s\n", resp.Status, r.URL)
// dump response to wire format
if dump, err := httputil.DumpResponse(resp, true); err == nil {
log.Printf("[DEBUG] AzureRM Response for %s: \n%s\n", r.URL, dump)
} else {
// fallback to basic message
log.Printf("[DEBUG] AzureRM Response: %s for %s\n", resp.Status, r.URL)
}
} else {
log.Printf("[DEBUG] Request to %s completed with no response", r.URL)
}
Expand Down

0 comments on commit c9138da

Please sign in to comment.