From 32a0d96adc16b6c904daf6a792b26066a996088e Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Tue, 12 Apr 2022 11:35:22 -0400 Subject: [PATCH 1/2] internal/logging: Add missing AdditionalLocationOffset for protocol logging Previously (note `@caller`): ``` 2022-04-12T11:11:25.684-0400 [TRACE] provider.terraform-provider-aws: Received request: @caller=/Users/bflad/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.8.0/internal/logging/protocol.go:21 @module=sdk.proto tf_rpc=GetProviderSchema tf_proto_version=5.2 tf_provider_addr=provider tf_req_id=0c818104-0f9d-2bb3-1fa5-998a35ecae3e timestamp=2022-04-12T11:11:25.684-0400 2022-04-12T11:11:25.684-0400 [TRACE] provider.terraform-provider-aws: Calling downstream: tf_rpc=GetProviderSchema @caller=/Users/bflad/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.8.0/internal/logging/protocol.go:21 @module=sdk.proto tf_provider_addr=provider tf_req_id=0c818104-0f9d-2bb3-1fa5-998a35ecae3e tf_proto_version=5.2 timestamp=2022-04-12T11:11:25.684-0400 ``` Now: ``` 2022-04-12T11:32:32.867-0400 [TRACE] provider.terraform-provider-aws: Received request: @module=sdk.proto tf_req_id=89b3ee71-db56-42cb-75ce-3cfd6cd50589 tf_rpc=GetProviderSchema @caller=/Users/bflad/src/github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server/server.go:490 tf_proto_version=5.2 tf_provider_addr=provider timestamp=2022-04-12T11:32:32.867-0400 2022-04-12T11:32:32.867-0400 [TRACE] provider.terraform-provider-aws: Calling downstream: @caller=/Users/bflad/src/github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server/server.go:497 tf_proto_version=5.2 tf_req_id=89b3ee71-db56-42cb-75ce-3cfd6cd50589 tf_rpc=GetProviderSchema @module=sdk.proto tf_provider_addr=provider timestamp=2022-04-12T11:32:32.867-0400 ``` --- .changelog/pending.txt | 7 +++++++ internal/logging/context.go | 2 ++ 2 files changed, 9 insertions(+) create mode 100644 .changelog/pending.txt diff --git a/.changelog/pending.txt b/.changelog/pending.txt new file mode 100644 index 00000000..1096af63 --- /dev/null +++ b/.changelog/pending.txt @@ -0,0 +1,7 @@ +```release-note:bug +tfprotov5/tf5server: Ensured `@caller` in protocol logging entries accurately reflected calling code location +``` + +```release-note:bug +tfprotov6/tf6server: Ensured `@caller` in protocol logging entries accurately reflected calling code location +``` diff --git a/internal/logging/context.go b/internal/logging/context.go index 3407b4a6..a35258a8 100644 --- a/internal/logging/context.go +++ b/internal/logging/context.go @@ -23,6 +23,8 @@ func InitContext(ctx context.Context, sdkOpts tfsdklog.Options, providerOpts tfl tfsdklog.WithLevelFromEnv(EnvTfLogSdk), }, sdkOpts...)...) ctx = tfsdklog.NewSubsystem(ctx, SubsystemProto, append(tfsdklog.Options{ + // All calls are through the Protocol* helper functions + tfsdklog.WithAdditionalLocationOffset(1), tfsdklog.WithLevelFromEnv(EnvTfLogSdkProto), }, sdkOpts...)...) ctx = tfsdklog.NewRootProviderLogger(ctx, providerOpts...) From 232a89467f27a3b2146cb50aecfaee91adc39d2f Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Tue, 12 Apr 2022 11:37:35 -0400 Subject: [PATCH 2/2] Update CHANGELOG for #179 --- .changelog/{pending.txt => 179.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .changelog/{pending.txt => 179.txt} (100%) diff --git a/.changelog/pending.txt b/.changelog/179.txt similarity index 100% rename from .changelog/pending.txt rename to .changelog/179.txt