[eluser]Billy Shall[/eluser]
Ended up taking the simple route on this:
Code:
class MY_Log extends CI_Log {
function __construct()
{
parent::CI_Log();
$config =& get_config();
if (is_numeric($config['log_threshold']))
{
$this->_threshold = $config['log_threshold'];
}
}
function write_log($level = 'error', $msg, $php_error = FALSE)
{
$level = strtoupper($level);
if ( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold))
{
return FALSE;
}
$time = time();
$ip = $this->get_ip_address();
//Log Error To Database
require(APPPATH.'config/database.php');
mysql_connect($db['default']['hostname'], $db['default']['username'], $db['default']['password'])
or die(mysql_error());
mysql_select_db($db['default']['database'])
or die(mysql_error());
mysql_query("
INSERT INTO errors (error_level, error_msg, error_time, error_ip_address)
VALUES('$level', '$msg', '$time', '$ip')")
or die(mysql_error());
mysql_close();
return TRUE;
}
function get_ip_address()
{
if (!empty($_SERVER['HTTP_CLIENT_IP']))
{
$ip = $_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
elseif (!empty($_SERVER['REMOTE_ADDR']))
{
$ip = $_SERVER['REMOTE_ADDR'];
}
else
{
$ip = NULL;
}
return $ip;
}
}