From 714df97a028f463d44359b83d6ac2ca0c6f8b27e Mon Sep 17 00:00:00 2001 From: James Bardin Date: Tue, 15 Aug 2017 14:15:00 -0400 Subject: [PATCH] specify a logger for go-plugin The go-plugin package now uses hclog. The default Logger has a level set to Info, but all plugin output is relayed via Debug. Create a new named logger for plugins with the level set to Trace so that all output comes through. --- plugin/client.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugin/client.go b/plugin/client.go index 3a5cb7af0..7e2f4fecb 100644 --- a/plugin/client.go +++ b/plugin/client.go @@ -1,8 +1,10 @@ package plugin import ( + "os" "os/exec" + hclog "github.com/hashicorp/go-hclog" plugin "github.com/hashicorp/go-plugin" "github.com/hashicorp/terraform/plugin/discovery" ) @@ -10,11 +12,18 @@ import ( // ClientConfig returns a configuration object that can be used to instantiate // a client for the plugin described by the given metadata. func ClientConfig(m discovery.PluginMeta) *plugin.ClientConfig { + logger := hclog.New(&hclog.LoggerOptions{ + Name: "plugin", + Level: hclog.Trace, + Output: os.Stderr, + }) + return &plugin.ClientConfig{ Cmd: exec.Command(m.Path), HandshakeConfig: Handshake, Managed: true, Plugins: PluginMap, + Logger: logger, } }