2013-01-18 131 views

回答

1

脚本由"kirill" in a blog posted on "key2market.com"

提供它记录错误,URI和发布数据到log文件。如果您的应用程序有很多错误,该脚本可能会降低您的服务器速度。

  • 只需创建文件 “[CI]应用/核心/ MY_Exceptions.php”
  • 复制/ pastethe以下脚本:

开始

<?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 */ 

结束