加日志
This commit is contained in:
parent
7e7b4d6eb0
commit
f9ae5275d1
@ -78,7 +78,10 @@ func (c *Client) postForm(path string, form url.Values, out interface{}) error {
|
|||||||
|
|
||||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||||
req.Header.Set("app_id", c.AppID)
|
req.Header.Set("app_id", c.AppID)
|
||||||
req.Header.Set("signature", c.signature(form))
|
signature := c.signature(form)
|
||||||
|
req.Header.Set("signature", signature)
|
||||||
|
|
||||||
|
c.logUpstreamRequest(path, form, signature)
|
||||||
|
|
||||||
resp, err := c.HTTPClient.Do(req)
|
resp, err := c.HTTPClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -182,6 +185,20 @@ func setValue(form url.Values, key, value string) {
|
|||||||
form.Set(key, value)
|
form.Set(key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Client) logUpstreamRequest(path string, form url.Values, signature string) {
|
||||||
|
if global.Logger == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
global.Logger.WithFields(logrus.Fields{
|
||||||
|
"module": "ca_v2",
|
||||||
|
"upstream_path": path,
|
||||||
|
"request_form": form.Encode(),
|
||||||
|
"request_params": form,
|
||||||
|
"signature": signature,
|
||||||
|
}).Info("ca v2 upstream request")
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Client) logUpstreamResponse(path string, form url.Values, statusCode int, body string) {
|
func (c *Client) logUpstreamResponse(path string, form url.Values, statusCode int, body string) {
|
||||||
if global.Logger == nil {
|
if global.Logger == nil {
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user