Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce tfsdklog helper_resource Subsystem #838

Closed
bflad opened this issue Dec 23, 2021 · 1 comment · Fixed by #891
Closed

Introduce tfsdklog helper_resource Subsystem #838

bflad opened this issue Dec 23, 2021 · 1 comment · Fixed by #891
Assignees
Labels
enhancement New feature or request subsystem/tests Issues and feature requests related to the testing framework.
Milestone

Comments

@bflad
Copy link
Member

bflad commented Dec 23, 2021

SDK version

v2.10.1

Use-cases

SDK maintainers and provider developers would love additional logging information from the acceptance testing framework. Similar to our recent addition of helper_schema for the "SDK logic", it would be great to bootstrap a logging subsystem for the testing code in helper/resource.

Proposal

package resource

const tflogSubsystemName = "helper_resource"

func withLogger(ctx context.Context) context.Context {
	return tfsdklog.NewSubsystem(ctx, tflogSubsystemName,
		tfsdklog.WithLevelFromEnv("TF_LOG_SDK_HELPER_RESOURCE"))
}

// ...

ctx = withLogger(ctx)

tflog.SubsystemDebug(ctx, tflogSubsystemName, "doing amazing things")

References

@bflad bflad added enhancement New feature or request subsystem/tests Issues and feature requests related to the testing framework. labels Dec 23, 2021
@bflad bflad added this to the v2.11.0 milestone Jan 12, 2022
@bflad bflad self-assigned this Feb 17, 2022
bflad added a commit that referenced this issue Feb 19, 2022
…entries

Reference: #838

This new subsystem logger is meant for instrumenting the acceptance testing framework. Most of the changes are to support passing the context to many of the functions and adding `DEBUG`/`TRACE` log entries for provider developer and SDK maintainer troubleshooting.

Verified `go test` logging behaviors via terraform-provider-corner:

- No logs by default
- `TF_LOG_SDK_HELPER_RESOURCE` environment variable control of new logger
- `TF_LOG` enabling new logger
- `TF_ACC_LOG_PATH` enabling new logger
bflad added a commit that referenced this issue Feb 22, 2022
…entries

Reference: #838

This new subsystem logger is meant for instrumenting the acceptance testing framework. Most of the changes are to support passing the context to many of the functions and adding `DEBUG`/`TRACE` log entries for provider developer and SDK maintainer troubleshooting.

Verified `go test` logging behaviors via terraform-provider-corner:

- No logs by default
- `TF_LOG_SDK_HELPER_RESOURCE` environment variable control of new logger
- `TF_LOG` enabling new logger
- `TF_ACC_LOG_PATH` enabling new logger
bflad added a commit that referenced this issue Feb 22, 2022
…entries (#891)

Reference: #838

This new subsystem logger is meant for instrumenting the acceptance testing framework. Most of the changes are to support passing the context to many of the functions and adding `DEBUG`/`TRACE` log entries for provider developer and SDK maintainer troubleshooting.

Verified `go test` logging behaviors via terraform-provider-corner:

- No logs by default
- `TF_LOG_SDK_HELPER_RESOURCE` environment variable control of new logger
- `TF_LOG` enabling new logger
- `TF_ACC_LOG_PATH` enabling new logger
@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request subsystem/tests Issues and feature requests related to the testing framework.
Projects
None yet
1 participant