mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
improve logging
This commit is contained in:
parent
366036a35b
commit
d68564de28
|
@ -85,6 +85,7 @@ func (environ *Environment) Connect(ctx context.Context) error {
|
||||||
for n := range environ.sessions {
|
for n := range environ.sessions {
|
||||||
// avoid using the placeholder variable for the session because we use that in the callbacks
|
// avoid using the placeholder variable for the session because we use that in the callbacks
|
||||||
var session = environ.sessions[n]
|
var session = environ.sessions[n]
|
||||||
|
var log = log.WithField("session", n)
|
||||||
|
|
||||||
loadedSymbols := make(map[string]struct{})
|
loadedSymbols := make(map[string]struct{})
|
||||||
for _, s := range session.Subscriptions {
|
for _, s := range session.Subscriptions {
|
||||||
|
@ -131,8 +132,6 @@ func (environ *Environment) Connect(ctx context.Context) error {
|
||||||
session.marketDataStores[symbol] = marketDataStore
|
session.marketDataStores[symbol] = marketDataStore
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("loaded symbol: %+v", loadedSymbols)
|
|
||||||
|
|
||||||
log.Infof("querying balances...")
|
log.Infof("querying balances...")
|
||||||
balances, err := session.Exchange.QueryAccountBalances(ctx)
|
balances, err := session.Exchange.QueryAccountBalances(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -158,6 +157,11 @@ func (environ *Environment) Connect(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if len(session.Subscriptions) == 0 {
|
||||||
|
log.Warnf("no subscriptions, exchange session %s will not be connected", session.Name)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
log.Infof("connecting session %s...", session.Name)
|
log.Infof("connecting session %s...", session.Name)
|
||||||
if err := session.Stream.Connect(ctx); err != nil {
|
if err := session.Stream.Connect(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue
Block a user