[eluser]sophistry[/eluser]
I just made a similar MY_Log.php file and I think it is less code to maintain should the CI Log.php library change substantially.
The class proposed above is fine and it works, but it was too much STUFF to change and adding a config item was not to my taste.
Here is an alternative that just uses the MY_Log.php class extension to override the $_levels var. To use it, you just create your own array items. In my case, I needed to log search items in a text file.
Config file needs log_threshold set to 1:
Code:
$config['log_threshold'] = 1;
So, my log_message() call looks like this:
Code:
log_message('SEARCH', $search_term);
and the MY_log.php file...
Code:
<?php
// override the $_levels array to allow custom levels
class MY_Log extends CI_Log {
var $_levels = array('SEARCH' => '1', 'ERROR' => '2', 'DEBUG' => '3', 'INFO' => '4', 'ALL' => '5');
function MY_Log()
{
parent::CI_Log();
}
}
/* end of file MY_Log.php */