Skip to content

Commit 456fde3

Browse files
committed
Remove unused code from internal/logging
1 parent df4a905 commit 456fde3

File tree

5 files changed

+0
-223
lines changed

5 files changed

+0
-223
lines changed

internal/logging/context.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,6 @@ import (
1111
testing "github.com/mitchellh/go-testing-interface"
1212
)
1313

14-
// InitContext creates SDK logger contexts when the provider is running in
15-
// "production" (not under acceptance testing). The incoming context will
16-
// already have the root SDK logger and root provider logger setup from
17-
// terraform-plugin-go tf5server RPC handlers.
18-
func InitContext(ctx context.Context) context.Context {
19-
ctx = tfsdklog.NewSubsystem(ctx, SubsystemHelperSchema,
20-
// All calls are through the HelperSchema* helper functions
21-
tfsdklog.WithAdditionalLocationOffset(1),
22-
tfsdklog.WithLevelFromEnv(EnvTfLogSdkHelperSchema),
23-
// Propagate tf_req_id, tf_rpc, etc. fields
24-
tfsdklog.WithRootFields(),
25-
)
26-
27-
return ctx
28-
}
29-
3014
// InitTestContext registers the terraform-plugin-log/tfsdklog test sink,
3115
// configures the standard library log package, and creates SDK logger
3216
// contexts. The incoming context is expected to be devoid of logging setup.

internal/logging/context_test.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,6 @@ import (
1515
"github.com/hashicorp/terraform-plugin-testing/internal/logging"
1616
)
1717

18-
func TestInitContext(t *testing.T) {
19-
t.Parallel()
20-
21-
var output bytes.Buffer
22-
23-
ctx := tfsdklogtest.RootLogger(context.Background(), &output)
24-
25-
// Simulate root logger fields that would have been associated by
26-
// terraform-plugin-go prior to the InitContext() call.
27-
ctx = tfsdklog.SetField(ctx, "tf_rpc", "GetProviderSchema")
28-
ctx = tfsdklog.SetField(ctx, "tf_req_id", "123-testing-123")
29-
30-
ctx = logging.InitContext(ctx)
31-
32-
logging.HelperSchemaTrace(ctx, "test message")
33-
34-
entries, err := tfsdklogtest.MultilineJSONDecode(&output)
35-
36-
if err != nil {
37-
t.Fatalf("unable to read multiple line JSON: %s", err)
38-
}
39-
40-
expectedEntries := []map[string]interface{}{
41-
{
42-
"@level": "trace",
43-
"@message": "test message",
44-
"@module": "sdk.helper_schema",
45-
"tf_rpc": "GetProviderSchema",
46-
"tf_req_id": "123-testing-123",
47-
},
48-
}
49-
50-
if diff := cmp.Diff(entries, expectedEntries); diff != "" {
51-
t.Errorf("unexpected difference: %s", diff)
52-
}
53-
}
54-
5518
func TestTestNameContext(t *testing.T) {
5619
t.Parallel()
5720

internal/logging/environment_variables.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,4 @@ const (
2020
// unset.
2121
EnvTfLogSdkHelperResource = "TF_LOG_SDK_HELPER_RESOURCE"
2222

23-
// EnvTfLogSdkHelperSchema is an environment variable that sets the logging
24-
// level of SDK helper/schema loggers. Infers root SDK logging level, if
25-
// unset.
26-
EnvTfLogSdkHelperSchema = "TF_LOG_SDK_HELPER_SCHEMA"
2723
)

internal/logging/helper_schema.go

Lines changed: 0 additions & 35 deletions
This file was deleted.

internal/logging/helper_schema_test.go

Lines changed: 0 additions & 131 deletions
This file was deleted.

0 commit comments

Comments
 (0)