Documentation ¶
Index ¶
- Constants
- func HelperResourceDebug(ctx context.Context, msg string, additionalFields ...map[string]interface{})
- func HelperResourceError(ctx context.Context, msg string, additionalFields ...map[string]interface{})
- func HelperResourceTrace(ctx context.Context, msg string, additionalFields ...map[string]interface{})
- func HelperResourceWarn(ctx context.Context, msg string, additionalFields ...map[string]interface{})
- func HelperSchemaDebug(ctx context.Context, msg string, additionalFields ...map[string]interface{})
- func HelperSchemaError(ctx context.Context, msg string, additionalFields ...map[string]interface{})
- func HelperSchemaTrace(ctx context.Context, msg string, additionalFields ...map[string]interface{})
- func HelperSchemaWarn(ctx context.Context, msg string, additionalFields ...map[string]interface{})
- func InitContext(ctx context.Context) context.Context
- func InitTestContext(ctx context.Context, t testing.T) context.Context
- func TestNameContext(ctx context.Context, testName string) context.Context
- func TestStepNumberContext(ctx context.Context, stepNumber int) context.Context
- func TestTerraformPathContext(ctx context.Context, terraformPath string) context.Context
- func TestWorkingDirectoryContext(ctx context.Context, workingDirectory string) context.Context
Constants ¶
const ( // EnvTfLogSdk is an environment variable that sets the logging level of // the root SDK logger, while the provider is under test. In "production" // usage, this environment variable is handled by terraform-plugin-go. // // Terraform CLI's logging must be explicitly turned on before this // environment varable can be used to reduce the SDK logging levels. It // cannot be used to show only SDK logging unless all other logging levels // are turned off. EnvTfLogSdk = "TF_LOG_SDK" // EnvTfLogSdkHelperResource is an environment variable that sets the logging // level of SDK helper/resource loggers. Infers root SDK logging level, if // unset. EnvTfLogSdkHelperResource = "TF_LOG_SDK_HELPER_RESOURCE" // EnvTfLogSdkHelperSchema is an environment variable that sets the logging // level of SDK helper/schema loggers. Infers root SDK logging level, if // unset. EnvTfLogSdkHelperSchema = "TF_LOG_SDK_HELPER_SCHEMA" )
Environment variables.
const ( // Attribute path representation, which is typically in flatmap form such // as parent.0.child in this project. KeyAttributePath = "tf_attribute_path" // The type of data source being operated on, such as "archive_file" KeyDataSourceType = "tf_data_source_type" // Underlying Go error string when logging an error. KeyError = "error" // The full address of the provider, such as // registry.terraform.io/hashicorp/random KeyProviderAddress = "tf_provider_addr" // The type of resource being operated on, such as "random_pet" KeyResourceType = "tf_resource_type" // The name of the test being executed. KeyTestName = "test_name" // The TestStep number of the test being executed. Starts at 1. KeyTestStepNumber = "test_step_number" // Terraform configuration used during acceptance testing Terraform operations. KeyTestTerraformConfiguration = "test_terraform_configuration" // The Terraform CLI logging level (TF_LOG) used for an acceptance test. KeyTestTerraformLogLevel = "test_terraform_log_level" // The Terraform CLI logging level (TF_LOG_CORE) used for an acceptance test. KeyTestTerraformLogCoreLevel = "test_terraform_log_core_level" // The Terraform CLI logging level (TF_LOG_PROVIDER) used for an acceptance test. KeyTestTerraformLogProviderLevel = "test_terraform_log_provider_level" // The path to the Terraform CLI logging file used for an acceptance test. // // This should match where the rest of the acceptance test logs are going // already, but is provided for troubleshooting in case it does not. KeyTestTerraformLogPath = "test_terraform_log_path" // The path to the Terraform CLI used for an acceptance test. KeyTestTerraformPath = "test_terraform_path" // Terraform plan output generated during a TestStep. KeyTestTerraformPlan = "test_terraform_plan" // The working directory of the acceptance test. KeyTestWorkingDirectory = "test_working_directory" )
Structured logging keys.
Practitioners or tooling reading logs may be depending on these keys, so be conscious of that when changing them.
Refer to the terraform-plugin-go logging keys as well, which should be equivalent to these when possible.
const (
// SubsystemHelperResource is the tfsdklog subsystem name for helper/resource.
SubsystemHelperResource = "helper_resource"
)
const (
// SubsystemHelperSchema is the tfsdklog subsystem name for helper/schema.
SubsystemHelperSchema = "helper_schema"
)
Variables ¶
This section is empty.
Functions ¶
func HelperResourceDebug ¶
func HelperResourceDebug(ctx context.Context, msg string, additionalFields ...map[string]interface{})
HelperResourceDebug emits a helper/resource subsystem log at DEBUG level.
func HelperResourceError ¶
func HelperResourceError(ctx context.Context, msg string, additionalFields ...map[string]interface{})
HelperResourceError emits a helper/resource subsystem log at ERROR level.
func HelperResourceTrace ¶
func HelperResourceTrace(ctx context.Context, msg string, additionalFields ...map[string]interface{})
HelperResourceTrace emits a helper/resource subsystem log at TRACE level.
func HelperResourceWarn ¶
func HelperResourceWarn(ctx context.Context, msg string, additionalFields ...map[string]interface{})
HelperResourceWarn emits a helper/resource subsystem log at WARN level.
func HelperSchemaDebug ¶
HelperSchemaDebug emits a helper/schema subsystem log at DEBUG level.
func HelperSchemaError ¶
HelperSchemaError emits a helper/schema subsystem log at ERROR level.
func HelperSchemaTrace ¶
HelperSchemaTrace emits a helper/schema subsystem log at TRACE level.
func HelperSchemaWarn ¶
HelperSchemaWarn emits a helper/schema subsystem log at WARN level.
func InitContext ¶
InitContext creates SDK logger contexts when the provider is running in "production" (not under acceptance testing). The incoming context will already have the root SDK logger and root provider logger setup from terraform-plugin-go tf5server RPC handlers.
func InitTestContext ¶
InitTestContext registers the terraform-plugin-log/tfsdklog test sink, configures the standard library log package, and creates SDK logger contexts. The incoming context is expected to be devoid of logging setup.
The standard library log package handling is important as provider code under test may be using that package or another logging library outside of terraform-plugin-log.
func TestNameContext ¶
TestNameContext adds the current test name to loggers.
func TestStepNumberContext ¶
TestStepNumberContext adds the current test step number to loggers.
func TestTerraformPathContext ¶
TestTerraformPathContext adds the current test Terraform CLI path to loggers.
Types ¶
This section is empty.