New logging system (#319)

* First pass at adding new logging system

* NewLogger

* NewLogger

* WIP

* silly bug fix

* :D removed files

* removed old logging interface

* added tests

* added tests

* Started to add new lines to all f calls

* Added subsystem log types

* Logger improvements

* Further performance improvements

* changes to logger and sublogger creation

* Renamed Logging types

* removed old print statement

* changes based on feedback

* moved sublogger types to own file

* :)

* added console as output type

* added get level command

* added get/set log level via grpc command

* added check for output being empty for migration support

* first pass at log rotation

* added log rotation

* :D derp fixed

* added tests

* changes based on feedback

* changed log type

* comments

* renamed file -> fileSettings

* typo fix

* changes based on feedback

* gofmt ran on additional files

* gofmt ran on additional files
This commit is contained in:
Andrew
2019-07-07 05:20:31 +10:00
committed by Adrian Gallagher
parent 7112a89491
commit 3de1d94e5f
137 changed files with 2920 additions and 1650 deletions

View File

@@ -101,7 +101,7 @@ func (b *Bitmex) WsConnector() error {
}
if b.Verbose {
log.Debugf("Successfully connected to Bitmex %s at time: %s Limit: %d",
log.Debugf(log.ExchangeSys, "Successfully connected to Bitmex %s at time: %s Limit: %d",
welcomeResp.Info,
welcomeResp.Timestamp,
welcomeResp.Limit.Remaining)
@@ -112,7 +112,7 @@ func (b *Bitmex) WsConnector() error {
err = b.websocketSendAuth()
if err != nil {
log.Errorf("%v - authentication failed: %v", b.Name, err)
log.Errorf(log.ExchangeSys, "%v - authentication failed: %v\n", b.Name, err)
}
b.GenerateAuthenticatedSubscriptions()
return nil
@@ -195,13 +195,13 @@ func (b *Bitmex) wsHandleIncomingData() {
b.Websocket.DataHandler <- decodedResp
if len(quickCapture) == 3 {
if b.Verbose {
log.Debugf("%s websocket: Successfully subscribed to %s",
log.Debugf(log.ExchangeSys, "%s websocket: Successfully subscribed to %s",
b.Name, decodedResp.Subscribe)
}
} else {
b.Websocket.SetCanUseAuthenticatedEndpoints(true)
if b.Verbose {
log.Debugf("%s websocket: Successfully authenticated websocket connection",
log.Debugf(log.ExchangeSys, "%s websocket: Successfully authenticated websocket connection",
b.Name)
}
}
@@ -561,7 +561,7 @@ func (b *Bitmex) wsSend(data interface{}) error {
b.wsRequestMtx.Lock()
defer b.wsRequestMtx.Unlock()
if b.Verbose {
log.Debugf("%v sending message to websocket %v", b.Name, data)
log.Debugf(log.ExchangeSys, "%v sending message to websocket %v", b.Name, data)
}
return b.WebsocketConn.WriteJSON(data)
}

View File

@@ -153,7 +153,7 @@ func (b *Bitmex) Start(wg *sync.WaitGroup) {
// Run implements the Bitmex wrapper
func (b *Bitmex) Run() {
if b.Verbose {
log.Debugf("%s Websocket: %s. (url: %s).\n", b.GetName(), common.IsEnabled(b.Websocket.IsEnabled()), b.API.Endpoints.WebsocketURL)
log.Debugf(log.ExchangeSys, "%s Websocket: %s. (url: %s).\n", b.GetName(), common.IsEnabled(b.Websocket.IsEnabled()), b.API.Endpoints.WebsocketURL)
b.PrintEnabledPairs()
}
@@ -163,7 +163,7 @@ func (b *Bitmex) Run() {
err := b.UpdateTradablePairs(false)
if err != nil {
log.Errorf("%s failed to update tradable pairs. Err: %s", b.Name, err)
log.Errorf(log.ExchangeSys, "%s failed to update tradable pairs. Err: %s", b.Name, err)
}
}
@@ -221,7 +221,7 @@ func (b *Bitmex) UpdateTradablePairs(forceUpdate bool) error {
err = b.UpdatePairs(currency.NewPairsFromStrings(assetPairs), b.CurrencyPairs.AssetTypes[x], false, false)
if err != nil {
log.Warnf("%s failed to update available pairs. Err: %v", b.Name, err)
log.Warnf(log.ExchangeSys, "%s failed to update available pairs. Err: %v", b.Name, err)
}
assetPairs = nil
}