|
@@ -1,61 +0,0 @@
|
|
|
-package com.bootdo.common.aspect;
|
|
|
-
|
|
|
-import com.bootdo.common.utils.HttpContextUtils;
|
|
|
-import org.aspectj.lang.JoinPoint;
|
|
|
-import org.aspectj.lang.ProceedingJoinPoint;
|
|
|
-import org.aspectj.lang.annotation.*;
|
|
|
-import org.aspectj.lang.reflect.MethodSignature;
|
|
|
-import org.slf4j.Logger;
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
-import org.springframework.web.context.request.RequestContextHolder;
|
|
|
-import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
-import sun.net.util.IPAddressUtil;
|
|
|
-
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.lang.reflect.Method;
|
|
|
-import java.util.Arrays;
|
|
|
-
|
|
|
-@Aspect
|
|
|
-@Component
|
|
|
-public class WebLogAspect {
|
|
|
-
|
|
|
- private static final Logger logger = LoggerFactory.getLogger(WebLogAspect.class);
|
|
|
-
|
|
|
- @Pointcut("execution( * com.bootdo..controller.*.*(..))")
|
|
|
- public void logPointCut() {
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Before("logPointCut()")
|
|
|
- public void doBefore(JoinPoint joinPoint) throws Throwable {
|
|
|
-
|
|
|
- ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
|
|
- HttpServletRequest request = attributes.getRequest();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- logger.info("CLASS_METHOD : " + joinPoint.getSignature().getDeclaringTypeName() + "."
|
|
|
- + joinPoint.getSignature().getName());
|
|
|
- logger.info("参数 : " + Arrays.toString(joinPoint.getArgs()));
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @AfterReturning(returning = "ret", pointcut = "logPointCut()")
|
|
|
- public void doAfterReturning(Object ret) throws Throwable {
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Around("logPointCut()")
|
|
|
- public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
|
|
|
- long startTime = System.currentTimeMillis();
|
|
|
- Object ob = pjp.proceed();
|
|
|
-
|
|
|
- return ob;
|
|
|
- }
|
|
|
-}
|