From: Janusz Dobrowolski Date: Tue, 16 Jun 2009 09:10:20 +0000 (+0000) Subject: Added error logging to file or syslog. X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=13f72359cce0c214d7fe543654671324b7b8b5e1;p=textcart.git Added error logging to file or syslog. --- diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 501ee78..db28dbc 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,11 @@ Legend: ! -> Note $ -> Affected files +16-Jun-2009 Janusz Dobrowolski +! Added error logging to file or syslog. +$ /config.php + /includes/errors.inc + 15-Jun-2009 Joe Hunt ! Added Item Code Entry in Work Order Entry and quantity decimals now follows the item ! Clean-up in ui_list codes. diff --git a/config.php b/config.php index c3e0d68..20a0897 100644 --- a/config.php +++ b/config.php @@ -20,7 +20,10 @@ if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_to_root'])) die("Restricted access"); - + // Log file for error/warning messages. Should be set to any location + // writable by www server. When set to empty string logging is switched off. + // Special value 'syslog' can be used for system logger usage (see php manual). + $error_logfile = dirname(__FILE__).'/tmp/errors.log'; $debug = 1; $show_sql = 0; $go_debug = 0; @@ -43,6 +46,12 @@ if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_ // ini_alter("error_reporting","E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR|E_PARSE"); ini_set("display_errors", "On"); } + + if($error_logfile != '') { + ini_set("error_log", $error_logfile); + ini_set("ignore_repeated_errors", "On"); + ini_set("log_errors", "On"); + } // Main Title $app_title = "FrontAccounting"; // application version diff --git a/includes/errors.inc b/includes/errors.inc index 8972a9e..eb06ff1 100644 --- a/includes/errors.inc +++ b/includes/errors.inc @@ -25,8 +25,18 @@ function error_handler($errno, $errstr, $file, $line) { global $messages; // error_reporting==0 when messages are set off with @ - if ($errno & error_reporting()) { - $messages[] = array($errno, $errstr, $file, $line); + if ($errno) { + if(error_reporting()) + $messages[] = array($errno, $errstr, $file, $line); + + $ignored = E_USER_WARNING|E_USER_ERROR|E_USER_NOTICE; + // don't log notices hidden with @ unless in debug mode + if (!$go_debug) $ignored |= E_NOTICE; + + if (!($errno & $ignored)) + error_log( + user_company().':'.$_SESSION["wa_current_user"]->loginname.':'. + basename($file).":$line: $errstr"); } return true; }