Implement Logger (#228)

* Added new base logger

* updated example and test configs

* updated exchange helpers restful router & server

* logPath is now passed to the logger to remove dependency on common package

* updated everything besides exchanges to use new logger

* alphapoint to bitmex done

* updated bitmex bitstamp bittrex btcc and also performance changes to logger

* btcmarkets coinbase coinut exmo gateio wrappers updated

* gateio and gemini logger updated

* hitbtc huobi itbit & kraken updated

* All exchanges updatd

* return correct error for disabled websocket

* don't disconnect client on invalid json

* updated router internal logging

* log.Fatal to t.Error for tests

* Changed from fatal to error failure to set maxprocs

* output ANSI codes for everything but windows for now due to lack of windows support

* added error handling to logger and unit tests

* clear wording on print -> log.print

* added benchmark test

* cleaned up import sections

* Updated logger based on PR requests (added default config options on failure/setting errors)

* ah this should fix travici enc config issue

* Load entire config and clear out logging to hopefully fix travisci issue

* wording & test error handling

* fixed formatting issues based on feedback

* fixed formatting issues based on feedback

* changed CheckDir to use mkdirall instead of mkdir and other changes based on feedback
This commit is contained in:
Andrew
2019-01-08 21:56:22 +11:00
committed by Adrian Gallagher
parent bfbd496c3a
commit d01e7bad72
103 changed files with 1028 additions and 657 deletions

View File

@@ -3,16 +3,16 @@ package bittrex
import (
"errors"
"fmt"
"log"
"net/url"
"strconv"
"time"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/config"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (

View File

@@ -3,7 +3,6 @@ package bittrex
import (
"errors"
"fmt"
"log"
"sync"
"github.com/thrasher-/gocryptotrader/common"
@@ -11,6 +10,7 @@ import (
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the Bittrex go routine
@@ -25,13 +25,13 @@ func (b *Bittrex) Start(wg *sync.WaitGroup) {
// Run implements the Bittrex wrapper
func (b *Bittrex) Run() {
if b.Verbose {
log.Printf("%s polling delay: %ds.\n", b.GetName(), b.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", b.GetName(), len(b.EnabledPairs), b.EnabledPairs)
log.Debugf("%s polling delay: %ds.\n", b.GetName(), b.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", b.GetName(), len(b.EnabledPairs), b.EnabledPairs)
}
exchangeProducts, err := b.GetMarkets()
if err != nil {
log.Printf("%s Failed to get available symbols.\n", b.GetName())
log.Errorf("%s Failed to get available symbols.\n", b.GetName())
} else {
forceUpgrade := false
if !common.StringDataContains(b.EnabledPairs, "-") || !common.StringDataContains(b.AvailablePairs, "-") {
@@ -47,16 +47,16 @@ func (b *Bittrex) Run() {
if forceUpgrade {
enabledPairs := []string{"USDT-BTC"}
log.Println("WARNING: Available pairs for Bittrex reset due to config upgrade, please enable the ones you would like again")
log.Warn("Available pairs for Bittrex reset due to config upgrade, please enable the ones you would like again")
err = b.UpdateCurrencies(enabledPairs, true, true)
if err != nil {
log.Printf("%s Failed to get config.\n", b.GetName())
log.Errorf("%s Failed to get config.", b.GetName())
}
}
err = b.UpdateCurrencies(currencies, false, forceUpgrade)
if err != nil {
log.Printf("%s Failed to get config.\n", b.GetName())
log.Errorf("%s Failed to get config.", b.GetName())
}
}
}