From 1ab00eda87879fdc4054bfb187d3030672e8fc4d Mon Sep 17 00:00:00 2001
From: Andrew Boag <red@red.geek.nz>
Date: Thu, 22 Jul 2010 13:41:15 +1000
Subject: [PATCH] PHP E_NOTICE patch to core for less log noise

---
 includes/common.inc          |    8 ++++++++
 modules/syslog/syslog.module |   19 +++++++++++++++++++
 2 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/includes/common.inc b/includes/common.inc
index b065f77..2292655 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -627,6 +627,14 @@ function drupal_error_handler($errno, $message, $filename, $line, $context) {
     return;
   }
 
+  // E_NOTICE disable (patch)
+    global $conf;
+    if (!empty($conf['e_notice_suppress']) && ($errno == E_NOTICE)) {
+      return;
+      }
+  // END E_NOTICE disable
+
+
   if ($errno & (E_ALL ^ E_DEPRECATED)) {
     $types = array(1 => 'error', 2 => 'warning', 4 => 'parse error', 8 => 'notice', 16 => 'core error', 32 => 'core warning', 64 => 'compile error', 128 => 'compile warning', 256 => 'user error', 512 => 'user warning', 1024 => 'user notice', 2048 => 'strict warning', 4096 => 'recoverable fatal error');
 
diff --git a/modules/syslog/syslog.module b/modules/syslog/syslog.module
index 5f92580..68f7c20 100644
--- a/modules/syslog/syslog.module
+++ b/modules/syslog/syslog.module
@@ -14,6 +14,17 @@ else {
 }
 
 /**
+ * so that we can disable the E_NOTICE messages at runtime
+ */
+
+function syslog_init() {
+  global $conf ;
+  $conf['e_notice_suppress']= variable_get('syslog_e_notice_suppress', 0);
+}
+
+
+
+/**
  * Implementation of hook_help().
  */
 function syslog_help($path, $arg) {
@@ -46,6 +57,14 @@ function syslog_admin_settings() {
     '#description'   => t('Select the syslog facility code under which Drupal\'s messages should be sent. On UNIX/Linux systems, Drupal can flag its messages with the code LOG_LOCAL0 through LOG_LOCAL7; for Microsoft Windows, all messages are flagged with the code LOG_USER. Depending on the system configuration, syslog and other logging tools use this code to identify or filter Drupal messages from within the entire system log. For more information on syslog, see <a href="@syslog_help">Syslog help</a>.', array(
       '@syslog_help' => url('admin/help/syslog'))),
   );
+
+  $form['syslog_e_notice_suppress'] = array(
+    '#type'          => 'checkbox',
+    '#title'         => t('PHP E_NOTICE Suppress (less log noise)'),
+    '#default_value' => variable_get('syslog_e_notice_suppress', 0),
+    '#description'   => t('Drupal enables the PHP E_NOTICE messages from the web server to the syslog. While this is very useful during development it can generate lots of unneccessary noise on a production system for non-critical issues (i.e. notices about undefined variables etc). It is useful to be able to toggle this on or off on a production site.'),
+  );
+
   return system_settings_form($form);
 }
 
-- 
1.6.5

