Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Mar 8, 2022

Conversation

bflad
Copy link
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
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

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