From 615049f4b215a054b071383df97e5afb1a1cbd52 Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 28 Mar 2019 22:57:47 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E7=A6=81=E6=AD=A2TryUnmarshalUseNumber?= =?UTF-8?q?=E5=87=BA=E9=94=99=E5=90=8E=E6=8A=A5=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/platformapi.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 {