• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Set log_threshold in model

#1
[eluser]Unknown[/eluser]
I want to be able to use the built in logging calls in order to capture some log messages. I would like to leave the $config['log_threshold'] set to 0 however within my model, I want to change the system logging threshold. I am using this code.

Code:
$this->config->set_item('log_threshold', 4);

I have a profiler enabled so I am seeing that the config value has been updated, however the logs are never created. I have tried just about everything I can think of at this point. My current thought that the Log singleton is created and checks the config['log_threshold'] value and since it is zero, never get's updated with the new threshold.

I have looked at how some people are loading config variables from a database to see if that would spark an idea, nothing was too obvious.

Looking for some suggestions.

#2
[eluser]Aken[/eluser]
I would just extend the Log library and add your own method for controlling the threshold. You can extend the Log library just like any other library.

The library doesn't use a Singleton pattern, it is just instantiated once and that's it. Because the threshold check is in the constructor, changing the config value after instantiation is useless. You'll need to do it manually at that point.

Just remember that once you change the threshold in the library, it will stay that way for the rest of your script's execution. So if another library / controller / whatever hits the matching log level, it will be logged as well. So if you want to avoid that, remember to change the original log level back when you're done.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.