hashicorp / go-plugin

Golang plugin system over RPC.
Mozilla Public License 2.0
5.25k stars 450 forks source link

Do not override the default log output in the server #160

Closed jbardin closed 3 years ago

jbardin commented 4 years ago

In order to transition large existing codebases to use end-to-end structured logging, we want to be able to make use of the hclog Logger.StandardWriter. The entails setting the default std library log output to a wrapped instance of an hclog.Logger while running the server.

The plugin.Server function however overrides the log output when initializing the server. This means the implementation currently needs to restore its logger again after the server has started (there is no callback, so this must be checked on the first method call). Failing to do so does not cause an error, however it does cause the log output to lose its structure.

Removing the call to log.SetOutput makes it easier to setup a std library logger for all implementations, at the minor expense of requiring all implementations to ensure they write to os.Stderr, which is almost always the default case.

Fixes #155