diff --git a/azurerm/provider.go b/azurerm/provider.go index 7c1a0be64b6a..4ff8e9e702aa 100644 --- a/azurerm/provider.go +++ b/azurerm/provider.go @@ -3,6 +3,7 @@ package azurerm import ( "fmt" "log" + "os" "github.com/hashicorp/go-azure-helpers/authentication" "github.com/hashicorp/terraform/helper/schema" @@ -434,8 +435,16 @@ func Provider() terraform.ResourceProvider { "azurerm_web_application_firewall_policy": resourceArmWebApplicationFirewallPolicy(), } + // avoids this showing up in test output + var debugLog = func(f string, v ...interface{}) { + if os.Getenv("TF_LOG") == "" { + return + } + + log.Printf(f, v...) + } for _, service := range supportedServices { - log.Printf("[DEBUG] Registering Data Sources for %q..", service.Name()) + debugLog("[DEBUG] Registering Data Sources for %q..", service.Name()) for k, v := range service.SupportedDataSources() { if existing := dataSources[k]; existing != nil { panic(fmt.Sprintf("An existing Data Source exists for %q", k)) @@ -444,7 +453,7 @@ func Provider() terraform.ResourceProvider { dataSources[k] = v } - log.Printf("[DEBUG] Registering Resources for %q..", service.Name()) + debugLog("[DEBUG] Registering Resources for %q..", service.Name()) for k, v := range service.SupportedResources() { if existing := resources[k]; existing != nil { panic(fmt.Sprintf("An existing Resource exists for %q", k))