How to determine when a rule or rule_set is executed or evaluated?

Events happening in the community are now at Drupal community events on www.drupal.org.
drecute's picture

Hello,

I want to be able to determine when exactly a rule_set or rule has been executed successfully. I have looked vividly at the entire Rules code and I can't just find what I need. The only implementation that gave me a result is rules_log_evaluation_finished(). Below is my understanding about some pretty clear Rules APIs (I hope I'm correct).

  • rules_get_items (returns info about all defined items - rules or rule set)
  • rules_gather_items (used for collecting events, rules, actions and conditions from other modules)
  • rules_rules_item_info (implementation of hook_rules_item_info)
  • rules_get_actions
  • rules_get_events
  • rules_get_rule_set
  • rules_get_rule_sets (i.e all defined events (functions) prefixed with event_)
  • rules_get_configured_items (returns configuration for rules or rule set which are stored in the db)
  • rules_get_event_sets
  • _rules_rule_is_active
  • rules_evaluate_rule_set (Evaluates the configured rules for the given rule set and evaluation state.)
  • rules_execute_rule (executes an active rule)
  • rules_invoke_rule_set
  • rules_execute_action(executes actions on a rule)
  • rules_get_execution_arguments
  • rules_execute_condition
  • rules_evaluate_rule_set
  • rules_show_log
  • rules_log_evaluated_rule (logs the evaluated rule)
  • rules_log_rule_is_evaluated (checks if the given rule is currently evaluated)
  • rules_get_element_info
  • rules_retrieve_element_info (retrieves info about an action or condition)

Again, what I want to be able to achieve is to create a log (either in watchdog or custom table) of all Rules events and rule_sets at exactly the time they are executed or evaluated. I want to do something like this:

<?php
 
foreach(rules_get_rule_sets() as $sets ) {

    if(
rules_log_rule_is_evaluated($sets)) {
     
// get it's info
      // get it's type
      // watchdog('type', 'msg');
   
}
}
?>

I am thinking if it is possible to just get what $element['#info'] is during a particular rule execution - be it #action, #conditions, this will open door for me to do what I want to achieve.

I will appreciate some help please.

Regards

Comments

This would be so helpful...

Arwym's picture

This would be so helpful...

my solution

arpas's picture

If I understand your problem correctly, there is a checkbox "Debug rule evaluation" in Rules module "Settings" page. This is only for debugging process, but helpful for me.

Rules

Group organizers

Group categories

Categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: