Send email notification to administrator when 'warning' is printed
chuckienorton - February 9, 2009 - 23:42
Is there any way to send an email to an administrator when a warning is printed anywhere?
I'm in need of something like this, as our site is so big now that it's once a week that some small aspect of the site will start printing a warning on that page. My guess is that there are a lot of site administrators who would be happy about this (or maybe not! especially if there are tons of errors!).
I'd love a way to send an email to the administrator whenever a warning is printed somewhere. It'd save my butt, since I could avoid learning about warnings from site visitors!
Thanks,
Chuck

I don't know of a "Drupal
I don't know of a "Drupal way" to do this, but you can setup a custom error handler for PHP with set_error_handler(): http://ca3.php.net/set_error_handler
Put something like this in a custom module:
<?php
set_error_handler( 'MyErrorHandler' );
function MyErrorHandler( $errno, $errstr, $errfile, $errline ){
// write code to send an email here, using something like drupal_mail(), drupal_mail_send(), or the plain PHP mail() function
}
?>
Be forewarned that this error handler will get passed ALL errors, it'll be up to you to discard the ones you don't want, and/or die on fatal errors.
oh yeah!
Think I found my own sollution: http://drupal.org/project/logging_alerts.
Thanks for the feedback though! This should be included in drupal core (I would think?!).
C