class MY_Exceptions extends CI_Exceptions {
protected $CI;
public function __construct()
{
// Assign the CodeIgniter super-object
$this->CI =& get_instance();
}
public function log_exception($severity, $message, $filepath, $line)
{
// this allows different params for different environments
$this->CI->config->load('email_php_errors');
// if it's enabled
if (config_item('email_php_errors'))
{
// set up email with config values
$this->CI->load->library('email');
$this->CI->email->from(config_item('php_error_from'));
$this->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);
$this->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
$this->CI->email->message($content);
$this->CI->email->send();
}
// do the rest of the codeigniter stuff
parent::log_exception($severity, $message, $filepath, $line);
}
private function _replace_short_tags($content, $severity, $message, $filepath, $line)
{
$content = str_replace('{{severity}}', $severity, $content);
$content = str_replace('{{message}}', $message, $content);
$content = str_replace('{{filepath}}', $filepath, $content);
$content = str_replace('{{line}}', $line, $content);
return $content;
}
}