refactor(log): 优化复数属性命名 include -> includes

This commit is contained in:
2024-02-05 23:33:04 +08:00
parent 669ea85658
commit 2afb0b625f
4 changed files with 12 additions and 12 deletions

View File

@@ -51,12 +51,12 @@ public @interface Log {
/** /**
* 包含信息(在全局配置基础上扩展包含信息) * 包含信息(在全局配置基础上扩展包含信息)
*/ */
Include[] include() default {}; Include[] includes() default {};
/** /**
* 排除信息(在全局配置基础上减少包含信息) * 排除信息(在全局配置基础上减少包含信息)
*/ */
Include[] exclude() default {}; Include[] excludes() default {};
/** /**
* 是否忽略日志记录(用于接口方法或类上) * 是否忽略日志记录(用于接口方法或类上)

View File

@@ -45,7 +45,7 @@ public class LogProperties {
/** /**
* 包含信息 * 包含信息
*/ */
private Set<Include> include = new HashSet<>(Include.defaultIncludes()); private Set<Include> includes = new HashSet<>(Include.defaultIncludes());
public boolean isEnabled() { public boolean isEnabled() {
return enabled; return enabled;
@@ -63,11 +63,11 @@ public class LogProperties {
isPrint = print; isPrint = print;
} }
public Set<Include> getInclude() { public Set<Include> getIncludes() {
return include; return includes;
} }
public void setInclude(Set<Include> include) { public void setIncludes(Set<Include> includes) {
this.include = include; this.includes = includes;
} }
} }

View File

@@ -105,7 +105,7 @@ public class LogFilter extends OncePerRequestFilter implements Ordered {
* @return truefalse * @return truefalse
*/ */
private boolean isRequestWrapper(HttpServletRequest request) { private boolean isRequestWrapper(HttpServletRequest request) {
Set<Include> includeSet = logProperties.getInclude(); Set<Include> includeSet = logProperties.getIncludes();
return !(request instanceof ContentCachingRequestWrapper) && (includeSet return !(request instanceof ContentCachingRequestWrapper) && (includeSet
.contains(Include.REQUEST_BODY) || includeSet.contains(Include.REQUEST_PARAM)); .contains(Include.REQUEST_BODY) || includeSet.contains(Include.REQUEST_PARAM));
} }
@@ -117,7 +117,7 @@ public class LogFilter extends OncePerRequestFilter implements Ordered {
* @return truefalse * @return truefalse
*/ */
private boolean isResponseWrapper(HttpServletResponse response) { private boolean isResponseWrapper(HttpServletResponse response) {
Set<Include> includeSet = logProperties.getInclude(); Set<Include> includeSet = logProperties.getIncludes();
return !(response instanceof ContentCachingResponseWrapper) && (includeSet return !(response instanceof ContentCachingResponseWrapper) && (includeSet
.contains(Include.RESPONSE_BODY) || includeSet.contains(Include.RESPONSE_PARAM)); .contains(Include.RESPONSE_BODY) || includeSet.contains(Include.RESPONSE_PARAM));
} }

View File

@@ -117,7 +117,7 @@ public class LogInterceptor implements HandlerInterceptor {
* @return 日志包含信息 * @return 日志包含信息
*/ */
private Set<Include> getIncludes(Log methodLog, Log classLog) { private Set<Include> getIncludes(Log methodLog, Log classLog) {
Set<Include> includeSet = logProperties.getInclude(); Set<Include> includeSet = logProperties.getIncludes();
if (null != classLog) { if (null != classLog) {
this.processInclude(includeSet, classLog); this.processInclude(includeSet, classLog);
} }
@@ -134,11 +134,11 @@ public class LogInterceptor implements HandlerInterceptor {
* @param logAnnotation Log 注解 * @param logAnnotation Log 注解
*/ */
private void processInclude(Set<Include> includes, Log logAnnotation) { private void processInclude(Set<Include> includes, Log logAnnotation) {
Include[] includeArr = logAnnotation.include(); Include[] includeArr = logAnnotation.includes();
if (includeArr.length > 0) { if (includeArr.length > 0) {
includes.addAll(Set.of(includeArr)); includes.addAll(Set.of(includeArr));
} }
Include[] excludeArr = logAnnotation.exclude(); Include[] excludeArr = logAnnotation.excludes();
if (excludeArr.length > 0) { if (excludeArr.length > 0) {
includes.removeAll(Set.of(excludeArr)); includes.removeAll(Set.of(excludeArr));
} }