logging

package
v2.11.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2022 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 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.

View Source
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"

	// The path to the Terraform CLI used for an acceptance test.
	KeyTestTerraformPath = "test_terraform_path"

	// 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.

View Source
const (
	// SubsystemHelperResource is the tfsdklog subsystem name for helper/resource.
	SubsystemHelperResource = "helper_resource"
)
View Source
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

func HelperSchemaDebug(ctx context.Context, msg string, additionalFields ...map[string]interface{})

HelperSchemaDebug emits a helper/schema subsystem log at DEBUG level.

func HelperSchemaTrace

func HelperSchemaTrace(ctx context.Context, msg string, additionalFields ...map[string]interface{})

HelperSchemaTrace emits a helper/schema subsystem log at TRACE level.

func HelperSchemaWarn

func HelperSchemaWarn(ctx context.Context, msg string, additionalFields ...map[string]interface{})

HelperSchemaWarn emits a helper/schema subsystem log at WARN level.

func InitContext

func InitContext(ctx context.Context) context.Context

InitContext creates SDK logger contexts.

func InitTestContext

func InitTestContext(ctx context.Context, t testing.T) context.Context

InitTestContext registers the terraform-plugin-log/tfsdklog test sink, configures the standard library log package, and creates SDK logger contexts.

It may be possible to eliminate the helper/logging handling if all log package calls are replaced with tfsdklog and any go-plugin or terraform-exec logger configurations are updated to the tfsdklog logger.

func TestNameContext

func TestNameContext(ctx context.Context, testName string) context.Context

TestNameContext adds the current test name to loggers.

func TestStepNumberContext

func TestStepNumberContext(ctx context.Context, stepNumber int) context.Context

TestStepNumberContext adds the current test step number to loggers.

func TestTerraformPathContext

func TestTerraformPathContext(ctx context.Context, terraformPath string) context.Context

TestTerraformPathContext adds the current test Terraform CLI path to loggers.

func TestWorkingDirectoryContext

func TestWorkingDirectoryContext(ctx context.Context, workingDirectory string) context.Context

TestWorkingDirectoryContext adds the current test working directory to loggers.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL