change config['log_path'] on the fly |
I am trying to specify my log directory from MY_Controller (my base class for application/controllers/*.php) depending on the controller class being called. The clog directory was specified using
Code: $this->config->set_item("log_path",APPPATH.'logs'.DIRECTORY_SEPARATOR.$this->router->class.DIRECTORY_SEPARATOR); in the MY_Controller::__construct(). I have a custom log function in MY_Controller::log() which in turn calls CI's log_message(). All the possible log directories exists and have permission of 777. Code: $this->config->item('log_path'); always return the correct expected log directory. The issue despite the default log directory being changed successfully to another directory, the string to be logged is being logged into the default log directory (application/logs). Any help will be appreciated. Thanks.
Try this, it may need to be put into the CodeIgniter global space.
PHP Code: $this->load->vars($this->config->item('log_path')); What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
This directive is not supposed to be changed at runtime, and you shouldn't try to.
Quite a lot of messages are logged before you ever have the chance to try altering the path. (03-01-2018, 06:17 AM)InsiteFX Wrote: Try this, it may need to be put into the CodeIgniter global space. ... and this cannot possibly help, in any situation. Totally unrelated. I've lost count of how many times I've had to correct you for stuff like this, @InsiteFX. I know you're trying to help, but you can't just throw random suggestions, because when they don't work, you're doing the very opposite - people waste time with it and are often put in an entirely wrong direction.
No. I don't understand why you should it should be possible, but even if we wanted to modify the entire framework to allow this, we'd probably still fall short.
OK. Narf, does this apply to "log_path" alone or all CI config params?
CI gave room for config params modification using PHP Code: $this->config->set_item("index","new_value")
A few other ones have the same limitation, but it's very far from all of them.
It's very simple - some directives just have to go into effect before you ever have the chance to try modifying them (if you do at all; there's no guarantee that a controller will be instantiated). |
Welcome Guest, Not a member yet? Register Sign In |