log: Add structured logging (#1171)

* basic implementation

* log: deprecate duplicate function, add tests and refine calls.

* linter: fixes

* linter: update struct

* linter and new type

* log tests: update to not lint issue

* linter: stop complaining please

* glorious: nits

* log: rm comment code

* glorious: nits

* glorious: nits

* glorious: nits

* glorious: nits missed

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
This commit is contained in:
Ryan O'Hara-Reid
2023-05-10 17:52:53 +10:00
committed by GitHub
parent 6e1cbfc31e
commit db8735ec99
44 changed files with 679 additions and 476 deletions

View File

@@ -21,7 +21,7 @@ func (a *Alphapoint) WebsocketClient() {
var httpResp *http.Response
endpoint, err := a.API.Endpoints.GetURL(exchange.WebsocketSpot)
if err != nil {
log.Error(log.WebsocketMgr, err)
log.Errorln(log.WebsocketMgr, err)
}
a.WebsocketConn, httpResp, err = dialer.Dial(endpoint, http.Header{})
httpResp.Body.Close() // not used, so safely free the body
@@ -38,14 +38,14 @@ func (a *Alphapoint) WebsocketClient() {
err = a.WebsocketConn.WriteMessage(websocket.TextMessage, []byte(`{"messageType": "logon"}`))
if err != nil {
log.Error(log.ExchangeSys, err)
log.Errorln(log.ExchangeSys, err)
return
}
for a.Enabled {
msgType, resp, err := a.WebsocketConn.ReadMessage()
if err != nil {
log.Error(log.ExchangeSys, err)
log.Errorln(log.ExchangeSys, err)
break
}
@@ -57,7 +57,7 @@ func (a *Alphapoint) WebsocketClient() {
msgType := MsgType{}
err := json.Unmarshal(resp, &msgType)
if err != nil {
log.Error(log.ExchangeSys, err)
log.Errorln(log.ExchangeSys, err)
continue
}
@@ -65,7 +65,7 @@ func (a *Alphapoint) WebsocketClient() {
ticker := WebsocketTicker{}
err = json.Unmarshal(resp, &ticker)
if err != nil {
log.Error(log.ExchangeSys, err)
log.Errorln(log.ExchangeSys, err)
continue
}
}