mirror of https://github.com/poanetwork/gecko.git
improve plugin logging
This commit is contained in:
parent
7591e93e08
commit
d40fbe8f75
1
go.mod
1
go.mod
|
@ -20,6 +20,7 @@ require (
|
|||
github.com/gorilla/mux v1.7.4
|
||||
github.com/gorilla/rpc v1.2.0
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd
|
||||
github.com/hashicorp/go-plugin v1.3.0
|
||||
github.com/hashicorp/golang-lru v0.5.4 // indirect
|
||||
github.com/huin/goupnp v1.0.0
|
||||
|
|
|
@ -5,13 +5,12 @@ package rpcchainvm
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/ava-labs/gecko/snow"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/go-plugin"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os/exec"
|
||||
|
||||
"github.com/hashicorp/go-plugin"
|
||||
|
||||
"github.com/ava-labs/gecko/snow"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -33,12 +32,18 @@ func (f *Factory) New(ctx *snow.Context) (interface{}, error) {
|
|||
},
|
||||
}
|
||||
if ctx != nil {
|
||||
// disable go-plugin logging (since it is not controlled by Gecko's own
|
||||
// logging facility)
|
||||
log.SetOutput(ioutil.Discard)
|
||||
log.SetOutput(ctx.Log)
|
||||
config.Stderr = ctx.Log
|
||||
config.SyncStdout = ctx.Log
|
||||
config.SyncStderr = ctx.Log
|
||||
config.Logger = hclog.New(&hclog.LoggerOptions{
|
||||
Output: ctx.Log,
|
||||
Level: hclog.Info,
|
||||
})
|
||||
} else {
|
||||
log.SetOutput(ioutil.Discard)
|
||||
config.Stderr = ioutil.Discard
|
||||
config.Logger = hclog.New(&hclog.LoggerOptions{
|
||||
Output: ioutil.Discard,
|
||||
})
|
||||
}
|
||||
client := plugin.NewClient(config)
|
||||
|
||||
|
|
Loading…
Reference in New Issue