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.classic.turbo; 15 16 import org.slf4j.Marker; 17 18 import ch.qos.logback.classic.Level; 19 import ch.qos.logback.classic.Logger; 20 import ch.qos.logback.core.spi.ContextAwareBase; 21 import ch.qos.logback.core.spi.FilterReply; 22 import ch.qos.logback.core.spi.LifeCycle; 23 24 /** 25 * TurboFilter is a specialized filter with a decide method that takes a bunch 26 * of parameters instead of a single event object. The latter is cleaner but the 27 * first is much more performant. 28 * <p> 29 * For more information about turbo filters, please refer to the online manual 30 * at http://logback.qos.ch/manual/filters.html#TurboFilter 31 * 32 * @author Ceki Gulcu 33 */ 34 public abstract class TurboFilter extends ContextAwareBase implements LifeCycle { 35 36 private String name; 37 boolean start = false; 38 39 /** 40 * Make a decision based on the multiple parameters passed as arguments. The 41 * returned value should be one of <code>{@link FilterReply#DENY}</code>, 42 * <code>{@link FilterReply#NEUTRAL}</code>, or 43 * <code>{@link FilterReply#ACCEPT}</code>. 44 * 45 * @param marker 46 * @param logger 47 * @param level 48 * @param format 49 * @param params 50 * @param t 51 * @return 52 */ 53 public abstract FilterReply decide(Marker marker, Logger logger, Level level, String format, Object[] params, 54 Throwable t); 55 56 public void start() { 57 this.start = true; 58 } 59 60 public boolean isStarted() { 61 return this.start; 62 } 63 64 public void stop() { 65 this.start = false; 66 } 67 68 public String getName() { 69 return name; 70 } 71 72 public void setName(String name) { 73 this.name = name; 74 } 75 }