Skip to content

Commit

Permalink
internal/logging: Add missing AdditionalLocationOffset for protocol l…
Browse files Browse the repository at this point in the history
…ogging (#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
```
  • Loading branch information
bflad authored Apr 12, 2022
1 parent 091c6fe commit 9734c12
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .changelog/179.txt
Original file line number Diff line number Diff line change
@@ -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
```
2 changes: 2 additions & 0 deletions internal/logging/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down

0 comments on commit 9734c12

Please sign in to comment.