🎨 优化部分日志输出,调整输出级别

This commit is contained in:
Binary Wang
2022-06-28 11:42:03 +08:00
parent 5f34a8811e
commit 1b6275afb3
5 changed files with 25 additions and 21 deletions

View File

@ -333,12 +333,12 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH
} }
if (error.getErrorCode() != 0) { if (error.getErrorCode() != 0) {
log.error("\n【请求地址】: {}\n【请求参数】{}\n【错误信息】{}", uriWithAccessToken, dataForLog, error); log.warn("\n【请求地址】: {}\n【请求参数】{}\n【错误信息】{}", uriWithAccessToken, dataForLog, error);
throw new WxErrorException(error, e); throw new WxErrorException(error, e);
} }
return null; return null;
} catch (IOException e) { } catch (IOException e) {
log.error("\n【请求地址】: {}\n【请求参数】{}\n【异常信息】{}", uriWithAccessToken, dataForLog, e.getMessage()); log.warn("\n【请求地址】: {}\n【请求参数】{}\n【异常信息】{}", uriWithAccessToken, dataForLog, e.getMessage());
throw new WxRuntimeException(e); throw new WxRuntimeException(e);
} }
} }

View File

@ -296,12 +296,12 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
} }
if (error.getErrorCode() != 0) { if (error.getErrorCode() != 0) {
log.error("\n【请求地址】: {}\n【请求参数】{}\n【错误信息】{}", uriWithAccessToken, dataForLog, error); log.warn("\n【请求地址】: {}\n【请求参数】{}\n【错误信息】{}", uriWithAccessToken, dataForLog, error);
throw new WxErrorException(error, e); throw new WxErrorException(error, e);
} }
return null; return null;
} catch (IOException e) { } catch (IOException e) {
log.error("\n【请求地址】: {}\n【请求参数】{}\n【异常信息】{}", uriWithAccessToken, dataForLog, e.getMessage()); log.warn("\n【请求地址】: {}\n【请求参数】{}\n【异常信息】{}", uriWithAccessToken, dataForLog, e.getMessage());
throw new WxRuntimeException(e); throw new WxRuntimeException(e);
} }
} }

View File

@ -435,12 +435,12 @@ public abstract class BaseWxMpServiceImpl<H, P> implements WxMpService, RequestH
} }
if (error.getErrorCode() != 0) { if (error.getErrorCode() != 0) {
log.error("\n【请求地址】: {}\n【请求参数】{}\n【错误信息】{}", uriWithAccessToken, dataForLog, error); log.warn("\n【请求地址】: {}\n【请求参数】{}\n【错误信息】{}", uriWithAccessToken, dataForLog, error);
throw new WxErrorException(error, e); throw new WxErrorException(error, e);
} }
return null; return null;
} catch (IOException e) { } catch (IOException e) {
log.error("\n【请求地址】: {}\n【请求参数】{}\n【异常信息】{}", uriWithAccessToken, dataForLog, e.getMessage()); log.warn("\n【请求地址】: {}\n【请求参数】{}\n【异常信息】{}", uriWithAccessToken, dataForLog, e.getMessage());
throw new WxErrorException(e); throw new WxErrorException(e);
} }
} }

View File

@ -1,5 +1,6 @@
package me.chanjar.weixin.open.api.impl; package me.chanjar.weixin.open.api.impl;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.enums.WxType; import me.chanjar.weixin.common.enums.WxType;
import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxErrorException;
@ -17,8 +18,8 @@ import java.io.IOException;
/** /**
* @author <a href="https://github.com/007gzs">007</a> * @author <a href="https://github.com/007gzs">007</a>
*/ */
@Slf4j
public abstract class WxOpenServiceAbstractImpl<H, P> implements WxOpenService, RequestHttp<H, P> { public abstract class WxOpenServiceAbstractImpl<H, P> implements WxOpenService, RequestHttp<H, P> {
private final Logger log = LoggerFactory.getLogger(this.getClass());
private WxOpenComponentService wxOpenComponentService = new WxOpenComponentServiceImpl(this); private WxOpenComponentService wxOpenComponentService = new WxOpenComponentServiceImpl(this);
private WxOpenConfigStorage wxOpenConfigStorage; private WxOpenConfigStorage wxOpenConfigStorage;
@ -46,17 +47,17 @@ public abstract class WxOpenServiceAbstractImpl<H, P> implements WxOpenService,
protected <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException { protected <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException {
try { try {
T result = executor.execute(uri, data, WxType.Open); T result = executor.execute(uri, data, WxType.Open);
this.log.debug("\n【请求地址】: {}\n【请求参数】{}\n【响应数据】{}", uri, data, result); log.debug("\n【请求地址】: {}\n【请求参数】{}\n【响应数据】{}", uri, data, result);
return result; return result;
} catch (WxErrorException e) { } catch (WxErrorException e) {
WxError error = e.getError(); WxError error = e.getError();
if (error.getErrorCode() != 0) { if (error.getErrorCode() != 0) {
this.log.error("\n【请求地址】: {}\n【请求参数】{}\n【错误信息】{}", uri, data, error); log.warn("\n【请求地址】: {}\n【请求参数】{}\n【错误信息】{}", uri, data, error);
throw new WxErrorException(error, e); throw new WxErrorException(error, e);
} }
return null; return null;
} catch (IOException e) { } catch (IOException e) {
this.log.error("\n【请求地址】: {}\n【请求参数】{}\n【异常信息】{}", uri, data, e.getMessage()); log.warn("\n【请求地址】: {}\n【请求参数】{}\n【异常信息】{}", uri, data, e.getMessage());
throw new WxRuntimeException(e); throw new WxRuntimeException(e);
} }
} }

View File

@ -13,15 +13,18 @@ import com.github.binarywang.wxpay.exception.WxPayException;
*/ */
public interface CustomDeclarationService { public interface CustomDeclarationService {
static String DECLARATION_BASE_URL = "https://apihk.mch.weixin.qq.com/global/v3/customs"; /**
* The constant DECLARATION_BASE_URL.
*/
String DECLARATION_BASE_URL = "https://apihk.mch.weixin.qq.com/global/v3/customs";
/** /**
* <pre> * <pre>
* 报关API * 报关API
* 文档地址: https://pay.weixin.qq.com/wiki/doc/api/wxpay/ch/declarecustom_ch/chapter3_1.shtml * 文档地址: <a href="https://pay.weixin.qq.com/wiki/doc/api/wxpay/ch/declarecustom_ch/chapter3_1.shtml">...</a>
* </pre> * </pre>
* *
* @param request * @param request the request
* @return 返回数据 declaration result * @return 返回数据 declaration result
* @throws WxPayException the wx pay exception * @throws WxPayException the wx pay exception
*/ */
@ -30,10 +33,10 @@ public interface CustomDeclarationService {
/** /**
* <pre> * <pre>
* 报关查询API * 报关查询API
* 文档地址: https://pay.weixin.qq.com/wiki/doc/api/wxpay/ch/declarecustom_ch/chapter3_3.shtml * 文档地址: <a href="https://pay.weixin.qq.com/wiki/doc/api/wxpay/ch/declarecustom_ch/chapter3_3.shtml">...</a>
* </pre> * </pre>
* *
* @param request * @param request the request
* @return 返回数据 declaration query result * @return 返回数据 declaration query result
* @throws WxPayException the wx pay exception * @throws WxPayException the wx pay exception
*/ */
@ -42,10 +45,10 @@ public interface CustomDeclarationService {
/** /**
* <pre> * <pre>
* 身份信息校验API * 身份信息校验API
* 文档地址: https://pay.weixin.qq.com/wiki/doc/api/wxpay/ch/declarecustom_ch/chapter3_2.shtml * 文档地址: <a href="https://pay.weixin.qq.com/wiki/doc/api/wxpay/ch/declarecustom_ch/chapter3_2.shtml">...</a>
* </pre> * </pre>
* *
* @param request * @param request the request
* @return 返回数据 verify certification result * @return 返回数据 verify certification result
* @throws WxPayException the wx pay exception * @throws WxPayException the wx pay exception
*/ */
@ -54,10 +57,10 @@ public interface CustomDeclarationService {
/** /**
* <pre> * <pre>
* 报关信息修改API * 报关信息修改API
* 文档地址: https://pay.weixin.qq.com/wiki/doc/api/wxpay/ch/declarecustom_ch/chapter3_5.shtml * 文档地址: <a href="https://pay.weixin.qq.com/wiki/doc/api/wxpay/ch/declarecustom_ch/chapter3_5.shtml">...</a>
* </pre> * </pre>
* *
* @param request * @param request the request
* @return 返回数据 declaration result * @return 返回数据 declaration result
* @throws WxPayException the wx pay exception * @throws WxPayException the wx pay exception
*/ */
@ -66,10 +69,10 @@ public interface CustomDeclarationService {
/** /**
* <pre> * <pre>
* 报关重推API * 报关重推API
* 文档地址: https://pay.weixin.qq.com/wiki/doc/api/wxpay/ch/declarecustom_ch/chapter3_4.shtml * 文档地址: <a href="https://pay.weixin.qq.com/wiki/doc/api/wxpay/ch/declarecustom_ch/chapter3_4.shtml">...</a>
* </pre> * </pre>
* *
* @param request * @param request the request
* @return 返回数据 redeclaration result * @return 返回数据 redeclaration result
* @throws WxPayException the wx pay exception * @throws WxPayException the wx pay exception
*/ */