-
Notifications
You must be signed in to change notification settings - Fork 233
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
Update go-plugin, and use hclog.Logger when serving a plugin #639
Conversation
The major fix here is go-plugin no longer overrides the default output for the log package, allowing us to set it globally for providers.
Go-plugin can transfer JSON structured hclog output to a client logger. Rather than requiring existing providers to udpate all logging calls, we inject a wrapper into the std log package output which translates the defacto log format into structured log output with the correct levels. This will allow terraform to correctly filter the output, rather than default to handling all logs as Debug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do it. Thanks @jbardin. I think we're going to want to follow up in the testing framework, but for the moment, we can ship this incremental improvement.
When testing, we don't want to override where log output gets sent--the test framework takes care of that itself. go-plugin has disabled its use of log.SetOutput for us, but #639 introduced a log.SetOutput in plugin.Serve. This adds a plugin.ServeOpt property to disable that log.SetOutput call so we can finally have tests where log lines don't randomly show up in test output.
When testing, we don't want to override where log output gets sent--the test framework takes care of that itself. go-plugin has disabled its use of log.SetOutput for us, but #639 introduced a log.SetOutput in plugin.Serve. This adds a plugin.ServeOpt property to disable that log.SetOutput call so we can finally have tests where log lines don't randomly show up in test output.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Update go-plugin, so that it no longer overrides the default output in the
log
package.Go-plugin can transfer JSON structured hclog output to a client logger. Rather than requiring existing providers to update all logging calls, we inject a wrapper into the std log package output which translates the defacto log format into structured log output with the correct levels. This will allow terraform to correctly filter the output, rather than default to handling all logs as Debug. This allows the logger to remove redundant tags and timestamps in the log output, and fixes multi-line log output where the first line may have a tag other than
[DEBUG]
, but the remainder of the lines will be converted to[DEBUG]
.This PR intends to only configure the logging when running as a plugin. The same logger could also be adapted for testing, but that is to be left for another PR.