package com.malk.filter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.servlet.*;
import java.io.IOException;

@Component
public class RequestFilter implements Filter {

    // 指定类输出日志到指定文件夹
    private static final Logger logger = LoggerFactory.getLogger("point");

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        logger.info("过滤器 ▷ 初始化");
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        logger.trace("过滤器 ▷ 开始执行");
        chain.doFilter(request, response);
        logger.trace("过滤器 ▷ 执行结束");
    }

    @Override
    public void destroy() {
        logger.info("过滤器 ▷ 销毁");
    }
}
