package com.starry.common.config;

import com.starry.common.interceptor.RequestLoggingInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 日志记录配置类
 * 配置请求日志拦截器
 *
 * 注意：CorrelationFilter已移至play-admin模块，通过@Component自动注册
 *
 * @author Claude
 */
@Configuration
public class LoggingConfig implements WebMvcConfigurer {

    @Autowired
    private RequestLoggingInterceptor requestLoggingInterceptor;

    /**
     * 添加请求日志拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(requestLoggingInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(
                        "/static/**",
                        "/webjars/**",
                        "/swagger-resources/**",
                        "/v2/api-docs/**",
                        "/swagger-ui.html/**",
                        "/doc.html/**",
                        "/error",
                        "/favicon.ico"
                );
    }
}
