public static function logError($reason, $original_error, CRM_Civirules_TriggerData_TriggerData $triggerData, $context = array()) { $logger = CRM_Civirules_Utils_LoggerFactory::getLogger(); if (empty($logger)) { return; } $error = "Rule: '{rule_title}' with id {rule_id} failed for contact {contact_id} because of {reason}"; $context['rule_id'] = $triggerData->getTrigger()->getRuleId(); $context['rule_title'] = $triggerData->getTrigger()->getRuleTitle(); $context['original_error'] = $original_error; $context['contact_id'] = $triggerData->getContactId(); $context['reason'] = $reason; $logger->error($error, $context); }
/** * This function writes a record to the log table to indicate that this rule for this trigger is triggered * * The data this function stores is required by the cron type events. * @todo: think of a better handling for cron type events * * @param CRM_Civirules_TriggerData_TriggerData $triggerData */ protected static function logRule(CRM_Civirules_TriggerData_TriggerData $triggerData) { $sql = "INSERT INTO `civirule_rule_log` (`rule_id`, `contact_id`, `log_date`) VALUES (%1, %2, NOW())"; $params[1] = array($triggerData->getTrigger()->getRuleId(), 'Integer'); $params[2] = array($triggerData->getContactId(), 'Integer'); CRM_Core_DAO::executeQuery($sql, $params); }