Created
December 5, 2012 16:56
-
-
Save diemer/4217389 to your computer and use it in GitHub Desktop.
CodeIgniter - Log controller/method where error occurred
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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