forked from go-packages/paypal
req log
This commit is contained in:
parent
768e6872d3
commit
0bbdd821f8
|
@ -4,6 +4,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -131,9 +132,9 @@ func (c *Client) NewRequest(method, url string, payload interface{}) (*http.Requ
|
||||||
}
|
}
|
||||||
|
|
||||||
// log will dump request and response to the log file
|
// log will dump request and response to the log file
|
||||||
func (c *Client) log(req *http.Request, resp *http.Response) {
|
func (c *Client) log(r *http.Request, resp *http.Response) {
|
||||||
if c.Log != nil {
|
if c.Log != nil {
|
||||||
reqDump, _ := httputil.DumpRequest(req, true)
|
reqDump := fmt.Sprintf("%s %s. Data: %s", r.Method, r.URL.String(), r.Form.Encode())
|
||||||
respDump, _ := httputil.DumpResponse(resp, true)
|
respDump, _ := httputil.DumpResponse(resp, true)
|
||||||
|
|
||||||
c.Log.Write([]byte("Request: " + string(reqDump) + "\nResponse: " + string(respDump) + "\n\n"))
|
c.Log.Write([]byte("Request: " + string(reqDump) + "\nResponse: " + string(respDump) + "\n\n"))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user