<?php
$gtracelog;
$gfunction_name;
$gfile_name;
$gi;

function l( $data, $function_name = '', $file_name='' ) 
{
    $GLOBALS['gi'] = $GLOBALS['gi'] + 1;
    
    if(strlen($function_name) > 0 )
        $GLOBALS['gfunction_name'] = $function_name;

    if(strlen($file_name) > 0 )
        $GLOBALS['gfile_name'] = $file_name;
    
    $GLOBALS['gtracelog'] .= "\n" . $GLOBALS['gi'] . '|' . $data . '|' . $GLOBALS['gfunction_name'] . '|' . $GLOBALS['gfile_name'] ;
    $data = NULL;
    
}

function d($data)
{
var_dump($data . "|" . $GLOBALS['gtracelog']);
exit;
}

function debug_to_console( $data ) {

    if ( is_array( $data ) )
        $output = "<script>console.log( 'Debug Objects: " . implode( ',', $data) . "' );</script>";
    else
        $output = "<script>console.log( 'Debug Objects: " . $data . "' );</script>";

    echo $output;
    exit;
}
	
?>