拦截接口的调用 打印日志
@Aspect
@Component
@Slf4j
public class MethodLogAspect {
@Around(value = "execution(* com.xxx.controller.*.*(..))")
public Object around(ProceedingJoinPoint point) {
StopWatch clock = new StopWatch();
clock.start();
String methodPrefix = point.getSignature().toString();
log.info(methodPrefix + ", 参数值:" + Arrays.toString(point.getArgs()));
Object returnValue;
try {
returnValue = point.proceed();
} catch (Throwable throwable) {
log.error(methodPrefix + " invoke controller error ", throwable);
returnValue = Result.failed("系统错误");
}
clock.stop();
log.info(methodPrefix + ", 返回值:" + returnValue + ", 用时:" + clock.getTotalTimeMillis() + " ms");
return returnValue;
}
}