Commit aaa39a55 by zhiheng.zhang

删除logutil 打印

parent 82f78c45
...@@ -9,11 +9,7 @@ import java.lang.annotation.*; ...@@ -9,11 +9,7 @@ import java.lang.annotation.*;
@Inherited @Inherited
public @interface IgnoreFeignLogAnnotation { public @interface IgnoreFeignLogAnnotation {
/** boolean printInfoLog() default true;
* 是否打印日志,true打印,false不打印,注意设置成false状态码和状态码信息都不会打印
* @return
*/
boolean printLog() default true;
/** /**
* printLog 设置成true的时候,可以排除哪些状态码的响应不用打印响应报文,只会打印状态码 * printLog 设置成true的时候,可以排除哪些状态码的响应不用打印响应报文,只会打印状态码
......
...@@ -8,6 +8,8 @@ import cn.freemud.inteceptor.CommonServiceException; ...@@ -8,6 +8,8 @@ import cn.freemud.inteceptor.CommonServiceException;
import cn.freemud.redis.RedisCache; import cn.freemud.redis.RedisCache;
import cn.freemud.utils.LogUtil; import cn.freemud.utils.LogUtil;
import cn.freemud.utils.ResponseUtil; import cn.freemud.utils.ResponseUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.freemud.api.assortment.datamanager.entity.db.AssortmentOpenPlatformConfig; import com.freemud.api.assortment.datamanager.entity.db.AssortmentOpenPlatformConfig;
import com.freemud.api.assortment.datamanager.entity.vo.AssortmentCustomerInfoVo; import com.freemud.api.assortment.datamanager.entity.vo.AssortmentCustomerInfoVo;
import com.freemud.api.assortment.datamanager.manager.AssortmentOpenPlatformConfigManager; import com.freemud.api.assortment.datamanager.manager.AssortmentOpenPlatformConfigManager;
...@@ -221,18 +223,17 @@ public class WebAspect { ...@@ -221,18 +223,17 @@ public class WebAspect {
if (sig instanceof MethodSignature) { if (sig instanceof MethodSignature) {
msig = (MethodSignature) sig; msig = (MethodSignature) sig;
Method currentMethod = sig.getDeclaringType().getDeclaredMethod(msig.getName(), msig.getParameterTypes()); Method currentMethod = sig.getDeclaringType().getDeclaredMethod(msig.getName(), msig.getParameterTypes());
Object logReult = result; Object logReult = result;
ThirdPartLogVo thirdPartLogVo = LogUtil.createThirdPartLogVo(joinPoint); ThirdPartLogVo thirdPartLogVo = LogUtil.createThirdPartLogVo(joinPoint);
String statusCodeValue = "ignore"; String statusCodeValue = "ignore";
String messageValue = "ignore"; String messageValue = "ignore";
// 打印第三方出参日志 // 打印第三方出参日志 如果feign方法没有IgnoreFeignLogAnnotation注解,全部打日志,但是由于statusCodeValue = "ignore",是不是触发日志告警的
IgnoreFeignLogAnnotation logIgnore = currentMethod.getAnnotation(IgnoreFeignLogAnnotation.class);
if (!this.printFeignResponseBodyLog) { if (logIgnore != null) {
IgnoreFeignLogAnnotation logIgnore = currentMethod.getAnnotation(IgnoreFeignLogAnnotation.class); JSONObject json = JSON.parseObject(JSON.toJSONString(result));
if (logIgnore != null && logIgnore.printLog()) { statusCodeValue = json.getString(logIgnore.statusCodeFieldName());
statusCodeValue = org.apache.commons.beanutils.BeanUtils.getProperty(result, logIgnore.statusCodeFieldName()); messageValue = json.getString(logIgnore.messageFieldName());
messageValue = org.apache.commons.beanutils.BeanUtils.getProperty(result, logIgnore.messageFieldName()); if (!this.printFeignResponseBodyLog && !logIgnore.printInfoLog()) {
//todo 当排除了这个状态码不打印响应的具体内容只会打印状态码和状态描述信息 //todo 当排除了这个状态码不打印响应的具体内容只会打印状态码和状态描述信息
String[] excludeStatusCodes = logIgnore.excludeStatusCodes(); String[] excludeStatusCodes = logIgnore.excludeStatusCodes();
if (!StringUtils.isEmpty(statusCodeValue) && this.containStatusCode(excludeStatusCodes, statusCodeValue)) { if (!StringUtils.isEmpty(statusCodeValue) && this.containStatusCode(excludeStatusCodes, statusCodeValue)) {
...@@ -242,7 +243,8 @@ public class WebAspect { ...@@ -242,7 +243,8 @@ public class WebAspect {
} }
} }
} }
ThirdPartyLog.infoConvertJson(statusCodeValue, messageValue, start, System.currentTimeMillis(), thirdPartLogVo.getUri(), thirdPartLogVo.getRequestBody(), logReult); ThirdPartyLog.infoConvertJson(statusCodeValue, messageValue, start, System.currentTimeMillis(),
thirdPartLogVo.getUri(), thirdPartLogVo.getRequestBody(), logReult);
} }
} catch (Exception e) { } catch (Exception e) {
log.error("WebAspect Feign Log Ignore error {}", ExceptionUtils.getMessage(e)); log.error("WebAspect Feign Log Ignore error {}", ExceptionUtils.getMessage(e));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment