修复:修复记录被忽略的日志的问题
This commit is contained in:
parent
ac6d2918d9
commit
c1bc5d9049
@ -51,7 +51,7 @@ public @interface Log {
|
|||||||
String module() default "";
|
String module() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否忽略日志记录(仅用于接口方法上)
|
* 是否忽略日志记录(用于接口方法或类上)
|
||||||
*/
|
*/
|
||||||
boolean ignore() default false;
|
boolean ignore() default false;
|
||||||
}
|
}
|
||||||
|
@ -322,20 +322,24 @@ public class LogInterceptor implements HandlerInterceptor {
|
|||||||
// 3、排除不需要记录系统日志的接口
|
// 3、排除不需要记录系统日志的接口
|
||||||
HandlerMethod handlerMethod = (HandlerMethod)handler;
|
HandlerMethod handlerMethod = (HandlerMethod)handler;
|
||||||
Log methodLog = handlerMethod.getMethodAnnotation(Log.class);
|
Log methodLog = handlerMethod.getMethodAnnotation(Log.class);
|
||||||
// 3.1 请求方式不要求记录且接口方法上没有 @Log 注解,则不记录系统日志
|
// 3.1 如果接口方法上既没有 @Log 注解,也没有 @Operation 注解,则不记录系统日志
|
||||||
if (operationLogProperties.getExcludeMethods().contains(request.getMethod()) && methodLog == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// 3.2 如果接口方法上既没有 @Log 注解,也没有 @Operation 注解,则不记录系统日志
|
|
||||||
Operation methodOperation = handlerMethod.getMethodAnnotation(Operation.class);
|
Operation methodOperation = handlerMethod.getMethodAnnotation(Operation.class);
|
||||||
if (methodLog == null && methodOperation == null) {
|
if (methodLog == null && methodOperation == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// 3.2 请求方式不要求记录且接口方法上没有 @Log 注解,则不记录系统日志
|
||||||
|
if (methodLog == null && operationLogProperties.getExcludeMethods().contains(request.getMethod())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// 3.3 如果接口被隐藏,不记录系统日志
|
// 3.3 如果接口被隐藏,不记录系统日志
|
||||||
if (methodOperation != null && methodOperation.hidden()) {
|
if (methodOperation != null && methodOperation.hidden()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 3.4 如果接口方法上有 @Log 注解,但是要求忽略该接口,则不记录系统日志
|
// 3.4 如果接口方法或类上有 @Log 注解,但是要求忽略该接口,则不记录系统日志
|
||||||
return methodLog == null || !methodLog.ignore();
|
if (methodLog != null && methodLog.ignore()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Log classLog = handlerMethod.getBeanType().getDeclaredAnnotation(Log.class);
|
||||||
|
return classLog == null || !classLog.ignore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user