【fix sonar】LogRecordAspect文件
This commit is contained in:
+5
-8
@@ -1,28 +1,25 @@
|
||||
package com.jero.modules.ngalain.aop;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
|
||||
|
||||
|
||||
// 暂时注释掉,提高系统性能
|
||||
//@Aspect //定义一个切面
|
||||
//@Configuration
|
||||
@Slf4j
|
||||
public class LogRecordAspect {
|
||||
private static final Logger logger = LoggerFactory.getLogger(LogRecordAspect.class);
|
||||
|
||||
// 定义切点Pointcut
|
||||
@Pointcut("execution(public * com.jero.modules.*.*.*Controller.*(..))")
|
||||
public void excudeService() {
|
||||
// do point
|
||||
}
|
||||
|
||||
@Around("excudeService()")
|
||||
@@ -40,12 +37,12 @@ private static final Logger logger = LoggerFactory.getLogger(LogRecordAspect.cla
|
||||
uri = request.getRequestURI();
|
||||
queryString = request.getQueryString();
|
||||
}
|
||||
logger.info("请求开始, 各个参数, url: {}, method: {}, uri: {}, params: {}", url, method, uri, queryString);
|
||||
log.info("请求开始, 各个参数, url: {}, method: {}, uri: {}, params: {}", url, method, uri, queryString);
|
||||
|
||||
// result的值就是被拦截方法的返回值
|
||||
Object result = pjp.proceed();
|
||||
|
||||
logger.info("请求结束,controller的返回值是 " + result);
|
||||
log.info("请求结束,controller的返回值是 " + result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user