Welcome Guest, Not a member yet? Register   Sign In
Log an Array
#1

[eluser]tchule[/eluser]
Hello,

I'm constantly in need for a way to debug and log some Arrays.

I'd like to log it in the log file instead of having to use a var_dump.

I've added the following function to the Commun.php file of code_igniter, it works but it's probably ugly. If someone knows of a better way i'm interested ...

Code:
function log_array($level = 'error', $array, $php_error = FALSE)
{
    static $LOG;
    
    $config =& get_config();
    if ($config['log_threshold'] == 0)
    {
        return;
    }

    $LOG =& load_class('Log');    
    
    ob_start();
    var_export($array);
    $tab_debug=ob_get_contents();
    ob_end_clean();
    
    $LOG->write_log($level, $tab_debug, $php_error);
}

Tchule


Messages In This Thread
Log an Array - by El Forum - 09-07-2007, 07:45 AM
Log an Array - by El Forum - 09-07-2007, 07:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB