1 /** 2 * Logback: the generic, reliable, fast and flexible logging framework. 3 * 4 * Copyright (C) 2000-2008, QOS.ch 5 * 6 * This library is free software, you can redistribute it and/or modify it under 7 * the terms of the GNU Lesser General Public License as published by the Free 8 * Software Foundation. 9 */ 10 package ch.qos.logback.classic.turbo; 11 12 import org.slf4j.Marker; 13 14 import ch.qos.logback.classic.Level; 15 import ch.qos.logback.classic.Logger; 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 * TurboFilter is a specialized filter with a decide method that takes a bunch 22 * of parameters instead of a single event object. The latter is cleaner but 23 * the latter is much more performant. 24 * <p> 25 * For more information about turbo filters, please refer to the online manual at 26 * http://logback.qos.ch/manual/filters.html#TurboFilter 27 * 28 * @author Ceki Gulcu 29 */ 30 public abstract class TurboFilter extends ContextAwareBase implements LifeCycle { 31 32 private String name; 33 boolean start = false; 34 35 36 /** 37 * Make a decision based on the multiple parameters passed as arguments. 38 * The returned value should be one of <code>{@link FilterReply#DENY}</code>, 39 * <code>{@link FilterReply#NEUTRAL}</code>, or <code>{@link FilterReply#ACCEPT}</code>. 40 41 * @param marker 42 * @param logger 43 * @param level 44 * @param format 45 * @param params 46 * @param t 47 * @return 48 */ 49 public abstract FilterReply decide(Marker marker, Logger logger, 50 Level level, String format, Object[] params, Throwable t); 51 52 public void start() { 53 this.start = true; 54 } 55 56 public boolean isStarted() { 57 return this.start; 58 } 59 60 public void stop() { 61 this.start = false; 62 } 63 64 65 public String getName() { 66 return name; 67 } 68 69 public void setName(String name) { 70 this.name = name; 71 } 72 }