package com.atlassian.stash.internal.logback.web;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * Bootstrap listener for custom Logback initialization in a web environment. Delegates to {@link LogbackWebConfigurer}.
 * <p>
 * This listener should be registered before Spring's {@code ContextLoaderListener} in {@code web.xml}, when using
 * custom Logback initialisation.
 *
 * @see LogbackWebConfigurer
 */
public class LogbackConfigListener implements ServletContextListener {

    @Override
    public void contextDestroyed(ServletContextEvent event) {
        LogbackWebConfigurer.shutdownLogging(event.getServletContext());
    }

    @Override
    public void contextInitialized(ServletContextEvent event) {
        LogbackWebConfigurer.initLogging(event.getServletContext());
    }
}
