diff --git a/platformapi/platformapi.go b/platformapi/platformapi.go index 4de33ddf..ac3be644 100644 --- a/platformapi/platformapi.go +++ b/platformapi/platformapi.go @@ -130,7 +130,7 @@ func AccessPlatformAPIWithRetry(client *http.Client, handleRequest func() *http. if bodyData, err := ioutil.ReadAll(response.Body); err == nil { baseapi.SugarLogger.Errorf("AccessPlatformAPIWithRetry:%s HTTP code is:%d, url:%v, request:%v, response:%s", trackID, response.StatusCode, request.URL, getClonedData(request.URL, savedBuf), string(bodyData)) } else { - baseapi.SugarLogger.Errorf("AccessPlatformAPIWithRetry:%s HTTP code is:%d, url:%v, request:%v", trackID, response.StatusCode, request.URL, getClonedData(request.URL, savedBuf)) + baseapi.SugarLogger.Errorf("AccessPlatformAPIWithRetry:%s HTTP code is:%d, url:%v, request:%v, ioutil.ReadAll failed with error:%v", trackID, response.StatusCode, request.URL, getClonedData(request.URL, savedBuf), err) } return ErrHTTPCodeIsNot200 } @@ -142,7 +142,13 @@ func AccessPlatformAPIWithRetry(client *http.Client, handleRequest func() *http. if err != nil { baseapi.SugarLogger.Errorf("AccessPlatformAPIWithRetry:%s url:%v, request:%v failed with error:%v", trackID, request.URL, getClonedData(request.URL, savedBuf), err) } else if err = utils.TryUnmarshalUseNumber(bodyData, &bodyMap); err != nil { - baseapi.SugarLogger.Errorf("AccessPlatformAPIWithRetry:%s url:%v, request:%v failed with error:%v, bodyData:%s", trackID, request.URL, getClonedData(request.URL, savedBuf), err, string(bodyData)) + const maxOutputLen = 200 + bodyDataLen := len(bodyData) + bodyData2 := bodyData + if bodyDataLen > maxOutputLen { + bodyData2 = bodyData2[:maxOutputLen] + } + baseapi.SugarLogger.Infof("AccessPlatformAPIWithRetry:%s url:%v, request:%v failed with error:%v, bodyData:%s", trackID, request.URL, getClonedData(request.URL, savedBuf), err, string(bodyData2)) } if err != nil {