Пример #1
0
/**
 * function handleDebug()
 * Handle the debug array at the end of the process
 * @param  array $convoArr - conversation arrau
 * @return array $convoArr;
 **/
function handleDebug($convoArr, $et)
{
    global $debugArr, $debug_level, $debug_mode;
    $debug_level = isset($convoArr['conversation']['debug_level']) ? $convoArr['conversation']['debug_level'] : $debug_level;
    $debug_mode = isset($convoArr['conversation']['debugmode']) ? $convoArr['conversation']['debugmode'] : $debug_mode;
    $convoArr['debug'] = $debugArr;
    $log = '';
    foreach ($debugArr as $time => $subArray) {
        $log .= $time . '[NEWLINE]';
        foreach ($subArray as $index => $value) {
            if ($index == 'fileName' || $index == 'functionName' || $index == 'line') {
                $log .= "[{$value}]";
            } elseif ($index == 'info') {
                $log .= "[NEWLINE]{$value} [NEWLINE]-----------------------[NEWLINE]";
            }
        }
    }
    $log = rtrim($log);
    if ($debug_level == 4) {
        //show the full array
        $showArr = $convoArr;
        unset($showArr['debug']);
    } else {
        //show a reduced array
        $showArr = reduceConvoArr($convoArr);
    }
    if ($debug_level != 0) {
        //$log .= '[NEWLINE]-----------------------[NEWLINE]';
        $log .= "Debug Level: {$debug_level}";
        $log .= '[NEWLINE]-----------------------[NEWLINE]';
        $log .= "Debug Mode: {$debug_mode}";
        $log .= '[NEWLINE]-----------------------[NEWLINE]';
        $log .= 'CONVERSATION ARRAY';
        $log .= '[NEWLINE]-----------------------[NEWLINE]';
        $log .= str_replace("\n", PHP_EOL, print_r($showArr, true));
        $log .= '[NEWLINE]-----------------------[NEWLINE]';
        $log .= "Total execution time: {$et} Milliseconds. Goodbye.";
    }
    switch ($debug_mode) {
        case 0:
            //show in source code
            $log = str_replace('[NEWLINE]', "\n", $log);
            display_on_page(0, $log);
            break;
        case 1:
            //write to log file
            $log = str_replace('[NEWLINE]', PHP_EOL, $log);
            writefile_debug($log, $convoArr);
            break;
        case 2:
            //show in webpage
            $log = str_replace('[NEWLINE]', '<br/>', $log);
            display_on_page(1, $log);
            break;
        case 3:
            //email to user
            $log = str_replace('[NEWLINE]', "\r\n", $log);
            email_debug($convoArr['conversation']['debugemail'], $log);
            break;
    }
    return $convoArr;
}
Пример #2
0
/**
 * function handleDebug()
 * Handle the debug array at the end of the process
 * @param  array $convoArr - conversation arrau
 * @return array $convoArr;
 * TODO THIS MUST BE IMPLMENTED
**/
function handleDebug($convoArr)
{
    global $debugArr;
    $convoArr['debug'] = $debugArr;
    $log = '';
    foreach ($debugArr as $time => $subArray) {
        $log .= $time . "[NEWLINE]";
        foreach ($subArray as $index => $value) {
            if ($index == "fileName" || $index == "functionName" || $index == "line") {
                $log .= "[" . $value . "]";
            } elseif ($index == "info") {
                $log .= "[NEWLINE]" . $value . "[NEWLINE]-----------------------[NEWLINE]";
            }
        }
    }
    $log .= "[NEWLINE]-----------------------[NEWLINE]";
    $log .= "CONVERSATION ARRAY";
    $log .= "[NEWLINE]-----------------------[NEWLINE]";
    $debuglevel = get_convo_var($convoArr, 'conversation', 'debugshow', '', '');
    if ($debuglevel == 4) {
        //show the full array
        $showArr = $convoArr;
        unset($showArr['debug']);
    } else {
        //show a reduced array
        $showArr = reduceConvoArr($convoArr);
    }
    $log .= print_r($showArr, true);
    switch ($convoArr['conversation']['debugmode']) {
        case 0:
            //show in source code
            $log = str_replace("[NEWLINE]", "\r\n", $log);
            display_on_page(0, $log);
            break;
        case 1:
            //write to log file
            $log = str_replace("[NEWLINE]", "\r\n", $log);
            writefile_debug($log);
            break;
        case 2:
            //show in webpage
            $log = str_replace("[NEWLINE]", "<br/>", $log);
            display_on_page(1, $log);
            break;
        case 3:
            //email to user
            $log = str_replace("[NEWLINE]", "\r\n", $log);
            email_debug($convoArr['conversation']['debugemail'], $log);
            break;
    }
    return $convoArr;
}