pg fixes for the log
This commit is contained in:
parent
6dc5176949
commit
d828d51ac1
@ -6,27 +6,27 @@ namespace SYSTEM\LOG;
|
||||
//And only the first ErrorHandler will be called if he returns true in CALL.
|
||||
class error_handler_dbwriter extends \SYSTEM\LOG\error_handler {
|
||||
public static function CALL(\Exception $E, $thrown){
|
||||
try{
|
||||
try{
|
||||
if(\property_exists(get_class($E), 'logged') && $E->logged){
|
||||
return false;} //alrdy logged(this prevents proper thrown value for every system exception)
|
||||
|
||||
if(\SYSTEM\system::isSystemDbInfoPG()){
|
||||
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
|
||||
$con->prepare( 'sysLogStmt', 'INSERT INTO '.\SYSTEM\DBD\system_log::NAME_PG.
|
||||
'('.\SYSTEM\DBD\system_log::FIELD_CLASS.','.\SYSTEM\DBD\system_log::FIELD_MESSAGE.','.
|
||||
\SYSTEM\DBD\system_log::FIELD_CODE.','.\SYSTEM\DBD\system_log::FIELD_FILE.','.
|
||||
\SYSTEM\DBD\system_log::FIELD_LINE.','.\SYSTEM\DBD\system_log::FIELD_TRACE.','.
|
||||
\SYSTEM\DBD\system_log::FIELD_IP.','.\SYSTEM\DBD\system_log::FIELD_QUERYTIME.','.
|
||||
\SYSTEM\DBD\system_log::FIELD_SERVER_NAME.','.\SYSTEM\DBD\system_log::FIELD_SERVER_PORT.','.
|
||||
\SYSTEM\DBD\system_log::FIELD_REQUEST_URI.','.\SYSTEM\DBD\system_log::FIELD_POST.','.
|
||||
\SYSTEM\DBD\system_log::FIELD_HTTP_REFERER.','.\SYSTEM\DBD\system_log::FIELD_HTTP_USER_AGENT.','.
|
||||
\SYSTEM\DBD\system_log::FIELD_USER.','.\SYSTEM\DBD\system_log::FIELD_THROWN.')'.
|
||||
'("'.\SYSTEM\DBD\system_log::FIELD_CLASS.'","'.\SYSTEM\DBD\system_log::FIELD_MESSAGE.'","'.
|
||||
\SYSTEM\DBD\system_log::FIELD_CODE.'","'.\SYSTEM\DBD\system_log::FIELD_FILE.'","'.
|
||||
\SYSTEM\DBD\system_log::FIELD_LINE.'","'.\SYSTEM\DBD\system_log::FIELD_TRACE.'","'.
|
||||
\SYSTEM\DBD\system_log::FIELD_IP.'","'.\SYSTEM\DBD\system_log::FIELD_QUERYTIME.'","'.
|
||||
\SYSTEM\DBD\system_log::FIELD_SERVER_NAME.'","'.\SYSTEM\DBD\system_log::FIELD_SERVER_PORT.'","'.
|
||||
\SYSTEM\DBD\system_log::FIELD_REQUEST_URI.'","'.\SYSTEM\DBD\system_log::FIELD_POST.'","'.
|
||||
\SYSTEM\DBD\system_log::FIELD_HTTP_REFERER.'","'.\SYSTEM\DBD\system_log::FIELD_HTTP_USER_AGENT.'","'.
|
||||
\SYSTEM\DBD\system_log::FIELD_USER.'","'.\SYSTEM\DBD\system_log::FIELD_THROWN.'")'.
|
||||
'VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16);',
|
||||
array( get_class($E), $E->getMessage(), $E->getCode(), $E->getFile(), $E->getLine(), $E->getTraceAsString(),
|
||||
getenv('REMOTE_ADDR'),round(microtime(true) - \SYSTEM\time::getStartTime(),5),
|
||||
$_SERVER["SERVER_NAME"],$_SERVER["SERVER_PORT"],$_SERVER['REQUEST_URI'], serialize($_POST),
|
||||
array_key_exists('HTTP_REFERER', $_SERVER) ? $_SERVER['HTTP_REFERER'] : null,$_SERVER['HTTP_USER_AGENT'],
|
||||
($user = \SYSTEM\SECURITY\Security::getUser()) ? $user->id : null,$thrown));
|
||||
($user = \SYSTEM\SECURITY\Security::getUser()) ? $user->id : null, $thrown ? 1 : 0));
|
||||
} else {
|
||||
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
|
||||
$con->prepare( 'sysLogStmt', 'INSERT INTO '.\SYSTEM\DBD\system_log::NAME_MYS.
|
||||
|
||||
@ -52,7 +52,7 @@ class saimod_sys_log extends \SYSTEM\SAI\SaiModule {
|
||||
.'sum(case when '.\SYSTEM\DBD\system_log::FIELD_CLASS.' = \'Exception\' then 1 else 0 end) class_Exception,'
|
||||
.'sum(case when '.\SYSTEM\DBD\system_log::FIELD_CLASS.' = \'RuntimeException\' then 1 else 0 end) class_RuntimeException,'
|
||||
.'sum(case when '.\SYSTEM\DBD\system_log::FIELD_CLASS.' = \'ErrorException\' then 1 else 0 end) class_ErrorException'
|
||||
.'FROM '.\SYSTEM\DBD\system_log::NAME_PG
|
||||
.' FROM '.\SYSTEM\DBD\system_log::NAME_PG
|
||||
.' GROUP BY day'
|
||||
.' ORDER BY day DESC'
|
||||
.' LIMIT 365;');
|
||||
@ -119,14 +119,14 @@ class saimod_sys_log extends \SYSTEM\SAI\SaiModule {
|
||||
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_log/saimod_sys_log_error.tpl'), $vars);
|
||||
}
|
||||
|
||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_log_action_filter($filter = ""){
|
||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_log_action_filter($filter = ""){
|
||||
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
|
||||
$res = null;
|
||||
if($filter !== ""){
|
||||
if(\SYSTEM\system::isSystemDbInfoPG()){
|
||||
$res = $con->prepare( 'selectCountSysLogFilter',
|
||||
'SELECT COUNT(*) as count FROM '.\SYSTEM\DBD\system_log::NAME_PG.'WHERE '.\SYSTEM\DBD\system_log::FIELD_CLASS.' LIKE $1;',
|
||||
array(mysql_escape_string($filter)))->next();
|
||||
'SELECT COUNT(*) as count FROM '.\SYSTEM\DBD\system_log::NAME_PG.' WHERE '.\SYSTEM\DBD\system_log::FIELD_CLASS.' LIKE $1;',
|
||||
array($filter))->next();
|
||||
$count = $res['count'];
|
||||
$res = $con->prepare( 'selectSysLogFilter',
|
||||
'SELECT * FROM '.\SYSTEM\DBD\system_log::NAME_PG.
|
||||
@ -135,7 +135,7 @@ class saimod_sys_log extends \SYSTEM\SAI\SaiModule {
|
||||
' = '.\SYSTEM\DBD\system_user::NAME_PG.'.'.\SYSTEM\DBD\system_user::FIELD_ID.
|
||||
' WHERE '.\SYSTEM\DBD\system_log::FIELD_CLASS.' LIKE $1'.
|
||||
' ORDER BY '.\SYSTEM\DBD\system_log::FIELD_TIME.' DESC LIMIT 100;',
|
||||
array(mysql_escape_string($filter)));
|
||||
array($filter));
|
||||
} else {
|
||||
$res = $con->prepare( 'selectCountSysLogFilter',
|
||||
'SELECT COUNT(*) as count'.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user