001/**
002 * Logback: the reliable, generic, fast and flexible logging framework.
003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
004 *
005 * This program and the accompanying materials are dual-licensed under
006 * either the terms of the Eclipse Public License v1.0 as published by
007 * the Eclipse Foundation
008 *
009 *   or (per the licensee's choosing)
010 *
011 * under the terms of the GNU Lesser General Public License version 2.1
012 * as published by the Free Software Foundation.
013 */
014package ch.qos.logback.classic.spi;
015
016import ch.qos.logback.classic.Level;
017import ch.qos.logback.classic.Logger;
018import ch.qos.logback.classic.LoggerContext;
019
020public class BasicContextListener implements LoggerContextListener {
021
022    enum UpdateType {
023        NONE, START, RESET, STOP, LEVEL_CHANGE
024    };
025
026    UpdateType updateType = UpdateType.NONE;
027    LoggerContext context;
028    Logger logger;
029    Level level;
030
031    boolean resetResistant;
032
033    public void setResetResistant(boolean resetResistant) {
034        this.resetResistant = resetResistant;
035    }
036
037    public void onReset(LoggerContext context) {
038        updateType = UpdateType.RESET;
039        this.context = context;
040
041    }
042
043    public void onStart(LoggerContext context) {
044        updateType = UpdateType.START;
045        ;
046        this.context = context;
047    }
048
049    public void onStop(LoggerContext context) {
050        updateType = UpdateType.STOP;
051        ;
052        this.context = context;
053    }
054
055    public boolean isResetResistant() {
056        return resetResistant;
057    }
058
059    public void onLevelChange(Logger logger, Level level) {
060        updateType = UpdateType.LEVEL_CHANGE;
061        this.logger = logger;
062        this.level = level;
063    }
064
065}