Welcome Guest, Not a member yet? Register   Sign In
set log_threshold and environment in a function
#1

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] => 
I wrote my first program in 15 minutes. It took me 3 hours to keypunch it.

I wrote my first BASH script in 5 minutes. It took me a day to find out I had to put a . (period) in front of it to get it to execute.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB