View Javadoc

1   package ch.qos.logback.core.filter;
2   
3   import ch.qos.logback.core.spi.ContextAwareBase;
4   import ch.qos.logback.core.spi.FilterReply;
5   import ch.qos.logback.core.spi.LifeCycle;
6   
7   /**
8    * Users should extend this class to implement customized event filtering.
9    * 
10   * <p>We suggest that you first try to use the built-in rules before rushing to
11   * write your own custom filters.
12   * 
13   * <p>For more information about filters, please refer to the online manual at
14   * http://logback.qos.ch/manual/filters.html
15   * 
16   * @author Ceki G&uuml;lc&uuml;
17   */
18  public abstract class Filter<E> extends ContextAwareBase implements LifeCycle {
19  
20    private String name;
21  
22    boolean start = false;
23  
24    public void start() {
25      this.start = true;
26    }
27  
28    public boolean isStarted() {
29      return this.start;
30    }
31  
32    public void stop() {
33      this.start = false;
34    }
35  
36    /**
37     * If the decision is <code>{@link #DENY}</code>, then the event will be
38     * dropped. If the decision is <code>{@link #NEUTRAL}</code>, then the next
39     * filter, if any, will be invoked. If the decision is
40     * <code>{@link #ACCEPT}</code> then the event will be logged without
41     * consulting with other filters in the chain.
42     * 
43     * @param event
44     *                The event to decide upon.
45     */
46    public abstract FilterReply decide(E event);
47  
48    public String getName() {
49      return name;
50    }
51  
52    public void setName(String name) {
53      this.name = name;
54    }
55  }