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

internal/logging: Ensure @caller in SDK subsystem logging entries accurately reflects calling code location #939

Merged
merged 4 commits into from Apr 14, 2022

Conversation

bflad
Copy link
Member

@bflad bflad commented Apr 12, 2022

Reference: hashicorp/terraform-plugin-go#179

Previously:

2022-04-12T11:11:26.086-0400 [TRACE] provider.terraform-provider-aws: Found data source type: @caller=/Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/internal/logging/helper_schema.go:21 @module=sdk.helper_schema tf_data_source_type=aws_connect_bot_association timestamp=2022-04-12T11:11:25.917-0400
2022-04-12T11:11:26.086-0400 [TRACE] provider.terraform-provider-aws: Found data source type: @caller=/Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/internal/logging/helper_schema.go:21 @module=sdk.helper_schema tf_data_source_type=aws_datapipeline_pipeline timestamp=2022-04-12T11:11:25.917-0400

Now:

2022-04-12T14:54:22.571-0400 [TRACE] provider.terraform-provider-aws: Found data source type: @module=sdk.helper_schema tf_data_source_type=aws_connect_bot_association @caller=/Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/helper/schema/grpc_provider.go:95 timestamp=2022-04-12T14:54:22.571-0400
2022-04-12T14:54:22.574-0400 [TRACE] provider.terraform-provider-aws: Found data source type: @module=sdk.helper_schema tf_data_source_type=aws_datapipeline_pipeline @caller=/Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/helper/schema/grpc_provider.go:95 timestamp=2022-04-12T14:54:22.574-0400

…ccurately reflects calling code location

Reference: hashicorp/terraform-plugin-go#179

Previously:

```
2022-04-12T11:11:26.086-0400 [TRACE] provider.terraform-provider-aws: Found data source type: @caller=/Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/internal/logging/helper_schema.go:21 @module=sdk.helper_schema tf_data_source_type=aws_connect_bot_association timestamp=2022-04-12T11:11:25.917-0400
2022-04-12T11:11:26.086-0400 [TRACE] provider.terraform-provider-aws: Found data source type: @caller=/Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/internal/logging/helper_schema.go:21 @module=sdk.helper_schema tf_data_source_type=aws_datapipeline_pipeline timestamp=2022-04-12T11:11:25.917-0400
```

Now:

```
2022-04-12T14:54:22.571-0400 [TRACE] provider.terraform-provider-aws: Found data source type: @module=sdk.helper_schema tf_data_source_type=aws_connect_bot_association @caller=/Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/helper/schema/grpc_provider.go:95 timestamp=2022-04-12T14:54:22.571-0400
2022-04-12T14:54:22.574-0400 [TRACE] provider.terraform-provider-aws: Found data source type: @module=sdk.helper_schema tf_data_source_type=aws_datapipeline_pipeline @caller=/Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/helper/schema/grpc_provider.go:95 timestamp=2022-04-12T14:54:22.574-0400
```
@bflad bflad added the bug Something isn't working label Apr 12, 2022
@bflad bflad added this to the v2.14.0 milestone Apr 12, 2022
@bflad bflad requested a review from a team as a code owner April 12, 2022 18:56
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.

Just a question about using the variadic input, but nothing to stop the PR for.

internal/logging/context.go Outdated Show resolved Hide resolved
@@ -30,7 +34,11 @@ func InitTestContext(ctx context.Context, t testing.T) context.Context {

ctx = tfsdklog.RegisterTestSink(ctx, t)
ctx = tfsdklog.NewRootSDKLogger(ctx, tfsdklog.WithLevelFromEnv(EnvTfLogSdk))
ctx = tfsdklog.NewSubsystem(ctx, SubsystemHelperResource, tfsdklog.WithLevelFromEnv(EnvTfLogSdkHelperResource))
ctx = tfsdklog.NewSubsystem(ctx, SubsystemHelperResource, tfsdklog.Options{
Copy link
Contributor

Choose a reason for hiding this comment

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

As above

internal/logging/context.go Outdated Show resolved Hide resolved
Co-authored-by: Ivan De Marino <ivan.demarino@hashicorp.com>
internal/logging/context.go Outdated Show resolved Hide resolved
@bflad bflad merged commit ea02348 into main Apr 14, 2022
@bflad bflad deleted the bflad-subsystem-log-callers branch April 14, 2022 17:04
@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 May 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants