update go-plugin
This commit is contained in:
parent
bb00fd47c0
commit
181c5e01f6
|
@ -21,8 +21,6 @@ import (
|
|||
"time"
|
||||
"unicode"
|
||||
|
||||
"encoding/json"
|
||||
|
||||
hclog "github.com/hashicorp/go-hclog"
|
||||
)
|
||||
|
||||
|
@ -271,8 +269,11 @@ func NewClient(config *ClientConfig) (c *Client) {
|
|||
}
|
||||
|
||||
if config.Logger == nil {
|
||||
config.Logger = hclog.Default()
|
||||
config.Logger = config.Logger.ResetNamed("plugin")
|
||||
config.Logger = hclog.New(&hclog.LoggerOptions{
|
||||
Output: hclog.DefaultOutput,
|
||||
Level: hclog.Trace,
|
||||
Name: "plugin",
|
||||
})
|
||||
}
|
||||
|
||||
c = &Client{
|
||||
|
@ -737,16 +738,12 @@ func (c *Client) logStderr(r io.Reader) {
|
|||
line = strings.TrimRightFunc(line, unicode.IsSpace)
|
||||
|
||||
l := c.logger.Named(filepath.Base(c.config.Cmd.Path))
|
||||
// If output is not JSON format, print directly as error
|
||||
if !isJSON(line) {
|
||||
l.Debug("log from plugin", "entry", line)
|
||||
} else {
|
||||
// Parse JSON line received from the plugin into logEntry, and print via
|
||||
// the client's logger
|
||||
|
||||
entry, err := parseJSON(line)
|
||||
// If output is not JSON format, print directly to Debug
|
||||
if err != nil {
|
||||
l.Error("error parsing json from plugin", "error", err)
|
||||
}
|
||||
l.Debug(line)
|
||||
} else {
|
||||
out := flattenKVPairs(entry.KVPairs)
|
||||
|
||||
l = l.With("timestamp", entry.Timestamp.Format(hclog.TimeFormat))
|
||||
|
@ -773,8 +770,3 @@ func (c *Client) logStderr(r io.Reader) {
|
|||
// Flag that we've completed logging for others
|
||||
close(c.doneLogging)
|
||||
}
|
||||
|
||||
func isJSON(str string) bool {
|
||||
var js json.RawMessage
|
||||
return json.Unmarshal([]byte(str), &js) == nil
|
||||
}
|
||||
|
|
|
@ -1259,10 +1259,10 @@
|
|||
"revision": "d30f09973e19c1dfcd120b2d9c4f168e68d6b5d5"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "PjvQA7yNIn9/8ns0i6Sd8TvTwhY=",
|
||||
"checksumSHA1": "R6me0jVmcT/OPo80Fe0qo5fRwHc=",
|
||||
"path": "github.com/hashicorp/go-plugin",
|
||||
"revision": "871e7582ebde6a93f3e03d8c6fa0d2eb2eb98d02",
|
||||
"revisionTime": "2017-08-07T16:10:15Z"
|
||||
"revision": "a5174f84d7f8ff00fb07ab4ef1f380d32eee0e63",
|
||||
"revisionTime": "2017-08-16T15:18:19Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "ErJHGU6AVPZM9yoY/xV11TwSjQs=",
|
||||
|
|
Loading…
Reference in New Issue