de.qfs.lib.log
Class LevelFilter
java.lang.Object
|
+--de.qfs.lib.log.AbstractLogUser
|
+--de.qfs.lib.log.LevelFilter
- All Implemented Interfaces:
- LogFilter, LogUser
- public class LevelFilter
- extends AbstractLogUser
A simple LogFilter
that filters messages based on their
level.
It considers all messages with a level less than or equal to the given
maximum as useful. If a LogWriter
has been set, all
useful messages will be written to it. By setting the maximum level to a
value < 0, filtering can be turned off, so all messages are passed to the
writer.
Whether a message is passed on through the filter chain depends on whether
it is considered useful and on the mode setting as described for the LogUser
interface.
- Since:
- 0.98.0
- Version:
- $Revision: 1.2 $
- Author:
- Gregor Schmid
Method Summary |
LogEntry[] |
filter(LogEntry[] entries)
Filter an array of LogEntries, possibly writing some of them to the
LogWriter. |
int |
getLevel()
Get the level limiting the filtering and writing of messages. |
protected boolean |
isUseful(LogEntry entry)
Decide whether a log message is useful and should be passed to the log
writer. |
void |
setLevel(int level)
Set the level limiting the filtering and writing of messages. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LevelFilter
public LevelFilter(int level)
- Create a new LevelFilter with mode
FILTER_UNUSED
and no LogWriter
.
- Parameters:
level
- Only messages up to the returned level will be passed
on and possibly written to the LogWriter.
LevelFilter
public LevelFilter(int level,
LogWriter writer)
- Create a new LevelFilter with mode
FILTER_USED
.
- Parameters:
level
- Only messages up to the returned level will be passed
on and possibly written to the LogWriter.writer
- The LogWriter used to write LogEntries that pass the
filter setting.
LevelFilter
public LevelFilter(int level,
int mode,
LogWriter writer)
- Create a new LevelFilter.
- Parameters:
level
- Only messages up to the returned level will be passed
on and possibly written to the LogWriter.mode
- The LogUser
mode.writer
- The LogWriter used to write LogEntries that pass the
filter setting.
getLevel
public final int getLevel()
- Get the level limiting the filtering and writing of messages.
- Returns:
- Only messages up to the returned level will be passed on and
possibly written to the LogWriter.
setLevel
public final void setLevel(int level)
- Set the level limiting the filtering and writing of messages.
- Parameters:
level
- Only messages up to the returned level will be passed
on and possibly written to the LogWriter.
filter
public LogEntry[] filter(LogEntry[] entries)
- Filter an array of LogEntries, possibly writing some of them to the
LogWriter. This method is overridden to try some time and memory-saving
shortcuts.
- Overrides:
filter
in class AbstractLogUser
- Parameters:
entries
- The entries to filter.
isUseful
protected boolean isUseful(LogEntry entry)
- Decide whether a log message is useful and should be passed to the log
writer.
- Overrides:
isUseful
in class AbstractLogUser
- Parameters:
entry
- The LogEntry to check.- Returns:
- True if the entry's level is less than or equal to the
LevelFilter's level. It the LevelFilter's level is -1, filtering is
turned off and the result is always true.