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 filter that lets all log entries pass.DefaultLogEntryFilter(LogLevel level, BiPredicate<String, LogLevel> filter) 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.getLevel()Retrieves the log level of the DefaultLogEntryFilter.voidsetFilter(BiPredicate<String, LogLevel> filter) Sets the filter of the DefaultLogEntryFilter.voidSets the log level of the DefaultLogEntryFilter.booleanTest if aLogEntryshould be processed.withFilter(BiPredicate<String, LogLevel> newFilter) Returns a new {code DefaultLogEntryFilter} with the same log level and the specified 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 filter that lets all log entries pass. -
DefaultLogEntryFilter
Constructs a new DefaultLogEntryFilter with the specified log level and filter.- Parameters:
level- the log level to setfilter- the filter to set
-
-
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.
-
setFilter
Sets the filter of the DefaultLogEntryFilter.- Parameters:
filter- 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.
-
getFilter
Retrieves the filter used to determine if a log entry should be included or excluded.- Returns:
- The filter used to determine if a log entry should be included or excluded.
- 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
-
withFilter
Returns a new {code DefaultLogEntryFilter} with the same log level and the specified filter.- Parameters:
newFilter- the new filter to set- Returns:
- a new instance of {code DefaultLogEntryFilter} with the specified filter
-