Skip to content

tfsdklog: Consolidated multiple invalid log level messages and added missing newline#35

Merged
bflad merged 2 commits intomainfrom
bflad-invalid-log-level-once
Mar 8, 2022
Merged

tfsdklog: Consolidated multiple invalid log level messages and added missing newline#35
bflad merged 2 commits intomainfrom
bflad-invalid-log-level-once

Conversation

@bflad
Copy link
Copy Markdown
Contributor

@bflad bflad commented Mar 4, 2022

Closes #32

This is related to SDK (or special implementations of testing framework) code which needs to execute tfsdklog.RegisterTestSink(), generally via the tf5server.WithLoggingSink()/tf6server.WithLoggingSink() functions.

Previously in terraform-provider-kubernetes:

$ TF_LOG=trac go test -v -tags acceptance -run '^TestKubernetesManifest_ConfigMap$' ./manifest/test/acceptance
2022/03/04 16:51:21 Testing against Kubernetes API version: v1.22.3
=== RUN   TestKubernetesManifest_ConfigMap
[WARN] Invalid log level: "TRAC". Defaulting to level: OFF. Valid levels are: [TRACE DEBUG INFO WARN ERROR OFF][WARN] Invalid log level: "TRAC". Defaulting to level: OFF. Valid levels are: [TRACE DEBUG INFO WARN ERROR OFF][WARN] Invalid log level: "TRAC". Defaulting to level: OFF. Valid levels are: [TRACE DEBUG INFO WARN ERROR OFF][WARN] Invalid log level: "TRAC". Defaulting to level: OFF. Valid levels are: [TRACE DEBUG INFO WARN ERROR OFF][WARN] Invalid log level: "TRAC". Defaulting to level: OFF. Valid levels are: [TRACE DEBUG INFO WARN ERROR OFF][WARN] Invalid log level: "TRAC". Defaulting to level: OFF. Valid levels are: [TRACE DEBUG INFO WARN ERROR OFF]...

After updating dependency:

$ go mod edit -replace=github.com/hashicorp/terraform-plugin-log=/Users/bflad/src/github.com/hashicorp/terraform-plugin-log
$ go mod tidy
$ go mod vendor
$ TF_LOG=trac go test -v -tags acceptance -run '^TestKubernetesManifest_ConfigMap$' ./manifest/test/acceptance
2022/03/04 16:52:49 Testing against Kubernetes API version: v1.22.3
=== RUN   TestKubernetesManifest_ConfigMap
[WARN] Invalid log level: "TRAC". Defaulting to level: OFF. Valid levels are: [TRACE DEBUG INFO WARN ERROR OFF]
... other test output ...

…missing newline

Reference: #32

This is related to SDK (or special implementations of testing framework) code which needs to execute `tfsdklog.RegisterTestSink()`, generally via the `tf5server.WithLoggingSink()`/`tf6server.WithLoggingSink()` functions.

Previously in terraform-provider-kubernetes:

```console
$ TF_LOG=trac go test -v -tags acceptance -run '^TestKubernetesManifest_ConfigMap$' ./manifest/test/acceptance
2022/03/04 16:51:21 Testing against Kubernetes API version: v1.22.3
=== RUN   TestKubernetesManifest_ConfigMap
[WARN] Invalid log level: "TRAC". Defaulting to level: OFF. Valid levels are: [TRACE DEBUG INFO WARN ERROR OFF][WARN] Invalid log level: "TRAC". Defaulting to level: OFF. Valid levels are: [TRACE DEBUG INFO WARN ERROR OFF][WARN] Invalid log level: "TRAC". Defaulting to level: OFF. Valid levels are: [TRACE DEBUG INFO WARN ERROR OFF][WARN] Invalid log level: "TRAC". Defaulting to level: OFF. Valid levels are: [TRACE DEBUG INFO WARN ERROR OFF][WARN] Invalid log level: "TRAC". Defaulting to level: OFF. Valid levels are: [TRACE DEBUG INFO WARN ERROR OFF][WARN] Invalid log level: "TRAC". Defaulting to level: OFF. Valid levels are: [TRACE DEBUG INFO WARN ERROR OFF]...
```

After updating dependency:

```console
$ go mod edit -replace=github.com/hashicorp/terraform-plugin-log=/Users/bflad/src/github.com/hashicorp/terraform-plugin-log
$ go mod tidy
$ go mod vendor
$ TF_LOG=trac go test -v -tags acceptance -run '^TestKubernetesManifest_ConfigMap$' ./manifest/test/acceptance
2022/03/04 16:52:49 Testing against Kubernetes API version: v1.22.3
=== RUN   TestKubernetesManifest_ConfigMap
[WARN] Invalid log level: "TRAC". Defaulting to level: OFF. Valid levels are: [TRACE DEBUG INFO WARN ERROR OFF]
... other test output ...
```
@bflad bflad added the bug Something isn't working label Mar 4, 2022
@bflad bflad added this to the v0.3.0 milestone Mar 4, 2022
@bflad bflad requested a review from a team as a code owner March 4, 2022 21:55
Copy link
Copy Markdown
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.

LGTM

And I find the use of sync.Once fancy :)

@bflad bflad merged commit cca4f05 into main Mar 8, 2022
@bflad bflad deleted the bflad-invalid-log-level-once branch March 8, 2022 13:42
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2022

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 Apr 8, 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.

tfsdklog.RegisterTestSink() Will Output Invalid Log Level Error Many Times

2 participants