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

[eluser]JackU[/eluser]
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?

('application/config/extra/appconf.php)

Code:
class MY_Log extends CI_Log {
function MY_Log()
    {
        parent::__construct();
        $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();
        $this->ci->load->config('extra/appconf');
        echo $this->ci->config->item('sendto_emails');
    }
}
#2

[eluser]InsiteFX[/eluser]
Because it cannot be in a sub-directory.
#3

[eluser]JackU[/eluser]
That doesn´t seem to mather. It can´t be loaded if it is in main config dir or a sub dir.
#4

[eluser]InsiteFX[/eluser]
You should be loading it in the Constructor.
#5

[eluser]Aken[/eluser]
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.
#6

[eluser]JackU[/eluser]
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