Skip to content

Commit 00421c4

Browse files
committed
为接口请求增加日志输出
1 parent b8a9795 commit 00421c4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,9 @@ public <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) thro
538538
int retryTimes = 0;
539539
do {
540540
try {
541-
return executeInternal(executor, uri, data);
541+
T result = this.executeInternal(executor, uri, data);
542+
this.log.debug("\n[URL]: {}\n[PARAMS]: {}\n[RESPONSE]: {}",uri, data, result);
543+
return result;
542544
} catch (WxErrorException e) {
543545
if (retryTimes + 1 > this.maxRetryTimes) {
544546
this.log.warn("重试达到最大次数【{}】", this.maxRetryTimes);
@@ -578,8 +580,7 @@ protected synchronized <T, E> T executeInternal(RequestExecutor<T, E> executor,
578580
uriWithAccessToken += uri.indexOf('?') == -1 ? "?access_token=" + accessToken : "&access_token=" + accessToken;
579581

580582
try {
581-
return executor.execute(getHttpclient(), this.httpProxy,
582-
uriWithAccessToken, data);
583+
return executor.execute(getHttpclient(), this.httpProxy, uriWithAccessToken, data);
583584
} catch (WxErrorException e) {
584585
WxError error = e.getError();
585586
/*
@@ -592,11 +593,14 @@ protected synchronized <T, E> T executeInternal(RequestExecutor<T, E> executor,
592593
this.configStorage.expireAccessToken();
593594
return execute(executor, uri, data);
594595
}
596+
595597
if (error.getErrorCode() != 0) {
598+
this.log.error("\n[URL]: {}\n[PARAMS]: {}\n[RESPONSE]: {}", uri, data, error);
596599
throw new WxErrorException(error);
597600
}
598601
return null;
599602
} catch (IOException e) {
603+
this.log.error("\n[URL]: {}\n[PARAMS]: {}\n[EXCEPTION]: {}", uri, data, e.getMessage());
600604
throw new RuntimeException(e);
601605
}
602606
}

0 commit comments

Comments
 (0)