From 4f55721c2e43b34495f9cd26cab28f943fcda6f7 Mon Sep 17 00:00:00 2001 From: findkim Date: Tue, 3 Mar 2020 11:22:34 -0600 Subject: [PATCH] registry: setup client logger --- registry/client.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/registry/client.go b/registry/client.go index a4a80e021..e9cfcab79 100644 --- a/registry/client.go +++ b/registry/client.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/go-retryablehttp" "github.com/hashicorp/terraform-svchost" "github.com/hashicorp/terraform-svchost/disco" + "github.com/hashicorp/terraform/helper/logging" "github.com/hashicorp/terraform/httpclient" "github.com/hashicorp/terraform/registry/regsrc" "github.com/hashicorp/terraform/registry/response" @@ -74,6 +75,13 @@ func NewClient(services *disco.Disco, client *http.Client) *Client { retryableClient.RequestLogHook = requestLogHook retryableClient.ErrorHandler = maxRetryErrorHandler + logOutput, err := logging.LogOutput() + if err != nil { + log.Printf("[WARN] Failed to set up registry client logger, "+ + "continuing without client logging: %s", err) + } + retryableClient.Logger = log.New(logOutput, "", log.Flags()) + services.Transport = retryableClient.HTTPClient.Transport services.SetUserAgent(httpclient.TerraformUserAgent(version.String()))