当前位置:网站首页>切面打印调取的方法
切面打印调取的方法
2022-08-01 23:22:00 【枫林残@】
@Aspect
@Component
@Slf4j
public class SysLoggerAspect {
@Pointcut("execution(* com.siact..controller..*.*(..))")
public void loggerPointCut() {
}
@Before("loggerPointCut()")
public void saveSysLog(JoinPoint joinPoint) {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
//请求的方法名
String className = joinPoint.getTarget().getClass().getName();
String methodName = signature.getName();
//请求的参数
Object[] args = joinPoint.getArgs();
StringBuilder params = new StringBuilder();
for(Object o:args){
if(o instanceof HttpServletRequest || o instanceof HttpServletResponse || o instanceof MultipartFile){
continue;
}
params.append("/");
params.append(JSON.toJSONString(o));
}
//获取IP地址
String ip = HttpUtils.getIpAddress();
if(!methodName.contains("login")){
log.info("请求类名>>>:{},请求方法名>>>:{},请求ip:{},请求参数>>>:{}",className,methodName,ip,params);
}
}
@Around("loggerPointCut()")
public Object printElapseTime(ProceedingJoinPoint joinPoint){
long startTime = System.currentTimeMillis();// 开始时间
Object result = null;
try {
result = joinPoint.proceed();
} catch (CustomizeException ex){
log.error(SecurityError.SEC_20005.getLogMsg());
result = new ResponseEntity<>(new ResultInfo<String>().error(SecurityError.SEC_20005), HttpStatus.UNAUTHORIZED);
} catch (Throwable e) {
log.error(ExceptionUtils.getStackTrace(e));
log.error(SystemError.SYS_10019.getLogMsg()) ;
} finally {
long handleTime = System.currentTimeMillis()-startTime;
log.info("请求类名>>>:{},请求方法名>>>:{},请求耗时>>>:{}ms",joinPoint.getTarget().getClass().getName(),((MethodSignature) joinPoint.getSignature()).getName(),handleTime);
}
return result;
}
}边栏推荐
- C language - branch statement and loop statement
- excel split text into different rows
- 解决端口占用
- 浅析多服务在分布式系统下多事务通信处理机制方案
- C#大型互联网平台管理框架源码:基于ASP.NET MVC+EF6+Bootstrap开发,支持多数据库
- When using DocumentFragments add a large number of elements
- Chapter 19 Tips and Traps: Common Goofs for Novices
- Three, mysql storage engine - building database and table operation
- 最短路模板
- 还在纠结报表工具的选型么?来看看这个
猜你喜欢

drf生成序列化类代码

深度学习基础-基于Numpy的循环神经网络(RNN)实现和反向传播训练
![[Camp Experience Post] 2022 Cybersecurity Summer Camp](/img/1e/716bafc679dc67d3d54bcc21a3b670.png)
[Camp Experience Post] 2022 Cybersecurity Summer Camp
![Thesis understanding [RL - Exp Replay] - Experience Replay with Likelihood-free Importance Weights](/img/f1/9824f32dd4fe4b3e94af3f945b1801.png)
Thesis understanding [RL - Exp Replay] - Experience Replay with Likelihood-free Importance Weights

从0到1:图文投票小程序设计与研发笔记

E - Integer Sequence Fair

域名重定向工具 —— SwitchHosts 实用教程

伸展树的特性及实现

From 0 to 1: Design and R&D Notes of Graphic Voting Mini Program

Is TCP reliable?Why?
随机推荐
PostgreSQL 基础--常用命令
What is CICD excuse me
cmd command
测试岗月薪5-9k,如何实现涨薪到25k?
excel edit a cell without double clicking
qt-faststart 安装使用
【好书推荐】第一本无人驾驶技术书
Nacos配置中心之加载配置
部门项目源码分享
DRF generating serialization class code
仿牛客网项目第三章:开发社区核心功能(详细步骤和思路)
邻接表与邻接矩阵
qt-faststart installation and use
请问什么是 CICD
Special characters & escapes in bat
浅析多服务在分布式系统下多事务通信处理机制方案
excel vertical to horizontal
From 0 to 1: Design and R&D Notes of Graphic Voting Mini Program
Leetcode 129求根节点到叶节点数字之和、104二叉树的最大深度、8字符串转换整数(atoi)、82删除排序链表中的重复元素II、204二分查找、94二叉树的中序遍历、144二叉树的前序遍历
解决端口占用