diff --git a/core/includes/errors.inc b/core/includes/errors.inc
index 2d3942d..c649537 100644
--- a/core/includes/errors.inc
+++ b/core/includes/errors.inc
@@ -63,6 +63,20 @@ function _drupal_error_handler_real($error_level, $message, $filename, $line, $c
       require_once DRUPAL_ROOT . '/core/includes/common.inc';
     }
 
+    // Catch errors created via require() and drupal_load().
+    if ( $caller['file'] != $filename || $caller['line'] != $line ) {
+      _drupal_log_error(array(
+        '%type' => isset($types[$error_level]) ? $severity_msg : 'Unknown error',
+        // The standard PHP error handler considers that the error messages
+        // are HTML. We mimick this behavior here.
+        '!message' => filter_xss_admin($message),
+        '%function' => "unknown",
+        '%file' => $filename,
+        '%line' => $line,
+        'severity_level' => $severity_level,
+      ), $error_level == E_RECOVERABLE_ERROR);
+    }
+
     // We treat recoverable errors as fatal.
     _drupal_log_error(array(
       '%type' => isset($types[$error_level]) ? $severity_msg : 'Unknown error',
