mirror of
				https://github.com/continew-org/continew-starter.git
				synced 2025-10-30 23:00:11 +08:00 
			
		
		
		
	refactor(log): 优化日志拦截器配置
This commit is contained in:
		| @@ -26,6 +26,7 @@ import org.springframework.context.annotation.Bean; | |||||||
| import org.springframework.context.annotation.Configuration; | import org.springframework.context.annotation.Configuration; | ||||||
| import org.springframework.web.servlet.config.annotation.InterceptorRegistry; | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; | ||||||
| import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||||||
|  | import top.continew.starter.core.constant.StringConstants; | ||||||
| import top.continew.starter.log.annotation.ConditionalOnEnabledLog; | import top.continew.starter.log.annotation.ConditionalOnEnabledLog; | ||||||
| import top.continew.starter.log.dao.LogDao; | import top.continew.starter.log.dao.LogDao; | ||||||
| import top.continew.starter.log.dao.impl.DefaultLogDaoImpl; | import top.continew.starter.log.dao.impl.DefaultLogDaoImpl; | ||||||
| @@ -56,7 +57,9 @@ public class LogAutoConfiguration implements WebMvcConfigurer { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void addInterceptors(InterceptorRegistry registry) { |     public void addInterceptors(InterceptorRegistry registry) { | ||||||
|         registry.addInterceptor(new LogInterceptor(logProperties, logHandler(), logDao())); |         registry.addInterceptor(new LogInterceptor(logProperties, logHandler(), logDao())) | ||||||
|  |             .addPathPatterns(StringConstants.PATH_PATTERN) | ||||||
|  |             .excludePathPatterns(logProperties.getExcludePatterns()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -109,10 +109,6 @@ public class LogInterceptor implements HandlerInterceptor { | |||||||
|         if (!(handler instanceof HandlerMethod handlerMethod)) { |         if (!(handler instanceof HandlerMethod handlerMethod)) { | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|         // 如果接口匹配排除列表,不记录日志 |  | ||||||
|         if (logProperties.isMatch(request.getRequestURI())) { |  | ||||||
|             return false; |  | ||||||
|         } |  | ||||||
|         // 如果接口被隐藏,不记录日志 |         // 如果接口被隐藏,不记录日志 | ||||||
|         Operation methodOperation = handlerMethod.getMethodAnnotation(Operation.class); |         Operation methodOperation = handlerMethod.getMethodAnnotation(Operation.class); | ||||||
|         if (null != methodOperation && methodOperation.hidden()) { |         if (null != methodOperation && methodOperation.hidden()) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user