diff --git a/consul/client.go b/consul/client.go index 2aa3d04795..02aa4f658d 100644 --- a/consul/client.go +++ b/consul/client.go @@ -99,7 +99,7 @@ func NewClient(config *Config) (*Client, error) { // Create server c := &Client{ config: config, - connPool: NewPool(clientRPCCache, clientMaxStreams, tlsConfig), + connPool: NewPool(config.LogOutput, clientRPCCache, clientMaxStreams, tlsConfig), eventCh: make(chan serf.Event, 256), logger: logger, shutdownCh: make(chan struct{}), diff --git a/consul/pool.go b/consul/pool.go index 7c673e180e..7fc93950d2 100644 --- a/consul/pool.go +++ b/consul/pool.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/yamux" "github.com/inconshreveable/muxado" "github.com/ugorji/go/codec" + "io" "net" "net/rpc" "sync" @@ -110,6 +111,9 @@ func (c *Conn) returnClient(client *StreamClient) { type ConnPool struct { sync.Mutex + // LogOutput is used to control logging + logOutput io.Writer + // The maximum time to keep a connection open maxTime time.Duration @@ -132,8 +136,9 @@ type ConnPool struct { // Set maxTime to 0 to disable reaping. maxStreams is used to control // the number of idle streams allowed. // If TLS settings are provided outgoing connections use TLS. -func NewPool(maxTime time.Duration, maxStreams int, tlsConfig *tls.Config) *ConnPool { +func NewPool(logOutput io.Writer, maxTime time.Duration, maxStreams int, tlsConfig *tls.Config) *ConnPool { pool := &ConnPool{ + logOutput: logOutput, maxTime: maxTime, maxStreams: maxStreams, pool: make(map[string]*Conn), @@ -235,8 +240,12 @@ func (p *ConnPool) getNewConn(addr net.Addr, version int) (*Conn, error) { return nil, err } + // Setup the logger + conf := yamux.DefaultConfig() + conf.LogOutput = nil + // Create a multiplexed session - session, _ = yamux.Client(conn, nil) + session, _ = yamux.Client(conn, conf) } // Wrap the connection diff --git a/consul/rpc.go b/consul/rpc.go index d87109a181..20ffb3c6d5 100644 --- a/consul/rpc.go +++ b/consul/rpc.go @@ -130,7 +130,9 @@ func (s *Server) handleMultiplex(conn net.Conn) { // using the Yamux multiplexer func (s *Server) handleMultiplexV2(conn net.Conn) { defer conn.Close() - server, _ := yamux.Server(conn, nil) + conf := yamux.DefaultConfig() + conf.LogOutput = s.config.LogOutput + server, _ := yamux.Server(conn, conf) for { sub, err := server.Accept() if err != nil { diff --git a/consul/server.go b/consul/server.go index 6616843628..d8d94a5c4c 100644 --- a/consul/server.go +++ b/consul/server.go @@ -163,7 +163,7 @@ func NewServer(config *Config) (*Server, error) { // Create server s := &Server{ config: config, - connPool: NewPool(serverRPCCache, serverMaxStreams, tlsConfig), + connPool: NewPool(config.LogOutput, serverRPCCache, serverMaxStreams, tlsConfig), eventChLAN: make(chan serf.Event, 256), eventChWAN: make(chan serf.Event, 256), localConsuls: make(map[string]*serverParts),