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.turbo;
015
016import org.slf4j.Marker;
017
018import ch.qos.logback.classic.Level;
019import ch.qos.logback.classic.Logger;
020import ch.qos.logback.core.spi.ContextAwareBase;
021import ch.qos.logback.core.spi.FilterReply;
022import ch.qos.logback.core.spi.LifeCycle;
023
024/**
025 * TurboFilter is a specialized filter with a decide method that takes a bunch 
026 * of parameters instead of a single event object. The latter is cleaner but 
027 * the first is much more performant.
028 * <p>
029 * For more information about turbo filters, please refer to the online manual at
030 * http://logback.qos.ch/manual/filters.html#TurboFilter
031 * 
032 * @author Ceki Gulcu
033 */
034public abstract class TurboFilter extends ContextAwareBase implements LifeCycle {
035
036    private String name;
037    boolean start = false;
038
039    /**
040     * Make a decision based on the multiple parameters passed as arguments.
041     * The returned value should be one of <code>{@link FilterReply#DENY}</code>, 
042     * <code>{@link FilterReply#NEUTRAL}</code>, or <code>{@link FilterReply#ACCEPT}</code>.
043    
044     * @param marker
045     * @param logger
046     * @param level
047     * @param format
048     * @param params
049     * @param t
050     * @return
051     */
052    public abstract FilterReply decide(Marker marker, Logger logger, Level level, String format, Object[] params, Throwable t);
053
054    public void start() {
055        this.start = true;
056    }
057
058    public boolean isStarted() {
059        return this.start;
060    }
061
062    public void stop() {
063        this.start = false;
064    }
065
066    public String getName() {
067        return name;
068    }
069
070    public void setName(String name) {
071        this.name = name;
072    }
073}