binance: add DEBUG_BINANCE_STREAM env var

This commit is contained in:
c9s 2021-12-30 16:20:32 +08:00
parent a2931da92c
commit d72d57526c

View File

@ -2,7 +2,6 @@ package binance
import ( import (
"context" "context"
"math/rand"
"net" "net"
"net/http" "net/http"
"os" "os"
@ -11,6 +10,7 @@ import (
"time" "time"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/c9s/bbgo/pkg/depth" "github.com/c9s/bbgo/pkg/depth"
"github.com/c9s/bbgo/pkg/util" "github.com/c9s/bbgo/pkg/util"
@ -55,11 +55,15 @@ const writeTimeout = 10 * time.Second
const listenKeyKeepAliveInterval = 10 * time.Minute const listenKeyKeepAliveInterval = 10 * time.Minute
func init() { func init() {
debugBinanceDepth, _ = strconv.ParseBool(os.Getenv("DEBUG_BINANCE_DEPTH")) debugBinanceDepth, _ = strconv.ParseBool(os.Getenv("DEBUG_BINANCE_DEPTH"))
if debugBinanceDepth { if debugBinanceDepth {
log.Info("binance depth debugging is enabled") log.Info("binance depth debugging is enabled")
} }
debugBinanceStream, _ := strconv.ParseBool(os.Getenv("DEBUG_BINANCE_STREAM"))
if debugBinanceStream {
log.Level = logrus.DebugLevel
}
} }
type StreamRequest struct { type StreamRequest struct {
@ -416,7 +420,7 @@ func (s *Stream) connect(ctx context.Context) error {
} }
go s.read(s.connCtx, conn) go s.read(s.connCtx, conn)
go s.ping(s.connCtx, conn, readTimeout / 3) go s.ping(s.connCtx, conn, readTimeout/3)
return nil return nil
} }