Skip to content

Commit

Permalink
logging
Browse files Browse the repository at this point in the history
  • Loading branch information
chrlic committed Oct 28, 2024
1 parent 172a9dd commit 0b55f24
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions appd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0b55f24

Please sign in to comment.