#375 fixed loop in error db writer, log all errors except certain exceptions
This commit is contained in:
parent
f4e10ee977
commit
f5c99ea064
@ -28,11 +28,10 @@ class ConnectionMYS extends ConnectionAbstr {
|
||||
public function __construct(DBInfo $dbinfo, $new_link = false, $client_flag = 0){
|
||||
$this->connection = @mysqli_connect($dbinfo->m_host, $dbinfo->m_user, $dbinfo->m_password, $new_link, $client_flag);
|
||||
if(!$this->connection){
|
||||
die('Could not connect to Database. Check ur Database Settings');}
|
||||
die('Could not connect to Database. Check ur Database Settings.');}
|
||||
|
||||
if(!mysqli_select_db($this->connection, $dbinfo->m_database)){
|
||||
mysqli_close($this->connection);
|
||||
die('Could not select Database. Check ur Database Settings: '.mysqli_error($this->connection));}
|
||||
die('Could not select Database. Check ur Database Settings.');}
|
||||
|
||||
\mysqli_set_charset($this->connection, 'utf8');
|
||||
}
|
||||
|
||||
@ -25,8 +25,6 @@ class error_handler_dbwriter implements \SYSTEM\LOG\error_handler {
|
||||
*/
|
||||
public static function CALL(\Exception $E, $thrown){
|
||||
try{
|
||||
if(\property_exists(get_class($E), 'logged') && $E->logged){
|
||||
return false;} //alrdy logged(this prevents proper thrown value for every system exception)
|
||||
$result = \SYSTEM\SQL\SYS_LOG_INSERT::QI(array(
|
||||
get_class($E), $E->getMessage(), $E->getCode(), $E->getFile(), $E->getLine(), $E->getTraceAsString(),
|
||||
getenv('REMOTE_ADDR'),round(microtime(true) - \SYSTEM\time::getStartTime(),5),
|
||||
@ -34,12 +32,9 @@ class error_handler_dbwriter implements \SYSTEM\LOG\error_handler {
|
||||
array_key_exists('HTTP_REFERER', $_SERVER) ? $_SERVER['HTTP_REFERER'] : null,
|
||||
array_key_exists('HTTP_USER_AGENT',$_SERVER) ? $_SERVER['HTTP_USER_AGENT'] : null,
|
||||
($user = \SYSTEM\SECURITY\security::getUser()) ? $user->id : null,$thrown ? 1 : 0));
|
||||
|
||||
if(\property_exists(get_class($E), 'logged')){
|
||||
$E->logged = true;} //we just did log
|
||||
if(!\property_exists(get_class($E), 'do_not_todo_log')){
|
||||
\SYSTEM\SAI\saimod_sys_todo::exception($E,false);}
|
||||
} catch (\Exception $E){
|
||||
//Dump the Error
|
||||
echo \SYSTEM\LOG\JsonResult::toString((array)$E);
|
||||
return false;} //Error -> Ignore
|
||||
|
||||
return false; //We just log and do not handle the error!
|
||||
|
||||
@ -14,4 +14,4 @@ namespace SYSTEM\LOG;
|
||||
/**
|
||||
* Deprecated Log Class provided by System for marking code as Deprecated.
|
||||
*/
|
||||
class DEPRECATED extends \SYSTEM\LOG\TODO {}
|
||||
class DEPRECATED extends \SYSTEM\LOG\SYSTEM_EXCEPTION {}
|
||||
@ -14,4 +14,4 @@ namespace SYSTEM\LOG;
|
||||
/**
|
||||
* Error Log Class provided by System for all kinds of Errors.
|
||||
*/
|
||||
class ERROR extends \SYSTEM\LOG\TODO {}
|
||||
class ERROR extends \SYSTEM\LOG\SYSTEM_EXCEPTION {}
|
||||
@ -14,4 +14,7 @@ namespace SYSTEM\LOG;
|
||||
/**
|
||||
* Info Log Class provided by System for logging Infos.
|
||||
*/
|
||||
class INFO extends \SYSTEM\LOG\SYSTEM_EXCEPTION {}
|
||||
class INFO extends \SYSTEM\LOG\SYSTEM_EXCEPTION {
|
||||
/** Property to store if the Exception should not be logged */
|
||||
public $do_not_todo_log;
|
||||
}
|
||||
@ -16,8 +16,6 @@ namespace SYSTEM\LOG;
|
||||
* All other error exception Classes are derived from this.
|
||||
*/
|
||||
class SYSTEM_ERROR_EXCEPTION extends \ErrorException {
|
||||
/** bool Variable to store if the Exception was logged already */
|
||||
public $logged = false;
|
||||
/**
|
||||
* Construct the Error
|
||||
*
|
||||
|
||||
@ -15,12 +15,7 @@ namespace SYSTEM\LOG;
|
||||
* System Exception Class provided by System for logging all kinds of System Exceptions.
|
||||
* All other log Classes are derived from this.
|
||||
*/
|
||||
class SYSTEM_EXCEPTION extends \Exception {
|
||||
/** bool Variable to store if the Exception was logged already */
|
||||
public $logged = false;
|
||||
/** bool Variable to store if the Exceptions was logged as Todo */
|
||||
public $todo_logged = false;
|
||||
|
||||
class SYSTEM_EXCEPTION extends \Exception {
|
||||
/**
|
||||
* Construct the Error
|
||||
*
|
||||
@ -30,6 +25,7 @@ class SYSTEM_EXCEPTION extends \Exception {
|
||||
*/
|
||||
public function __construct($message = "", $code = 1, $previous = NULL){
|
||||
parent::__construct($message, $code, $previous);
|
||||
\SYSTEM\LOG\log::__exception_handler($this,false);
|
||||
if($previous == NULL){
|
||||
error_handler_dbwriter::CALL($this, false);}
|
||||
}
|
||||
}
|
||||
@ -23,6 +23,5 @@ class TODO extends \SYSTEM\LOG\SYSTEM_EXCEPTION {
|
||||
* @param \Exception $previous Previous Error leading to this one.
|
||||
*/
|
||||
public function __construct($message = "", $code = 1, $previous = NULL){
|
||||
parent::__construct($message, $code, $previous);
|
||||
\SYSTEM\SAI\saimod_sys_todo::exception($this,false);}
|
||||
parent::__construct($message, $code, $previous);}
|
||||
}
|
||||
@ -14,4 +14,4 @@ namespace SYSTEM\LOG;
|
||||
/**
|
||||
* Warning Class provided by System for logging Warnings.
|
||||
*/
|
||||
class WARNING extends \SYSTEM\LOG\TODO {}
|
||||
class WARNING extends \SYSTEM\LOG\SYSTEM_EXCEPTION {}
|
||||
Loading…
x
Reference in New Issue
Block a user