mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-18 15:10:03 +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:
@@ -4,13 +4,12 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/thrasher-/gocryptotrader/common"
|
||||
"github.com/thrasher-/gocryptotrader/exchanges"
|
||||
exchange "github.com/thrasher-/gocryptotrader/exchanges"
|
||||
"github.com/thrasher-/gocryptotrader/exchanges/request"
|
||||
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
|
||||
)
|
||||
@@ -191,7 +190,7 @@ func (a *Alphapoint) CreateAccount(firstName, lastName, email, phone, password s
|
||||
|
||||
err := a.SendAuthenticatedHTTPRequest("POST", alphapointCreateAccount, request, &response)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return fmt.Errorf("Alphapoint Error - CreateAccount HTTPRequest - reason: %s", err)
|
||||
}
|
||||
if !response.IsAccepted {
|
||||
return errors.New(response.RejectReason)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package alphapoint
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/thrasher-/gocryptotrader/common"
|
||||
log "github.com/thrasher-/gocryptotrader/logger"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -20,25 +20,25 @@ func (a *Alphapoint) WebsocketClient() {
|
||||
a.WebsocketConn, _, err = Dialer.Dial(a.WebsocketURL, http.Header{})
|
||||
|
||||
if err != nil {
|
||||
log.Printf("%s Unable to connect to Websocket. Error: %s\n", a.Name, err)
|
||||
log.Errorf("%s Unable to connect to Websocket. Error: %s\n", a.Name, err)
|
||||
continue
|
||||
}
|
||||
|
||||
if a.Verbose {
|
||||
log.Printf("%s Connected to Websocket.\n", a.Name)
|
||||
log.Debugf("%s Connected to Websocket.\n", a.Name)
|
||||
}
|
||||
|
||||
err = a.WebsocketConn.WriteMessage(websocket.TextMessage, []byte(`{"messageType": "logon"}`))
|
||||
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
for a.Enabled {
|
||||
msgType, resp, err := a.WebsocketConn.ReadMessage()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
log.Error(err)
|
||||
break
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ func (a *Alphapoint) WebsocketClient() {
|
||||
msgType := MsgType{}
|
||||
err := common.JSONDecode(resp, &msgType)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
log.Error(err)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -60,13 +60,13 @@ func (a *Alphapoint) WebsocketClient() {
|
||||
ticker := WebsocketTicker{}
|
||||
err = common.JSONDecode(resp, &ticker)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
log.Error(err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
a.WebsocketConn.Close()
|
||||
log.Printf("%s Websocket client disconnected.", a.Name)
|
||||
log.Debugf("%s Websocket client disconnected.", a.Name)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user