有时很难诊断中/大codeIgniter应用程序中出现的问题。当我们不知道用户如何访问资源时,很难重现。这是一个非常方便的脚本。
答案 0 :(得分:1)
由"kirill" in a blog posted on "key2market.com"提供的脚本
它将错误,URI和发布的数据记录到您的日志文件中。如果您的应用程序有很多错误,那么该脚本可能会降低您的服务器速度。
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Exceptions extends CI_Exceptions{
/**
* Constructor
*
*/
function __construct(){
parent::__construct();
}
/**
* Exception Logger
*
* This function logs PHP generated error messages
*
*/
function log_exception($severity, $message, $filepath, $line)
{
$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
$message = 'Severity: '.$severity.' –> '.$message. ' '.$filepath.' '.$line.' [URI='.$_SERVER['REQUEST_URI'].']';
if( !empty($_POST) ){
$message .= 'POST: ';
foreach($_POST as $key=>$value){
$message .= $key.' => '.$value;
}
}
log_message('error', $message, TRUE);
}
}
// END Exceptions Class
/* End of file Exceptions.php */
/* Location: ./ci_app/core/Exceptions.php */