CI_Exceptions::log_exception PHP Method

log_exception() public method

Logs PHP generated error messages
public log_exception ( integer $severity, string $message, string $filepath, integer $line ) : void
$severity integer Log level
$message string Error message
$filepath string File path
$line integer Line number
return void
    public function log_exception($severity, $message, $filepath, $line)
    {
        $severity = isset($this->levels[$severity]) ? $this->levels[$severity] : $severity;
        log_message('error', 'Severity: ' . $severity . ' --> ' . $message . ' ' . $filepath . ' ' . $line);
    }

Usage Example

Example #1
0
 /**
  * extend log_exception to add emailing of php errors.
  *
  * @access public
  * @param string $severity
  * @param string $message
  * @param string $filepath
  * @param int $line
  * @return void
  */
 function log_exception($severity, $message, $filepath, $line)
 {
     $ci =& get_instance();
     // this allows different params for different environments
     $ci->config->load('email_php_errors');
     // if it's enabled
     if (config_item('email_php_errors')) {
         // set up email with config values
         $ci->load->library('email');
         $ci->email->from(config_item('php_error_from'));
         $ci->email->to(config_item('php_error_to'));
         // set up subject
         $subject = config_item('php_error_subject');
         $subject = $this->_replace_short_tags($subject, $severity, $message, $filepath, $line);
         $ci->email->subject($subject);
         // set up content
         $content = config_item('php_error_content');
         $content = $this->_replace_short_tags($content, $severity, $message, $filepath, $line);
         // set message and send
         $ci->email->message($content);
         $f = $ci->email->send();
         //var_dump($ci->email);
     }
     // do the rest of the codeigniter stuff
     parent::log_exception($severity, $message, $filepath, $line);
 }
All Usage Examples Of CI_Exceptions::log_exception