mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-23 23:16:49 +00:00
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:
@@ -2,7 +2,6 @@ package kraken
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -10,9 +9,10 @@ import (
|
||||
|
||||
"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 (
|
||||
@@ -892,7 +892,7 @@ func GetError(errors []string) error {
|
||||
for _, e := range errors {
|
||||
switch e[0] {
|
||||
case 'W':
|
||||
log.Printf("Kraken API warning: %v\n", e[1:])
|
||||
log.Warnf("Kraken API warning: %v\n", e[1:])
|
||||
default:
|
||||
return fmt.Errorf("Kraken API error: %v", e[1:])
|
||||
}
|
||||
@@ -931,7 +931,7 @@ func (k *Kraken) SendAuthenticatedHTTPRequest(method string, params url.Values,
|
||||
signature := common.Base64Encode(common.GetHMAC(common.HashSHA512, append([]byte(path), shasum...), secret))
|
||||
|
||||
if k.Verbose {
|
||||
log.Printf("Sending POST request to %s, path: %s, params: %s", k.APIUrl, path, encoded)
|
||||
log.Debugf("Sending POST request to %s, path: %s, params: %s", k.APIUrl, path, encoded)
|
||||
}
|
||||
|
||||
headers := make(map[string]string)
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package kraken
|
||||
|
||||
import (
|
||||
"log"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/thrasher-/gocryptotrader/common"
|
||||
"github.com/thrasher-/gocryptotrader/currency/pair"
|
||||
"github.com/thrasher-/gocryptotrader/exchanges"
|
||||
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 Kraken go routine
|
||||
@@ -24,13 +24,13 @@ func (k *Kraken) Start(wg *sync.WaitGroup) {
|
||||
// Run implements the Kraken wrapper
|
||||
func (k *Kraken) Run() {
|
||||
if k.Verbose {
|
||||
log.Printf("%s polling delay: %ds.\n", k.GetName(), k.RESTPollingDelay)
|
||||
log.Printf("%s %d currencies enabled: %s.\n", k.GetName(), len(k.EnabledPairs), k.EnabledPairs)
|
||||
log.Debugf("%s polling delay: %ds.\n", k.GetName(), k.RESTPollingDelay)
|
||||
log.Debugf("%s %d currencies enabled: %s.\n", k.GetName(), len(k.EnabledPairs), k.EnabledPairs)
|
||||
}
|
||||
|
||||
assetPairs, err := k.GetAssetPairs()
|
||||
if err != nil {
|
||||
log.Printf("%s Failed to get available symbols.\n", k.GetName())
|
||||
log.Errorf("%s Failed to get available symbols.\n", k.GetName())
|
||||
} else {
|
||||
forceUpgrade := false
|
||||
if !common.StringDataContains(k.EnabledPairs, "-") || !common.StringDataContains(k.AvailablePairs, "-") {
|
||||
@@ -55,16 +55,16 @@ func (k *Kraken) Run() {
|
||||
|
||||
if forceUpgrade {
|
||||
enabledPairs := []string{"XBT-USD"}
|
||||
log.Println("WARNING: Available pairs for Kraken reset due to config upgrade, please enable the ones you would like again")
|
||||
log.Warn("Available pairs for Kraken reset due to config upgrade, please enable the ones you would like again")
|
||||
|
||||
err = k.UpdateCurrencies(enabledPairs, true, true)
|
||||
if err != nil {
|
||||
log.Printf("%s Failed to get config.\n", k.GetName())
|
||||
log.Errorf("%s Failed to get config.\n", k.GetName())
|
||||
}
|
||||
}
|
||||
err = k.UpdateCurrencies(exchangeProducts, false, forceUpgrade)
|
||||
if err != nil {
|
||||
log.Printf("%s Failed to get config.\n", k.GetName())
|
||||
log.Errorf("%s Failed to get config.\n", k.GetName())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user