public class LogFilter extends Object implements LogListener
LogListener
that filters out and passes through certain categories of
log messages to another LogListener
. When you construct this listener,
you pass a boolean flag that indicates its pass-through mode: if true, it passes log
messages by default and filters out specified categories; if false, it filters out
messages by default and passes through specified categories.
Note that this filter only affects events sent to LogListener.messageLogged(org.apache.oodt.commons.io.LogEvent)
.
Events sent to LogListener.streamStarted(org.apache.oodt.commons.io.LogEvent)
and LogListener.streamStopped(org.apache.oodt.commons.io.LogEvent)
are passed through regardless.
Categories used by this filter should implement their Object.hashCode()
and
Object.equals(java.lang.Object)
methods.
Log
Modifier and Type | Field and Description |
---|---|
protected Hashtable |
categories
Table of categories to filter/pass.
|
protected static Object |
DUMMY
The DUMMY value for all mappings in the
categories table. |
protected LogListener |
listener
The listener on whose behalf we filter.
|
protected boolean |
passThrough
If true, pass through by default, otherwise filter out by default.
|
Constructor and Description |
---|
LogFilter(LogListener listener,
boolean passThrough)
Create a log filter.
|
LogFilter(LogListener listener,
boolean passThrough,
Object[] categories)
Create a log filter.
|
Modifier and Type | Method and Description |
---|---|
void |
addCategory(Object category)
Add an additional category.
|
void |
messageLogged(LogEvent event)
Filter the event, and possibly pass it onto the registered listener.
|
void |
propertyChange(PropertyChangeEvent ignore)
Ignore this event.
|
void |
removeCategory(Object category)
Remove a category.
|
void |
streamStarted(LogEvent event)
Pass on the event unmodified to the registered listener.
|
void |
streamStopped(LogEvent event)
Pass on the event unmodified to the registered listener.
|
protected boolean passThrough
protected Hashtable categories
protected static final Object DUMMY
categories
table.protected LogListener listener
public LogFilter(LogListener listener, boolean passThrough, Object[] categories)
listener
- What object will get filtered log messages.passThrough
- If true, pass messages through by default and filter out the
specified categories of messages. If false, filter out messages by
default and pass through the specified categories.categories
- Categories of messages to filter out (if
passThrough is true) or to pass through (if passThrough
is false).public LogFilter(LogListener listener, boolean passThrough)
listener
- What object will get filtered log messages.passThrough
- If true, pass messages through by default. If false, filter out messages by default.public void addCategory(Object category)
category
- The category to add.public void removeCategory(Object category)
category
- The category to remove.public void streamStarted(LogEvent event)
streamStarted
in interface LogListener
event
- The event to pass.public void streamStopped(LogEvent event)
streamStopped
in interface LogListener
event
- The event to pass.public void messageLogged(LogEvent event)
messageLogged
in interface LogListener
event
- The event to filter.public void propertyChange(PropertyChangeEvent ignore)
propertyChange
in interface PropertyChangeListener
Copyright © 1999-2015 Apache OODT. All Rights Reserved.