We hard code a WATCHDOG_ERROR severity for all php errors, including notices. Attached patch maps error levels to our watchdog severity levels and calls watchdog with the right severity. This will lighten the load for all poor souls responsible for monitoring errors in watchdog. It also silences drush a bit.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

webchick’s picture

Status: Needs review » Needs work

Moshe tells me that this will stop drush installsite from outputting scary errors. It also seems like a decent improvement, in any case.

+++ includes/common.inc
@@ -1035,6 +1035,34 @@ function drupal_http_request($url, array $options = array()) {
+/*
+ * Map PHP error constants to watchdog severity levels. The error constants are
+ * documented at http://php.net/manual/en/errorfunc.constants.php
+ */

The first line should be /** instead of /*, or else the docs won't show up on api.drupal.org.

Also, for maximum pedanticness, the first line of the description should be <= 80 chars, with everything else on the following.

+++ includes/common.inc
@@ -1035,6 +1035,34 @@ function drupal_http_request($url, array $options = array()) {
+    E_STRICT => array('Strict warning', WATCHDOG_WARNING),

E_STRICT are the least error-y of all of them, so I'd make this one WATCHDOG_NOTICE, personally.

"Enable to have PHP suggest changes to your code which will ensure the best interoperability and forward compatibility of your code."

+++ includes/common.inc
@@ -1035,6 +1035,34 @@ function drupal_http_request($url, array $options = array()) {
+    $types[E_DEPRECATED] = array('Deprecated function', WATCHDOG_DEBUG);
+    $types[E_USER_DEPRECATED] = array('User deprecated function', WATCHDOG_DEBUG);

Debug? Not notice? If using debug here means "Not at all important in the grand scheme of things", then probably E_STRICT should be debug as well.

Powered by Dreditor.

moshe weitzman’s picture

Status: Needs work » Needs review
FileSize
3.62 KB

Nice catch on E_STRICT. i made that 'debug' severity as well. Doxygen as well.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Implemented all suggestions by webchick, so lets push it back to her.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Cool, thanks!

Committed to HEAD.

asimmonds’s picture

Status: Fixed » Needs review
FileSize
535 bytes

Small problem with the committed patch, if a uncaught exception occurs (ie a PDOException), you will get a notice of:

Notice: Undefined index: severity_level in _drupal_log_error() (line 1195 of includes/common.inc).

Attached patch hardcodes exceptions to WATCHDOG_ERROR

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

good catch

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Nice, thanks. Committed to HEAD.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.