java.lang.Object
com.dua3.utility.logging.DefaultLogEntryFilter
- All Implemented Interfaces:
LogEntryFilter,Predicate<LogEntry>
The DefaultLogEntryFilter class is an implementation of the LogEntryFilter interface
that filters log entries based on their log level and a user-defined filter.
DefaultLogEntryFilter provides methods to set and retrieve the log level and filter, as well as a test method to determine if a LogEntry should be included or excluded.
-
Field Summary
Fields inherited from interface com.dua3.utility.logging.LogEntryFilter
ALL_PASS_FILTER -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new DefaultLogEntryFilter withLogLevel.TRACEas the default log level and a looger name and message filters that let all log entries pass.DefaultLogEntryFilter(LogLevel level, BiPredicate<String, LogLevel> filterLoggerName, BiPredicate<String, LogLevel> filterText) Constructs a new DefaultLogEntryFilter with the specified log level and filter. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a copy of the DefaultLogEntryFilter with the same log level and filter.Retrieves the filter used to determine if a log entry should be included or excluded based on the logger name.Retrieves the filter used to determine if a log entry should be included or excluded based on the logger name.getLevel()Retrieves the log level of the DefaultLogEntryFilter.voidsetFilterLoggerName(BiPredicate<String, LogLevel> filterLoggerName) Sets the logger name filterLoggerName of the DefaultLogEntryFilter.voidsetFilterText(BiPredicate<String, LogLevel> filterText) Sets the message filterText of the DefaultLogEntryFilter.voidSets the log level of the DefaultLogEntryFilter.booleanTest if aLogEntryshould be processed.withFilterLoggerName(BiPredicate<String, LogLevel> newFilter) Returns a new {code DefaultLogEntryFilter} with the same log level and the specified logger name filter.withFilterText(BiPredicate<String, LogLevel> newFilter) Returns a new {code DefaultLogEntryFilter} with the same log level and the specified message filter.Returns a new DefaultLogEntryFilter with the same filter and the specified log level.
-
Constructor Details
-
DefaultLogEntryFilter
public DefaultLogEntryFilter()Constructs a new DefaultLogEntryFilter withLogLevel.TRACEas the default log level and a looger name and message filters that let all log entries pass. -
DefaultLogEntryFilter
public DefaultLogEntryFilter(LogLevel level, BiPredicate<String, LogLevel> filterLoggerName, BiPredicate<String, LogLevel> filterText) Constructs a new DefaultLogEntryFilter with the specified log level and filter.- Parameters:
level- the log level to setfilterLoggerName- the filter to set for the logger namefilterText- the filter to set for the message content
-
-
Method Details
-
setLevel
Sets the log level of the DefaultLogEntryFilter.- Parameters:
level- the log level to set
-
getLevel
Retrieves the log level of the DefaultLogEntryFilter.- Returns:
- The log level of the DefaultLogEntryFilter.
-
setFilterLoggerName
Sets the logger name filterLoggerName of the DefaultLogEntryFilter.- Parameters:
filterLoggerName- ABiPredicatethat takes a logger name and a log level as input and returns a boolean indicating whether the log entry should be filtered or not. The first argument is the logger name, and the second argument is the log level. Returns true if the log entry should be included, false otherwise.
-
getFilterLoggerName
Retrieves the filter used to determine if a log entry should be included or excluded based on the logger name.- Returns:
- The filter used to determine if a log entry should be included or excluded based on the logger name.
- See Also:
-
setFilterText
Sets the message filterText of the DefaultLogEntryFilter.- Parameters:
filterText- ABiPredicatethat takes a log message and a log level as input and returns a boolean indicating whether the log entry should be filtered or not. The first argument is the message text, and the second argument is the log level. Returns true if the log entry should be included, false otherwise.
-
getFilterText
Retrieves the filter used to determine if a log entry should be included or excluded based on the logger name.- Returns:
- The filter used to determine if a log entry should be included or excluded based on the logger name.
- See Also:
-
test
Description copied from interface:LogEntryFilterTest if aLogEntryshould be processed.- Specified by:
testin interfaceLogEntryFilter- Specified by:
testin interfacePredicate<LogEntry>- Parameters:
logEntry- the input argument- Returns:
true, if thelogEntryshould be processed,falseif it should be filtered out
-
copy
Creates a copy of the DefaultLogEntryFilter with the same log level and filter.- Returns:
- A new {code DefaultLogEntryFilter} instance with the same log level and filter.
-
withLevel
Returns a new DefaultLogEntryFilter with the same filter and the specified log level.- Parameters:
newLevel- the log level to set- Returns:
- a new {code DefaultLogEntryFilter} instance with the specified log level
-
withFilterLoggerName
Returns a new {code DefaultLogEntryFilter} with the same log level and the specified logger name filter.- Parameters:
newFilter- the new filter to set- Returns:
- a new instance of {code DefaultLogEntryFilter} with the specified filter
-
withFilterText
Returns a new {code DefaultLogEntryFilter} with the same log level and the specified message filter.- Parameters:
newFilter- the new filter to set- Returns:
- a new instance of {code DefaultLogEntryFilter} with the specified filter
-