Skip to content

Commit 9734c12

Browse files
authored
internal/logging: Add missing AdditionalLocationOffset for protocol logging (#179)
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/[email protected]/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/[email protected]/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 ```
1 parent 091c6fe commit 9734c12

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

.changelog/179.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```release-note:bug
2+
tfprotov5/tf5server: Ensured `@caller` in protocol logging entries accurately reflected calling code location
3+
```
4+
5+
```release-note:bug
6+
tfprotov6/tf6server: Ensured `@caller` in protocol logging entries accurately reflected calling code location
7+
```

internal/logging/context.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ func InitContext(ctx context.Context, sdkOpts tfsdklog.Options, providerOpts tfl
2323
tfsdklog.WithLevelFromEnv(EnvTfLogSdk),
2424
}, sdkOpts...)...)
2525
ctx = tfsdklog.NewSubsystem(ctx, SubsystemProto, append(tfsdklog.Options{
26+
// All calls are through the Protocol* helper functions
27+
tfsdklog.WithAdditionalLocationOffset(1),
2628
tfsdklog.WithLevelFromEnv(EnvTfLogSdkProto),
2729
}, sdkOpts...)...)
2830
ctx = tfsdklog.NewRootProviderLogger(ctx, providerOpts...)

0 commit comments

Comments
 (0)