set log_threshold and environment in a function - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: set log_threshold and environment in a function (/showthread.php?tid=75605) |
set log_threshold and environment in a function - gmgj - 02-25-2020 I sometimes have to debug in production. I turn on some things for my IP address or of a tester, by adding the ip address to a table and switching the environment at startup. Is there a way to set this in a function. I could dump the results from $CI =& get_instance(); But it shows a lot of recursion, so I am not sure what to set and of if it would take effect, and when and where I could call it to turn it on for a run. What I do config/config.php // $ip=$_SERVER['REMOTE_ADDR']; $validIP = array('xx.5.96.133', xx.119.59.56'); if (in_array($ip, $validIP) ){ $config['log_threshold'] = 4; } else { $config['log_threshold'] = 1; } and in the index.php // user mod $ip=$_SERVER['REMOTE_ADDR']; $validIP = array('xx.119.59.56'); if (in_array($ip, $validIP) ){ define('ENVIRONMENT', 'development'); } else { define('ENVIRONMENT', 'production'); } /* *--------------------------------------------------------------- * ERROR REPORTING *--------------------------------------------------------------- * * Different environments will require different levels of error reporting. * By default development will show errors but testing and live will hide them. */ switch (ENVIRONMENT) .... I can see how to get at the log [log_threshold] => [config] => CI_Config Object ( [config] => Array ( [base_url] => https://www.pbaclouda2019-doctortest.com [index_page] => [uri_protocol] => REQUEST_URI [url_suffix] => [language] => english [charset] => UTF-8 [enable_hooks] => [subclass_prefix] => MY_ [composer_autoload] => [permitted_uri_chars] => a-z 0-9~%.:_\- [allow_get_array] => [enable_query_strings] => [controller_trigger] => c [function_trigger] => m [directory_trigger] => d [log_threshold] => |