Skip to content

Instantly share code, notes, and snippets.

@diemer
Created December 5, 2012 16:56
Show Gist options
  • Save diemer/4217389 to your computer and use it in GitHub Desktop.
Save diemer/4217389 to your computer and use it in GitHub Desktop.
CodeIgniter - Log controller/method where error occurred
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Exceptions extends CI_Exceptions {
// this file goes in application/core
public function __construct()
{
$this->ob_level = ob_get_level();
// Note: Do not log messages from this constructor.
}
function log_exception($severity, $message, $filepath, $line)
{
$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
$router =& load_class('Router', 'core');
log_message('error', 'Severity: '.$severity.' --> '.$message. ' '.$filepath.' '.$line, TRUE);
log_message('error', 'Above error occurred in '.$router->fetch_class().' controller, inside '. $router->fetch_method() . ' method.');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment