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

@@ -16,7 +16,6 @@ import (
"hash"
"io"
"io/ioutil"
"log"
"math"
"net/http"
"net/url"
@@ -29,6 +28,8 @@ import (
"strconv"
"strings"
"time"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Vars for common.go operations
@@ -390,7 +391,7 @@ func SendHTTPRequest(method, path string, headers map[string]string, body io.Rea
// on failure.
func SendHTTPGetRequest(url string, jsonDecode, isVerbose bool, result interface{}) error {
if isVerbose {
log.Println("Raw URL: ", url)
log.Debugf("Raw URL: %s", url)
}
initialiseHTTPClient()
@@ -410,7 +411,7 @@ func SendHTTPGetRequest(url string, jsonDecode, isVerbose bool, result interface
}
if isVerbose {
log.Println("Raw Resp: ", string(contents[:]))
log.Debugf("Raw Resp: %s", string(contents[:]))
}
defer res.Body.Close()
@@ -639,8 +640,8 @@ func CheckDir(dir string, create bool) error {
return fmt.Errorf("directory %s does not exist. Err: %s", dir, err)
}
log.Printf("Directory %s does not exist.. creating.", dir)
err = os.Mkdir(dir, 0777)
log.Warnf("Directory %s does not exist.. creating.", dir)
err = os.MkdirAll(dir, 0777)
if err != nil {
return fmt.Errorf("failed to create dir. Err: %s", err)
}