errorhandler dbwriter mysql compatible and
This commit is contained in:
parent
58e9e0c443
commit
219f8aa535
@ -7,16 +7,25 @@ namespace SYSTEM\LOG;
|
|||||||
abstract class error_handler_dbwriter extends \SYSTEM\LOG\error_handler {
|
abstract class error_handler_dbwriter extends \SYSTEM\LOG\error_handler {
|
||||||
public static function CALL(\Exception $E, $errno, $thrown){
|
public static function CALL(\Exception $E, $errno, $thrown){
|
||||||
try{
|
try{
|
||||||
$con = new \SYSTEM\DB\Connection(static::getDBInfo());
|
if(\SYSTEM\system::isSystemDbInfoPG()){
|
||||||
$con->prepare( 'sysLogStmt', 'INSERT INTO system.sys_log '.
|
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
|
||||||
'(class, message, code, file, line, trace, ip, querytime) '.
|
$con->prepare( 'sysLogStmt', 'INSERT INTO system.sys_log '.
|
||||||
'VALUES ($1, $2, $3, $4, $5, $6, $7, $8);',
|
'(class, message, code, file, line, trace, ip, querytime) '.
|
||||||
array( get_class($E), $E->getMessage(), $E->getCode(), $E->getFile(), $E->getLine(), $E->getTraceAsString(),
|
'VALUES ($1, $2, $3, $4, $5, $6, $7, $8);',
|
||||||
getenv('REMOTE_ADDR'),round(microtime(true) - \SYSTEM\time::getStartTime(),5)));
|
array( get_class($E), $E->getMessage(), $E->getCode(), $E->getFile(), $E->getLine(), $E->getTraceAsString(),
|
||||||
|
getenv('REMOTE_ADDR'),round(microtime(true) - \SYSTEM\time::getStartTime(),5)));
|
||||||
|
} else {
|
||||||
|
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
|
||||||
|
$con->prepare( 'sysLogStmt', 'INSERT INTO system_log '.
|
||||||
|
'(class, message, code, file, line, trace, ip, querytime) '.
|
||||||
|
'VALUES (?, ?, ?, ?, ?, ?, ?, ?);',
|
||||||
|
array( get_class($E), $E->getMessage(), $E->getCode(), $E->getFile(), $E->getLine(), $E->getTraceAsString(),
|
||||||
|
getenv('REMOTE_ADDR'),round(microtime(true) - \SYSTEM\time::getStartTime(),5)));
|
||||||
|
}
|
||||||
} catch (\Exception $E){} //Error -> Ignore
|
} catch (\Exception $E){} //Error -> Ignore
|
||||||
|
|
||||||
return false; //We just log and do not handle the error!
|
return false; //We just log and do not handle the error!
|
||||||
}
|
}
|
||||||
|
public static function MASK(){
|
||||||
abstract protected static function getDBInfo();
|
return \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_ERRORREPORTING);}
|
||||||
}
|
}
|
||||||
2
log/register_errorhandler_dbwriter.php
Normal file
2
log/register_errorhandler_dbwriter.php
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
\SYSTEM\LOG\LOG::getInstance()->registerHandler('\SYSTEM\LOG\error_handler_dbwriter');
|
||||||
@ -27,14 +27,14 @@ class saimod_sys_log extends \SYSTEM\SAI\SaiModule {
|
|||||||
array('%'.$filter.'%'));
|
array('%'.$filter.'%'));
|
||||||
} else {
|
} else {
|
||||||
$res = $con->prepare( 'selectSysLogFilter',
|
$res = $con->prepare( 'selectSysLogFilter',
|
||||||
'SELECT * FROM system_sys_log WHERE class ILIKE $1 ORDER BY time DESC LIMIT 100;',
|
'SELECT * FROM system_log WHERE class LIKE ? ORDER BY time DESC LIMIT 100;',
|
||||||
array('%'.$filter.'%'));
|
array('%'.$filter.'%'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(\SYSTEM\system::isSystemDbInfoPG()){
|
if(\SYSTEM\system::isSystemDbInfoPG()){
|
||||||
$res = $con->query('SELECT * FROM system.sys_log ORDER BY time DESC LIMIT 100;');
|
$res = $con->query('SELECT * FROM system.sys_log ORDER BY time DESC LIMIT 100;');
|
||||||
} else {
|
} else {
|
||||||
$res = $con->query('SELECT * FROM system_sys_log ORDER BY time DESC LIMIT 100;');
|
$res = $con->query('SELECT * FROM system_log ORDER BY time DESC LIMIT 100;');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user