1 /** 2 * Logback: the reliable, generic, fast and flexible logging framework. 3 * Copyright (C) 1999-2015, QOS.ch. All rights reserved. 4 * 5 * This program and the accompanying materials are dual-licensed under 6 * either the terms of the Eclipse Public License v1.0 as published by 7 * the Eclipse Foundation 8 * 9 * or (per the licensee's choosing) 10 * 11 * under the terms of the GNU Lesser General Public License version 2.1 12 * as published by the Free Software Foundation. 13 */ 14 package ch.qos.logback.core.filter; 15 16 import ch.qos.logback.core.spi.ContextAwareBase; 17 import ch.qos.logback.core.spi.FilterReply; 18 import ch.qos.logback.core.spi.LifeCycle; 19 20 /** 21 * Users should extend this class to implement customized event filtering. 22 * 23 * <p> 24 * We suggest that you first try to use the built-in rules before rushing to 25 * write your own custom filters. 26 * 27 * <p> 28 * For more information about filters, please refer to the online manual at 29 * http://logback.qos.ch/manual/filters.html 30 * 31 * @author Ceki Gülcü 32 */ 33 public abstract class Filter<E> extends ContextAwareBase implements LifeCycle { 34 35 private String name; 36 37 boolean start = false; 38 39 public void start() { 40 this.start = true; 41 } 42 43 public boolean isStarted() { 44 return this.start; 45 } 46 47 public void stop() { 48 this.start = false; 49 } 50 51 /** 52 * If the decision is <code>{@link FilterReply#DENY}</code>, then the event will 53 * be dropped. If the decision is <code>{@link FilterReply#NEUTRAL}</code>, then 54 * the next filter, if any, will be invoked. If the decision is 55 * <code>{@link FilterReply#ACCEPT}</code> then the event will be logged without 56 * consulting with other filters in the chain. 57 * 58 * @param event The event to decide upon. 59 */ 60 public abstract FilterReply decide(E event); 61 62 public String getName() { 63 return name; 64 } 65 66 public void setName(String name) { 67 this.name = name; 68 } 69 }