Welcome Guest, Not a member yet? Register   Sign In
Custom config in extended class (library)

I´m extended the Log class to email me and some other guys when an error occurs. But i can´t get my config to load. It´s located in the config directory and a subdir. Also i´m changing the threshold levels (in the construct). Why can´t i get my config?


class MY_Log extends CI_Log {
function MY_Log()
        $this->_levels = array('ERROR' => '1', 'INFO' => '2',  'DEBUG' => '3', 'ALL' => '4');

function write_log($level = 'error', $msg, $php_error = FALSE)
        $result = parent::write_log($level, $msg, $php_error);
        //Get my config with emails.
        $this->ci =& get_instance();
        echo $this->ci->config->item('sendto_emails');

Because it cannot be in a sub-directory.

That doesn´t seem to mather. It can´t be loaded if it is in main config dir or a sub dir.

You should be loading it in the Constructor.

Also, the Log library is used well before get_instance() exists, so you won't be able to just call the CI object in there, or it'll throw errors.

Ok. So if the Log class is loaded to soon.

How do i load other stuff in the library or from the config? Or do i have to return to good old fashioned PHP coding style (not using any of the cool framework stuff) in order to make it work? Is this something that usually happens or is this just because of the Log class?

Theme © iAndrew 2016 - Forum software by © MyBB