bb.util.logging
Class FilterMsgSuppress

java.lang.Object
  extended by bb.util.logging.FilterMsgSuppress
All Implemented Interfaces:
Filter

public class FilterMsgSuppress
extends Object
implements Filter

Filter implementation which rejects LogRecords if their message contains a known bad substring.

Note that the only state, msgsSuppressed, is a static field, and therefore shared by all instances. This behavior was chosen because there was a need, when this class was first written, to have the same substring filter apply to several different Handlers (the HandlerConsole and HandlerGui instances which are usually attached to the root Logger; see this project's logging.properties file for example configuration).

One way that a user can configure this class is via DialogMsgSuppress.

This class is multithread safe: its only state, msgsSuppressed, is a multithread safe type.

Author:
Brent Boyer

Field Summary
private static Set<String> msgsSuppressed
          Stores all the message substrings which identify messages to be suppressed.
 
Constructor Summary
FilterMsgSuppress()
           
 
Method Summary
 boolean isLoggable(LogRecord record)
          First gets record's raw message, that is, before localization or formatting.
static void suppressMsg(String msg)
          Adds msg to msgsSuppressed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

msgsSuppressed

private static final Set<String> msgsSuppressed
Stores all the message substrings which identify messages to be suppressed.

Contract: is never null, and must be a multithread safe type.

Constructor Detail

FilterMsgSuppress

public FilterMsgSuppress()
Method Detail

suppressMsg

public static void suppressMsg(String msg)
                        throws IllegalArgumentException
Adds msg to msgsSuppressed.

Throws:
IllegalArgumentException - if msg is blank

isLoggable

public boolean isLoggable(LogRecord record)
                   throws IllegalArgumentException
First gets record's raw message, that is, before localization or formatting. Immediately returns true if that message is blank. Else, searches thru every element of msgsSuppressed, returning false if message contains any element as a substring.

Specified by:
isLoggable in interface Filter
Throws:
IllegalArgumentException - if record == null