Interface LogFilter
- All Known Implementing Classes:
LevelFilter, MarkerFilter, ThrottleFilter
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Log Filter Interface - Functional Filter for Log Events
日志过滤器接口 - 日志事件的函数式过滤器
A functional interface that evaluates a LogEvent and returns a
FilterAction indicating whether the event should be accepted, denied,
or passed to the next filter.
一个函数式接口,评估 LogEvent 并返回 FilterAction,
指示事件应被接受、拒绝还是传递给下一个过滤器。
Features | 主要功能:
- Functional interface for lambda-based filters - 函数式接口支持 Lambda 过滤器
- Ordered evaluation via getOrder() - 通过 getOrder() 进行有序评估
- Three-state filter result (ACCEPT/DENY/NEUTRAL) - 三态过滤结果
Usage Examples | 使用示例:
// Lambda-based filter
LogFilter filter = event -> event.level().getLevel() >= LogLevel.WARN.getLevel()
? FilterAction.ACCEPT : FilterAction.NEUTRAL;
// With custom order
LogFilter priorityFilter = new LogFilter() {
public FilterAction filter(LogEvent event) { return FilterAction.NEUTRAL; }
public int getOrder() { return -10; } // higher priority
};
Security | 安全性:
- Thread-safe: Implementation-dependent - 线程安全: 取决于实现
- Since:
- JDK 25, opencode-base-log V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionEvaluates the given log event and returns a filter action.default intgetOrder()Returns the order of this filter.
-
Method Details
-
filter
Evaluates the given log event and returns a filter action. 评估给定的日志事件并返回过滤器动作。- Parameters:
event- the log event to evaluate | 要评估的日志事件- Returns:
- the filter action | 过滤器动作
-
getOrder
default int getOrder()Returns the order of this filter. Lower values indicate higher priority. 返回此过滤器的顺序。较低的值表示较高的优先级。- Returns:
- the order value (default 0) | 顺序值(默认 0)
-