Commit 9e66fbad by hanghang.wang

修改日志打印内容,跟进打印多次问题

parent 595a014c
......@@ -6,7 +6,6 @@ import com.freemud.application.sdk.api.exception.IgnoreErrorAnnotation;
import com.freemud.application.sdk.api.log.*;
import com.freemud.application.sdk.api.service.EmailAlertService;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
......@@ -32,10 +31,13 @@ import java.util.Arrays;
import java.util.List;
import java.util.UUID;
/**
* @author freemud_whh
*/
@Aspect
@Component
@Slf4j
public class ControllerLogAop implements Ordered {
@Autowired
private EmailAlertService emailAlertService;
......@@ -51,7 +53,6 @@ public class ControllerLogAop implements Ordered {
@Value("${exclude-print-body-log-methods:findNearPickUpStores,getMenuCategory}")
private volatile List<String> excludePrintBodyLogMethods = Lists.newArrayList();
@Pointcut("@annotation(cn.freemud.aop.LogIgnore)")
public void pointcut() {
}
......@@ -78,7 +79,6 @@ public class ControllerLogAop implements Ordered {
List logArgs = this.getLogArgs(currentMethod, joinPoint);
String requestData = JSON.toJSONString(logArgs);
LogIgnore logIgnore = currentMethod.getAnnotation(LogIgnore.class);
// log.info("startTime={}-->TrackingNo={}-->logMessage= {}-->url={}-->requestData={} ::start",startTime,LogThreadLocal.getTrackingNo(),logIgnore.logMessage(),logMethod,requestData);
Object object = joinPoint.proceed();
Object logObj = object;
if (logIgnore != null && logIgnore.printLog()) {
......@@ -112,8 +112,6 @@ public class ControllerLogAop implements Ordered {
if (excludeStatusCodes == null || excludeStatusCodes.length == 0) {
return false;
}
for (int i = 0; i < excludeStatusCodes.length; i++) {
if (excludeStatusCodes[i].equals(statusCodeValue)) {
return true;
......@@ -143,18 +141,15 @@ public class ControllerLogAop implements Ordered {
} else {
msig = (MethodSignature) sig;
Object target = joinPoint.getTarget();
try {
currentMethod = target.getClass().getMethod(msig.getName(), msig.getParameterTypes());
} catch (NoSuchMethodException var19) {
var19.printStackTrace();
}
StringBuilder logMethod = new StringBuilder(joinPoint.getSignature().getDeclaringTypeName());
logMethod.append(".");
logMethod.append(joinPoint.getSignature().getName());
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
try {
Class<?> clz = e.getClass();
boolean clzHasAnno = clz.isAnnotationPresent(IgnoreErrorAnnotation.class);
......@@ -167,7 +162,6 @@ public class ControllerLogAop implements Ordered {
ErrorLog.errorConvertJson(SDKCommonBaseContextWare.getAppName(), logMethod.toString(), "出错:" + e.getMessage(), request, startTime, System.currentTimeMillis(), this.getLogArgs(currentMethod, joinPoint), e);
LogThreadLocal.removeTrackingNo();
}
}
}
......@@ -179,7 +173,6 @@ public class ControllerLogAop implements Ordered {
if (args != null && args.length != 0) {
List logArgs = new ArrayList();
Parameter[] parameters = method.getParameters();
for (int j = 0; j < parameters.length; ++j) {
Parameter parameter = parameters[j];
LogParams logParams = (LogParams) parameter.getAnnotation(LogParams.class);
......@@ -187,7 +180,6 @@ public class ControllerLogAop implements Ordered {
logArgs.add(args[j]);
}
}
return logArgs;
} else {
return null;
......
......@@ -84,7 +84,6 @@ public class WebAspect {
@Value("${print-feign-response-body-log-shop-cart:false}")
private volatile boolean printFeignResponseBodyLogForShopCart = false;
@Pointcut("execution(* cn.freemud.controller..*.*(..))")
public void webAspect() {
}
......@@ -169,7 +168,6 @@ public class WebAspect {
if (sig instanceof MethodSignature) {
msig = (MethodSignature) sig;
Method currentMethod = sig.getDeclaringType().getDeclaredMethod(msig.getName(), msig.getParameterTypes());
Object logReult = result;
ThirdPartLogVo thirdPartLogVo = LogUtil.createThirdPartLogVo(joinPoint);
// 打印第三方出参日志
......@@ -189,7 +187,6 @@ public class WebAspect {
}
ThirdPartyLog.infoConvertJson(LogThreadLocal.getTrackingNo(), SDKCommonBaseContextWare.getAppName(), start, System.currentTimeMillis(),
thirdPartLogVo.getUri(), thirdPartLogVo.getRequestBody(), logReult);
}
} catch (Exception e) {
log.error("WebAspect Feign Log Ignore error {}", ExceptionUtils.getMessage(e));
......@@ -197,13 +194,11 @@ public class WebAspect {
return result;
}
/**
* 20201231改造SDK日志打印判断
* 根据printFeignResponseBodyLog判断是否开启打印
* 后续将模块内SDK整合为feign请求,此次暂时不用
*/
/**
* @Pointcut("@annotation(com.freemud.application.sdk.api.log.ThirdPartyLog)") public void restTemplateLog() {
* }
......@@ -252,7 +247,6 @@ public class WebAspect {
* }
*/
public String getNotFilterUrl(String redisKey, String configKey) {
String notFilterUrl;
try {
......@@ -270,7 +264,8 @@ public class WebAspect {
return notFilterUrl;
}
private boolean containStatusCode(String[] excludeStatusCodes, String statusCodeValue) {
private boolean containStatusCode(String[] excludeStatusCodes,
String statusCodeValue) {
if (excludeStatusCodes == null || excludeStatusCodes.length == 0) {
return false;
}
......@@ -282,5 +277,4 @@ public class WebAspect {
return false;
}
}
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