register_shutdown_function("shutdown");
define('ERR_LOG_FILE', '/dev/shm/php_log.txt');
if(defined('ERR_LOG_FILE')){
ini_set("display_errors",0);//不在页面显示错误信息
error_reporting(E_ALL ^ E_NOTICE);//记录错误日志的级别
ini_set( "log_errors", "On" );//打开错误日志
ini_set( "error_log", ERR_LOG_FILE);//设置保存错误日志的地址
}
function shutdown(){
if(isset($GLOBALS['_pm'])){
if(isset($GLOBALS['_pm']['mysql'])) $GLOBALS['_pm']['mysql']->close();
if(isset($GLOBALS['_pm']['mem'])) $GLOBALS['_pm']['mem']->memClose();
$GLOBALS['_pm'] = NULL;
if(defined('ERR_LOG_FILE')){
$_error=error_get_last();
if($_error && in_array($_error['type'],array(1,4,16,64,256,4096,E_ALL))){
$s = chr(10).'---------------------'.chr(10).date('Y/m/d H:i:s').' error:'.$_error['message'].chr(10);
$s .= 'File:'.$_error['file'].chr(10);
$s .= 'Line'.$_error['line'].chr(10);
file_put_contents(ERR_LOG_FILE, $s , FILE_APPEND);
}
}
}
}