Software engineer, data guy, Open Source enthusiast, New Hampshire resident, husband, father. Fan of guitars, hiking, photography, homebrewing, sarcasm.
Drupal 6: Creating a module to email severe log entries to users
In this code snippet I’ll explain how you can create a module that emails log entries of a defined severity to a list of users.
The first step is to create an admin setting page that allows the admin to define the email recipients.
The above code creates an admin setting page that allows the admin to define the recipients list, and implements validation to ensure the email addresses exist and are valid.
The next two functions implement hook_mail() and hook_watchdog() to check the severity of the log entry, compose the email message, and send it.
Now when log entries are created that match the defined severity, they are emailed to the recipient list.