mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
refactor: Use anonymous functions for debug error_handler and shutdown_function in index.php (#7219)
This commit is contained in:
committed by
Neil Lathwood
parent
96cc9bfaa0
commit
b2c8f34039
@@ -19,29 +19,23 @@ if (empty($_SERVER['PATH_INFO'])) {
|
||||
}
|
||||
}
|
||||
|
||||
function logErrors($errno, $errstr, $errfile, $errline)
|
||||
{
|
||||
global $php_debug;
|
||||
$php_debug[] = array('errno' => $errno, 'errstr' => $errstr, 'errfile' => $errfile, 'errline' => $errline);
|
||||
}
|
||||
|
||||
function catchFatal()
|
||||
{
|
||||
$last_error = error_get_last();
|
||||
if ($last_error['type'] == 1) {
|
||||
$log_error = array($last_error['type'],$last_error['message'],$last_error['file'],$last_error['line']);
|
||||
print_r($log_error);
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($_SERVER['REQUEST_URI'], "debug")) {
|
||||
$debug = true;
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('log_errors', 1);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
set_error_handler('logErrors');
|
||||
register_shutdown_function('catchFatal');
|
||||
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
|
||||
global $php_debug;
|
||||
$php_debug[] = array('errno' => $errno, 'errstr' => $errstr, 'errfile' => $errfile, 'errline' => $errline);
|
||||
});
|
||||
register_shutdown_function(function () {
|
||||
$last_error = error_get_last();
|
||||
if ($last_error['type'] == 1) {
|
||||
$log_error = array($last_error['type'], $last_error['message'], $last_error['file'], $last_error['line']);
|
||||
print_r($log_error);
|
||||
}
|
||||
});
|
||||
$sql_debug = array();
|
||||
$php_debug = array();
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user