当前位置:网站首页>切面打印调取的方法
切面打印调取的方法
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;
}
}边栏推荐
- 论文理解【RL - Exp Replay】—— Experience Replay with Likelihood-free Importance Weights
- System availability: 3 9s, 4 9s in SRE's mouth... What is it?
- 部门项目源码分享
- 数据库表设计规则
- IDEA入门看这一篇就够了
- excel clear format
- y84.第四章 Prometheus大厂监控体系及实战 -- prometheus告警机制进阶(十五)
- Chapter 11 Working with Dates and Times
- 美赞臣EDI 940仓库装运订单详解
- Nacos配置中心之加载配置
猜你喜欢

研发团队数字化转型实践

Access the selected node in the console
![[LeetCode304周赛] 两道关于基环树的题 6134. 找到离给定两个节点最近的节点,6135. 图中的最长环](/img/63/16de443caf28644d79dc6e6889e5dd.png)
[LeetCode304周赛] 两道关于基环树的题 6134. 找到离给定两个节点最近的节点,6135. 图中的最长环

数据分析04

访问控制台中的选定节点

Building a cloud-native DevOps environment

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

6134. Find the closest node to the given two nodes - force double hundred code

ROS2初级知识(8):Launching启动多节点
![[Camp Experience Post] 2022 Cybersecurity Summer Camp](/img/1e/716bafc679dc67d3d54bcc21a3b670.png)
[Camp Experience Post] 2022 Cybersecurity Summer Camp
随机推荐
excel remove all carriage return from a cell
颜色透明参数
还在纠结报表工具的选型么?来看看这个
论文解读(GSAT)《Interpretable and Generalizable Graph Learning via Stochastic Attention Mechanism》
Avoid hidden text when loading fonts
Calculate the angle of a line defined by two points
[LeetCode304 Weekly Competition] Two questions about the base ring tree 6134. Find the closest node to the given two nodes, 6135. The longest cycle in the graph
bat 之 特殊字符&转义
vscode hide menu bar
深度学习基础-基于Numpy的循环神经网络(RNN)实现和反向传播训练
y84. Chapter 4 Prometheus Factory Monitoring System and Actual Combat -- Advanced Prometheus Alarm Mechanism (15)
Codeforces CodeTON Round 2 (Div. 1 + Div. 2, Rated, Prizes!) A-D 题解
下载安装 vscode(含汉化、插件的推荐和安装)
1391D. 505 状压dp
中职网络安全竞赛B7比赛部署流程
excel split text into different rows
ELK log collection
域名重定向工具 —— SwitchHosts 实用教程
excel edit a cell without double clicking
excel vertical to horizontal