From 65bf1394b8fcd4c16b43172f45613b504d7e46fc Mon Sep 17 00:00:00 2001 From: Simon Roberts Date: Fri, 15 Oct 2021 07:59:41 +1100 Subject: [PATCH 1/3] Emit verbose HTTP logging for coingecko when DEBUG_HTTP is set --- pkg/api/vendors/coingecko/v3/v3.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/api/vendors/coingecko/v3/v3.go b/pkg/api/vendors/coingecko/v3/v3.go index 7cc3155..5f3ead7 100644 --- a/pkg/api/vendors/coingecko/v3/v3.go +++ b/pkg/api/vendors/coingecko/v3/v3.go @@ -9,8 +9,11 @@ import ( "net/url" "strings" + "os" + "github.com/cointop-sh/cointop/pkg/api/vendors/coingecko/format" "github.com/cointop-sh/cointop/pkg/api/vendors/coingecko/v3/types" + log "github.com/sirupsen/logrus" ) var baseURL = "https://api.coingecko.com/api/v3" @@ -31,6 +34,11 @@ func NewClient(httpClient *http.Client) *Client { // helper // doReq HTTP client func doReq(req *http.Request, client *http.Client) ([]byte, error) { + debugHttp := os.Getenv("DEBUG_HTTP") != "" + if debugHttp { + log.Debugf("doReq %s %s", req.Method, req.URL) + } + resp, err := client.Do(req) if err != nil { return nil, err @@ -41,6 +49,10 @@ func doReq(req *http.Request, client *http.Client) ([]byte, error) { return nil, err } if 200 != resp.StatusCode { + if debugHttp { + log.Warnf("doReq Got Status '%s' from %s %s", resp.Status, req.Method, req.URL) + log.Debugf("doReq Got Body: %s", body) + } return nil, fmt.Errorf("%s", body) } return body, nil From daf131f21f0f7e268d2382edf76b1d895db102d8 Mon Sep 17 00:00:00 2001 From: Simon Roberts Date: Fri, 15 Oct 2021 14:52:32 +1100 Subject: [PATCH 2/3] Add FAQ about $DEBUG and $DEBUG_HTTP --- docs/content/faq.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/content/faq.md b/docs/content/faq.md index 1ee7e20..740506d 100644 --- a/docs/content/faq.md +++ b/docs/content/faq.md @@ -493,3 +493,14 @@ draft: false ```bash GO111MODULE=on go get github.com/cointop-sh/cointop ``` + +## How can I get more information when something is going wrong? + + Cointop creates a logfile at `/tmp/cointop.log`. Normally nothing is written to this, but if you set the environment variable + `DEBUG=1` cointop will write a lot of output describing its operation. Furthermore, if you set `DEBUG_HTTP=1` it will also + emit lots about every HTTP request that cointop makes to coingecko (backend). Developers may ask for this information + to help diagnose any problems you may experience. + + ```bash + DEBUG=1 DEBUG_HTTP=1 cointop + ``` From e49211ec71b058101dea612863bce1ab52d54cfb Mon Sep 17 00:00:00 2001 From: Simon Roberts Date: Fri, 15 Oct 2021 19:57:44 +1100 Subject: [PATCH 3/3] Update faq.md --- docs/content/faq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/faq.md b/docs/content/faq.md index 740506d..cc3c391 100644 --- a/docs/content/faq.md +++ b/docs/content/faq.md @@ -497,7 +497,7 @@ draft: false ## How can I get more information when something is going wrong? Cointop creates a logfile at `/tmp/cointop.log`. Normally nothing is written to this, but if you set the environment variable - `DEBUG=1` cointop will write a lot of output describing its operation. Furthermore, if you set `DEBUG_HTTP=1` it will also + `DEBUG=1` cointop will write a lot of output describing its operation. Furthermore, if you also set `DEBUG_HTTP=1` it will emit lots about every HTTP request that cointop makes to coingecko (backend). Developers may ask for this information to help diagnose any problems you may experience.