Class LoggingRuleListener
java.lang.Object
cloud.opencode.base.rules.listener.LoggingRuleListener
- All Implemented Interfaces:
RuleListener
Logging Rule Listener - Logs Rule Execution Events
日志规则监听器 - 记录规则执行事件
Logs rule execution lifecycle events using JUL (java.util.logging).
使用JUL(java.util.logging)记录规则执行生命周期事件。
Features | 主要功能:
- JUL-based logging - 基于JUL的日志记录
- Evaluation and execution event logging - 评估和执行事件日志
- Failure logging with stack trace - 带堆栈跟踪的失败日志
Usage Examples | 使用示例:
engine.addListener(new LoggingRuleListener());
Security | 安全性:
- Thread-safe: Yes (stateless, logger is thread-safe) - 线程安全: 是(无状态,日志器是线程安全的)
- Null-safe: No (rule and context must not be null) - 空值安全: 否(规则和上下文不能为null)
- Since:
- JDK 25, opencode-base-rules V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterEvaluate(Rule rule, RuleContext context, boolean satisfied) Called after a rule is evaluated 在规则评估后调用voidafterExecute(Rule rule, RuleContext context) Called after a rule is executed successfully 在规则成功执行后调用voidbeforeEvaluate(Rule rule, RuleContext context) Called before a rule is evaluated 在规则评估前调用voidbeforeExecute(Rule rule, RuleContext context) Called before a rule is executed 在规则执行前调用voidonFailure(Rule rule, RuleContext context, Exception exception) Called when a rule execution fails 当规则执行失败时调用voidonFinish(RuleContext context, int firedCount, long elapsedMillis) Called when rule engine finishes firing 当规则引擎完成触发时调用voidonStart(RuleContext context) Called when rule engine starts firing 当规则引擎开始触发时调用
-
Constructor Details
-
LoggingRuleListener
public LoggingRuleListener()
-
-
Method Details
-
beforeEvaluate
Description copied from interface:RuleListenerCalled before a rule is evaluated 在规则评估前调用- Specified by:
beforeEvaluatein interfaceRuleListener- Parameters:
rule- the rule | 规则context- the context | 上下文
-
afterEvaluate
Description copied from interface:RuleListenerCalled after a rule is evaluated 在规则评估后调用- Specified by:
afterEvaluatein interfaceRuleListener- Parameters:
rule- the rule | 规则context- the context | 上下文satisfied- whether the condition was satisfied | 条件是否满足
-
beforeExecute
Description copied from interface:RuleListenerCalled before a rule is executed 在规则执行前调用- Specified by:
beforeExecutein interfaceRuleListener- Parameters:
rule- the rule | 规则context- the context | 上下文
-
afterExecute
Description copied from interface:RuleListenerCalled after a rule is executed successfully 在规则成功执行后调用- Specified by:
afterExecutein interfaceRuleListener- Parameters:
rule- the rule | 规则context- the context | 上下文
-
onFailure
Description copied from interface:RuleListenerCalled when a rule execution fails 当规则执行失败时调用- Specified by:
onFailurein interfaceRuleListener- Parameters:
rule- the rule | 规则context- the context | 上下文exception- the exception | 异常
-
onStart
Description copied from interface:RuleListenerCalled when rule engine starts firing 当规则引擎开始触发时调用- Specified by:
onStartin interfaceRuleListener- Parameters:
context- the context | 上下文
-
onFinish
Description copied from interface:RuleListenerCalled when rule engine finishes firing 当规则引擎完成触发时调用- Specified by:
onFinishin interfaceRuleListener- Parameters:
context- the context | 上下文firedCount- number of rules fired | 触发的规则数量elapsedMillis- execution time in milliseconds | 执行时间(毫秒)
-