svn commit: r926 - logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/turbo

Author: seb Date: Fri Nov 17 09:57:44 2006 New Revision: 926 Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/turbo/UserTurboFilter.java Log: One can now specify the key to retrieve user information from the MDC Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/turbo/UserTurboFilter.java ============================================================================== --- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/turbo/UserTurboFilter.java (original) +++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/turbo/UserTurboFilter.java Fri Nov 17 09:57:44 2006 @@ -13,6 +13,10 @@ * * When the given user is identified by this TubroFilter, * the reply is based on the OnMatch option. + * The information is taken from the MDC. By default, + * the key used to retrieve the user information is "user". + * One can optionnally set the key that will be used to + * access the user information in the MDC. * * To allow output for a user, set the OnMatch option * to ACCEPT. To disable output for the given user, set @@ -20,18 +24,20 @@ * * By default, values of the OnMatch and OnMisMatch * options are NEUTRAL. + * * * @author Ceki Gülcü * @author Sébastien Pennec */ public class UserTurboFilter extends TurboFilter { + String MDCKey = ClassicGlobal.USER_MDC_KEY; String user; @Override public FilterReply decide(Marker marker, Logger logger, Level level, String format, Object[] params, Throwable t) { - String user = MDC.get(ClassicGlobal.USER_MDC_KEY); + String user = MDC.get(MDCKey); if (this.user.equals(user)) { return onMatch; } @@ -41,5 +47,9 @@ public void setUser(String user) { this.user = user; } + + public void setMDCKey(String MDCKey) { + this.MDCKey = MDCKey; + } }
participants (1)
-
noreply.seb@qos.ch