Class LoggingRuleListener

java.lang.Object
cloud.opencode.base.rules.listener.LoggingRuleListener
All Implemented Interfaces:
RuleListener

public class LoggingRuleListener extends Object implements 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 Details

    • LoggingRuleListener

      public LoggingRuleListener()
  • Method Details

    • beforeEvaluate

      public void beforeEvaluate(Rule rule, RuleContext context)
      Description copied from interface: RuleListener
      Called before a rule is evaluated 在规则评估前调用
      Specified by:
      beforeEvaluate in interface RuleListener
      Parameters:
      rule - the rule | 规则
      context - the context | 上下文
    • afterEvaluate

      public void afterEvaluate(Rule rule, RuleContext context, boolean satisfied)
      Description copied from interface: RuleListener
      Called after a rule is evaluated 在规则评估后调用
      Specified by:
      afterEvaluate in interface RuleListener
      Parameters:
      rule - the rule | 规则
      context - the context | 上下文
      satisfied - whether the condition was satisfied | 条件是否满足
    • beforeExecute

      public void beforeExecute(Rule rule, RuleContext context)
      Description copied from interface: RuleListener
      Called before a rule is executed 在规则执行前调用
      Specified by:
      beforeExecute in interface RuleListener
      Parameters:
      rule - the rule | 规则
      context - the context | 上下文
    • afterExecute

      public void afterExecute(Rule rule, RuleContext context)
      Description copied from interface: RuleListener
      Called after a rule is executed successfully 在规则成功执行后调用
      Specified by:
      afterExecute in interface RuleListener
      Parameters:
      rule - the rule | 规则
      context - the context | 上下文
    • onFailure

      public void onFailure(Rule rule, RuleContext context, Exception exception)
      Description copied from interface: RuleListener
      Called when a rule execution fails 当规则执行失败时调用
      Specified by:
      onFailure in interface RuleListener
      Parameters:
      rule - the rule | 规则
      context - the context | 上下文
      exception - the exception | 异常
    • onStart

      public void onStart(RuleContext context)
      Description copied from interface: RuleListener
      Called when rule engine starts firing 当规则引擎开始触发时调用
      Specified by:
      onStart in interface RuleListener
      Parameters:
      context - the context | 上下文
    • onFinish

      public void onFinish(RuleContext context, int firedCount, long elapsedMillis)
      Description copied from interface: RuleListener
      Called when rule engine finishes firing 当规则引擎完成触发时调用
      Specified by:
      onFinish in interface RuleListener
      Parameters:
      context - the context | 上下文
      firedCount - number of rules fired | 触发的规则数量
      elapsedMillis - execution time in milliseconds | 执行时间(毫秒)