From 0b55f24d7075b6352d4dd6fe61f74d5e0b295b17 Mon Sep 17 00:00:00 2001 From: Martin Divis Date: Mon, 28 Oct 2024 07:28:55 +0100 Subject: [PATCH] logging --- appd.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/appd.go b/appd.go index 9d45bbf..29f663b 100644 --- a/appd.go +++ b/appd.go @@ -332,11 +332,20 @@ func (c *Client) do(req *http.Request, v interface{}, authorization bool) error return err } + if v == nil { + c.log.Debugf("Suspect - no model supplied for request %s", req.URL.Path) + } + if v != nil { - err = json.NewDecoder(resp.Body).Decode(v) + body, err := io.ReadAll(resp.Body) if err != nil { + c.log.Errorf("Error reading request body for request %v", req) + } + c.log.Debugf("Decoding response from uri %s - %s", req.URL.Path, string(body)) + err = json.Unmarshal(body, v) + if err != nil { + c.log.Errorf("Error un-marshalling request body for request %v : %s - %v", req.URL.Path, string(body), err) return err - } } return nil