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

helper/resource: Added terraform-plugin-log logger and extensive log entries #891

Merged
merged 2 commits into from
Feb 22, 2022

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Feb 19, 2022

Closes #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 bflad added the enhancement New feature or request label Feb 19, 2022
@bflad bflad added this to the v2.11.0 milestone Feb 19, 2022
@bflad bflad requested a review from a team as a code owner February 19, 2022 02:49
Copy link
Contributor

@detro detro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A tiny nitpick, but otherwise LGTM.

Comment on lines 14 to 32
// HelperResourceDebug emits a helper/resource subsystem log at DEBUG level.
func HelperResourceDebug(ctx context.Context, msg string, args ...interface{}) {
tfsdklog.SubsystemDebug(ctx, SubsystemHelperResource, msg, args)
}

// HelperResourceError emits a helper/resource subsystem log at ERROR level.
func HelperResourceError(ctx context.Context, msg string, args ...interface{}) {
tfsdklog.SubsystemError(ctx, SubsystemHelperResource, msg, args)
}

// HelperResourceTrace emits a helper/resource subsystem log at TRACE level.
func HelperResourceTrace(ctx context.Context, msg string, args ...interface{}) {
tfsdklog.SubsystemTrace(ctx, SubsystemHelperResource, msg, args)
}

// HelperResourceWarn emits a helper/resource subsystem log at WARN level.
func HelperResourceWarn(ctx context.Context, msg string, args ...interface{}) {
tfsdklog.SubsystemWarn(ctx, SubsystemHelperResource, msg, args)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: would prefer if those functions where either sorted "trace, debug, warn, error" or "error, warn, debug, trace".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically I'll code function/method definitions alphabetically, but pushed up the ordering change.

bflad added a commit that referenced this pull request Feb 21, 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 bflad force-pushed the bflad-helper-resource-logging branch from 6ade90a to 55ec1bb Compare February 22, 2022 12:59
@bflad bflad merged commit 45133e6 into main Feb 22, 2022
@bflad bflad deleted the bflad-helper-resource-logging branch February 22, 2022 13:06
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce tfsdklog helper_resource Subsystem
2 participants