summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/hashicorp/yamux
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/yamux')
-rw-r--r--vendor/github.com/hashicorp/yamux/go.mod1
-rw-r--r--vendor/github.com/hashicorp/yamux/mux.go13
-rw-r--r--vendor/github.com/hashicorp/yamux/session.go7
3 files changed, 19 insertions, 2 deletions
diff --git a/vendor/github.com/hashicorp/yamux/go.mod b/vendor/github.com/hashicorp/yamux/go.mod
new file mode 100644
index 000000000..672a0e581
--- /dev/null
+++ b/vendor/github.com/hashicorp/yamux/go.mod
@@ -0,0 +1 @@
+module github.com/hashicorp/yamux
diff --git a/vendor/github.com/hashicorp/yamux/mux.go b/vendor/github.com/hashicorp/yamux/mux.go
index 7abc7c744..18a078c8a 100644
--- a/vendor/github.com/hashicorp/yamux/mux.go
+++ b/vendor/github.com/hashicorp/yamux/mux.go
@@ -3,6 +3,7 @@ package yamux
import (
"fmt"
"io"
+ "log"
"os"
"time"
)
@@ -30,8 +31,13 @@ type Config struct {
// window size that we allow for a stream.
MaxStreamWindowSize uint32
- // LogOutput is used to control the log destination
+ // LogOutput is used to control the log destination. Either Logger or
+ // LogOutput can be set, not both.
LogOutput io.Writer
+
+ // Logger is used to pass in the logger to be used. Either Logger or
+ // LogOutput can be set, not both.
+ Logger *log.Logger
}
// DefaultConfig is used to return a default configuration
@@ -57,6 +63,11 @@ func VerifyConfig(config *Config) error {
if config.MaxStreamWindowSize < initialStreamWindow {
return fmt.Errorf("MaxStreamWindowSize must be larger than %d", initialStreamWindow)
}
+ if config.LogOutput != nil && config.Logger != nil {
+ return fmt.Errorf("both Logger and LogOutput may not be set, select one")
+ } else if config.LogOutput == nil && config.Logger == nil {
+ return fmt.Errorf("one of Logger or LogOutput must be set, select one")
+ }
return nil
}
diff --git a/vendor/github.com/hashicorp/yamux/session.go b/vendor/github.com/hashicorp/yamux/session.go
index 32ba02e02..a80ddec35 100644
--- a/vendor/github.com/hashicorp/yamux/session.go
+++ b/vendor/github.com/hashicorp/yamux/session.go
@@ -86,9 +86,14 @@ type sendReady struct {
// newSession is used to construct a new session
func newSession(config *Config, conn io.ReadWriteCloser, client bool) *Session {
+ logger := config.Logger
+ if logger == nil {
+ logger = log.New(config.LogOutput, "", log.LstdFlags)
+ }
+
s := &Session{
config: config,
- logger: log.New(config.LogOutput, "", log.LstdFlags),
+ logger: logger,
conn: conn,
bufRead: bufio.NewReader(conn),
pings: make(map[uint32]chan struct{}),