作者 yangfu

chore: log api

... ... @@ -110,12 +110,13 @@ func (gateway BaseServiceGateway) DoRequest(requestParam Request, val interface{
}
byteResult, err := req.Bytes()
if err != nil {
gateway.InterceptSimple(requestParam.Url, string(byteResult), err)
return err
}
var result Response
err = json.Unmarshal(byteResult, &result)
if err != nil {
gateway.InterceptSimple(requestParam.Url, string(byteResult))
gateway.InterceptSimple(requestParam.Url, string(byteResult), err)
return err
}
if result.Code != 0 && len(result.Msg) > 0 {
... ... @@ -124,10 +125,14 @@ func (gateway BaseServiceGateway) DoRequest(requestParam Request, val interface{
return gateway.GetResponseData(result, val)
}
func (gateway BaseServiceGateway) InterceptSimple(url string, data string) {
func (gateway BaseServiceGateway) InterceptSimple(url string, data string, err error) {
if gateway.Interceptor != nil {
gateway.Interceptor(fmt.Sprintf("【网关】 %v | %v \nResponse:%v", url,
data,
errMsg := ""
if err != nil {
errMsg = err.Error()
}
gateway.Interceptor(fmt.Sprintf("【网关】 %v | %v \nResponse:%v Error:%v", url,
data, errMsg,
))
}
}
... ...