The Drupal 6 version of rules has the ability to create a watchdog entry, this functionality is not present in the D7 release.

Files: 
CommentFileSizeAuthor
#9 0001-added-description-properties-1349882-9.patch2.38 KBpluess
PASSED: [[SimpleTest]]: [MySQL] 351 pass(es).
[ View ]
#6 1349882-6-action_create_watchdog_entry.patch2.02 KBmitchell
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1349882-6-action_create_watchdog_entry.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#4 add-watchdog-action-1349882-4.patch1.76 KBwjaspers
PASSED: [[SimpleTest]]: [MySQL] 327 pass(es).
[ View ]
#1 add-watchdog-action-1349882-1.patch1.68 KBwillvincent
PASSED: [[SimpleTest]]: [MySQL] 251 pass(es).
[ View ]

Comments

Status:Active» Needs review
StatusFileSize
new1.68 KB
PASSED: [[SimpleTest]]: [MySQL] 251 pass(es).
[ View ]

Here's a patch that adds this functionality to the available rules system actions.

This was useful, thanks.

Severity and link should probably both be optional, i.e.

        'severity' => array(
          'type' => 'integer',
          'label' => t('Severity'),
          'options list' => 'watchdog_severity_levels',
          'optional' => TRUE,
        ),
        'link' => array(
          'type' => 'text',
          'label' => t('An associated, HTML formatted link'),
          'optional' => TRUE,
        ),
And be NULL arguments by default:

/**
* Action: Create a watchdog entry.
*/
function rules_action_watchdog($type, $message, $severity = NULL, $link = NULL) {
  ...
}

Title:Add a watchdog action for D7Action: Create a watchdog entry
Component:Provided Rules integration» Rules Engine
Status:Needs review» Needs work

Per #2.

Status:Needs work» Needs review
StatusFileSize
new1.76 KB
PASSED: [[SimpleTest]]: [MySQL] 327 pass(es).
[ View ]

Actually, the severity is required. It defaults to the notice severity, WATCHDOG_NOTICE.
For reference: http://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/watch...

Here's an updated patch.

EDIT: Updated comment to re-issue test request.

It is not required on the form - hence the addition of the 'optional' attribute.

Component:Rules Engine» Rules Core
Priority:Normal» Major
Status:Needs review» Needs work
StatusFileSize
new2.02 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1349882-6-action_create_watchdog_entry.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

#4 works.

It would be better to use description fields for the text currently in the labels. I tried to edit #4 directly to fix that, but the resulting patch I'm uploading is malformed. Please update #4 soon so we can get this committed.

git apply returns
fatal: corrupt patch at line 63
for the patch of #6

^ "the resulting patch I'm uploading is malformed"
My notes and patch in #6 go with the needs review > needs work change. If you'd like to help roll a patch, I'd appreciate the help.

Use #4 if you need this now.

Status:Needs work» Needs review
StatusFileSize
new2.38 KB
PASSED: [[SimpleTest]]: [MySQL] 351 pass(es).
[ View ]

Sorry, I didn't read your notes carfully. Please find a new patch attached including your changes.

And thanks for the new action. It does what it's supposed to do: Add watchdog entries.

I've just tested this patch, and it does what it says on the tin...

Status:Needs review» Reviewed & tested by the community

#9, #10: Awesome.

Status:Reviewed & tested by the community» Needs work

This action should use only one parameter with the data type "log_entry". Same as the watchdog event uses.

I think @klausi is saying that the action here should reuse _rules_system_watchdog_log_entry_info(). @previous-patch-submitters, please provide a new patch based on this provided data type?

Status:Needs work» Postponed

I started to work on this based on #12, but then realized there were more advantages to solving this in Entity API. Therefore, I propose we resolve this in #1714486: Add wrappers for watchdog's log entries. (Changing status to follow up there.)

@fago, I believe in #682722: What other modules can be candiadte for entity API, you said that this approach was "questionable" but not undesirable, and I think I've described some reasonable benefits.

I'm still progressing with php, so this patch was giving me some trouble, but I'd be happy to try again. If anyone with more experienced has the interest in getting this done, I would appreciate your efforts greatly.

+1

Status:Postponed» Reviewed & tested by the community

Seems to me like the bigger issue of using entity API to wrapper the watchdog isn't getting solved any time soon. I'd say that we should commit the patch in #9 now.

Priority:Major» Normal

... But not with "major" priority

I'm using it and it works for me too.
As Angry Dan I'm in doubt about getting entity-wrapped log entry soon - so I support the suggestion to commit this patch.

Better Watchdog UI (formerly Watchdog Entity) would only need small changes to complete the entity wrapping. See #2040213: Rules Watchdog Integration.

Status:Reviewed & tested by the community» Needs work

ad #12: I think it's ok to go without the data structure as the creating the data structure first would just pose UX problems without giving any extra functionality or features.

The patch looks good (did not test it though). It misses test coverage though - we should test it in the Rules core integration test case, where all other system actions are tested. E.g. execute the action and make sure the watchdog entry has been written.

Also, what about replacements? Replacements are the only way to create proper translatable watchdog entries so we should support providing them. E.g. just add two list parameter for replacement keys and values? The nicer variant would be probably making a message module - watchdog bridge but that's another story.

Status:Needs work» Needs review