From d72d57526c819127b7e5db6e4872bc7e6428f61c Mon Sep 17 00:00:00 2001 From: c9s Date: Thu, 30 Dec 2021 16:20:32 +0800 Subject: [PATCH] binance: add DEBUG_BINANCE_STREAM env var --- pkg/exchange/binance/stream.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/exchange/binance/stream.go b/pkg/exchange/binance/stream.go index 77a1d660f..20bba428e 100644 --- a/pkg/exchange/binance/stream.go +++ b/pkg/exchange/binance/stream.go @@ -2,7 +2,6 @@ package binance import ( "context" - "math/rand" "net" "net/http" "os" @@ -11,6 +10,7 @@ import ( "time" "github.com/pkg/errors" + "github.com/sirupsen/logrus" "github.com/c9s/bbgo/pkg/depth" "github.com/c9s/bbgo/pkg/util" @@ -55,11 +55,15 @@ const writeTimeout = 10 * time.Second const listenKeyKeepAliveInterval = 10 * time.Minute func init() { - debugBinanceDepth, _ = strconv.ParseBool(os.Getenv("DEBUG_BINANCE_DEPTH")) if debugBinanceDepth { log.Info("binance depth debugging is enabled") } + + debugBinanceStream, _ := strconv.ParseBool(os.Getenv("DEBUG_BINANCE_STREAM")) + if debugBinanceStream { + log.Level = logrus.DebugLevel + } } type StreamRequest struct { @@ -109,7 +113,7 @@ func NewStream(ex *Exchange, client *binance.Client, futuresClient *futures.Clie stream := &Stream{ StandardStream: types.StandardStream{ ReconnectC: make(chan struct{}, 1), - CloseC: make(chan struct{}), + CloseC: make(chan struct{}), }, Client: client, futuresClient: futuresClient, @@ -416,7 +420,7 @@ func (s *Stream) connect(ctx context.Context) error { } go s.read(s.connCtx, conn) - go s.ping(s.connCtx, conn, readTimeout / 3) + go s.ping(s.connCtx, conn, readTimeout/3) return nil }