-
Notifications
You must be signed in to change notification settings - Fork 10
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
Fallback to Generic Logger Output #52
Comments
Another way provider developers can get into this situation is if they are using a |
Same here tflog is not printing output to console for me. Just starting with Go and tf provider development so everything is still confusing to me... I tried: But I guess this is not working because I am using TODO context? What should I use instead? |
Ok, i resolved it by passing the context from parents to children and using that instead of "dummy" context |
terraform-plugin-log version
Use cases
For much of the terraform-plugin-log logging logic, it will fallback to dropping messages when the
context.Context
is not appropriately setup, e.g.terraform-plugin-log/tflog/provider.go
Lines 31 to 38 in 94541a8
In production, is quite trivial for provider developers to get into situations where the
context.Context
is not setup properly. For example, using the non-context-aware fields ofgithub.aaakk.us.kg/hashicorp/terraform-plugin-sdk/helper/schema.Resource
or using any SDK, errantly using a separatecontext.Context
that was not setup (e.g. viacontext.Background()
orcontext.TODO()
).Another use case is SDK-based unit testing, where it takes some effort to setup the logging contexts or its easy to miss in each and every test.
Not having any log output with no indication of an issue is more confusing than expecting everyone downstream to figure out the issue on their own.
Proposal
If a logging message is to be written, but the appropriate logging context is not available, fallback to a last resort
github.com/hashicorp/hc-log.Logger
and write to it instead. On first usage of the last resortLogger
, it should also output a warning message about the missing context-basedLogger
, so provider or SDK developers can understand any differences in logging behavior.References
The text was updated successfully, but these errors were encountered: