diff --git a/modules/system.rules.inc b/modules/system.rules.inc index fcd4f80..5cb237b 100644 --- a/modules/system.rules.inc +++ b/modules/system.rules.inc @@ -124,6 +124,44 @@ function rules_system_action_info() { 'base' => 'rules_action_drupal_message', 'access callback' => 'rules_system_integration_access', ), + 'drupal_watchdog' => array( + 'label' => t('Log a db watchdog message'), + 'group' => t('System'), + 'parameter' => array( + 'type' => array( + 'type' => 'text', + 'label' => t('Type'), + 'description' => t('Identifier for this message, displayed in the first column of the dblog.'), + ), + 'message' => array( + 'type' => 'text', + 'label' => t('Message'), + 'description' => t('The text of the message.'), + 'translatable' => TRUE, + ), + 'severity' => array( + 'type' => 'token', + 'label' => t('Severity'), + 'options list' => 'watchdog_severity_levels', + 'default value' => WATCHDOG_NOTICE, + 'optional' => TRUE, + ), + 'link_text' => array( + 'type' => 'text', + 'label' => t('Link text'), + 'description' => t('The text to display for the link (optional)'), + 'optional' => TRUE, + ), + 'link_path' => array( + 'type' => 'uri', + 'label' => t('Link path'), + 'description' => t('A Drupal path or path alias. Enter (optional) queries after "?" and (optional) anchor after "#".'), + 'optional' => TRUE, + ), + ), + 'base' => 'rules_action_drupal_watchdog', + 'access callback' => 'rules_system_integration_access', + ), 'redirect' => array( 'label' => t('Page redirect'), 'group' => t('System'), diff --git a/modules/system.eval.inc b/modules/system.eval.inc index a27225f..60ac0b2 100644 --- a/modules/system.eval.inc +++ b/modules/system.eval.inc @@ -16,6 +16,20 @@ function rules_action_drupal_message($message, $status, $repeat) { } /** + * Action: Write a watchdog db log message. + */ +function rules_action_drupal_watchdog($type, $message, $severity, $link_text, $link_path) { + if (!empty($link_path)) { + // Use $link_path for the text if no specific text was supplied. + $link = l(!empty($link_text) ? $link_text : $link_path, url($link_path)); + } + else { + $link = NULL; + } + watchdog($type, $message, array(), $severity, $link); +} + +/** * Action: Page redirect. * * @see rules_page_build()