Skip to content

Commit

Permalink
specify a logger for go-plugin
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jbardin committed Aug 15, 2017
1 parent 81f9c78 commit 714df97
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions plugin/client.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
package plugin

import (
"os"
"os/exec"

hclog "github.com/hashicorp/go-hclog"
plugin "github.com/hashicorp/go-plugin"
"github.com/hashicorp/terraform/plugin/discovery"
)

// 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,
}
}

Expand Down

0 comments on commit 714df97

Please sign in to comment.