コード例 #1
0
ファイル: Ak.php プロジェクト: joeymetal/v1
    /**
    * Trace helper function for development purposes
    *
    * @access public
    * @static
    * @param    string    $text    Helper text
    * @param    string    $line    Helper line
    * @param    string    $file    Helper file
    * @return echoes result to screen
    */
    function trace($text = null, $line = null, $file = null, $method = null, $escape_html_entities = true)
    {
        static $counter = 0;
        if(AK_PRODUCTION_MODE){
            return;
        }
        $html_entities_function = $escape_html_entities ? 'htmlentities' : 'trim';
        list($default_file, $default_line, $default_method) = Ak::getLastFileAndLineAndMethod();
        $line = empty($line) ? $default_line : $line;
        $file = empty($file) ? $default_file : $file;
        $method = empty($method) ? $default_method : $method;

        if(AK_CLI){
            $text = Ak::dump($text, 'print_r');
        }elseif (!empty($text) && !is_scalar($text)){
            $rand = Ak::randomString();
            $formatted = '';
            $methods = array('print_r', 'var_dump', 'var_export');
            foreach ($methods as $method){
                $pre_style = 'display:none;';
                if(defined('AK_TRACE_DUMP_METHOD')){
                    if(AK_TRACE_DUMP_METHOD == $method){
                        $pre_style = '';
                    }
                }elseif ($method == 'print_r'){
                    $pre_style = '';
                }
                $element_id = $method.'_'.$rand;
                $formatted .= "<div style='margin:10px;'><a href='javascript:void(0);' onclick='e_$element_id = document.getElementById(\"$element_id\"); e_$element_id.style.display = (e_$element_id.style.display == \"none\"?\"block\":\"none\");' title='Set the constant AK_TRACE_DUMP_METHOD to your favourite default method'>$method</a><br />".
                                '<pre style="'.$pre_style.'" id="'.$element_id.'">'.$html_entities_function(Ak::dump($text, $method)).'</pre></div>';
            }
            $text = $formatted;
        }elseif (is_scalar($text)){
            $text = '<pre style="margin:10px;">'.$html_entities_function($text).'</pre>';
        }

        if(!isset($text)){
            $counter++;
            $text = '';
        }else {
            $text = AK_CLI?'---> '.$text : ($text);
        }

        echo AK_CLI?"----------------\n$file ($line):\n $text\n----------------\n":"<div style='background-color:#fff;margin:10px;color:#000;font-family:sans-serif;border:3px solid #fc0;font-size:12px;'><div style='background-color:#ffc;padding:10px;color:#000;font-family:sans-serif;'>$file <span style='font-weight:bold'>$line</span> <span style='font-style:italic'>$method</span></div>".$text."</div>\n";
    }
コード例 #2
0
 function ak_trace_db_query($message, $new_line = true)
 {
     if (Ak::getStaticVar('ak_trace_db_query') === false) {
         return;
     }
     if (!AK_TRACE_DB_QUERIES_INCLUDES_DB_TYPE) {
         $message = preg_replace('/\\([a-z0-9]+\\): /', '', trim($message, "\n-"));
     }
     $details = Ak::getLastFileAndLineAndMethod(AK_TRACE_ONLY_APP_DB_QUERIES);
     if (empty($details)) {
         $details = array(null, null, null);
     }
     $message = trim(html_entity_decode(strip_tags($message)));
     if (!AK_DEBUG_OUTPUT_AS_HTML) {
         echo $message . "\n";
     } else {
         Ak::trace($message, $details[1], $details[0], $details[2]);
     }
 }
コード例 #3
0
ファイル: base.php プロジェクト: bermi/sintags
 static function getFileAndNumberTextForError($levels = 0)
 {
     list($file, $line, $method) = Ak::getLastFileAndLineAndMethod(false, $levels + 1);
     return Ak::t('In %file line %line', array('%file' => $file, '%line' => $line));
 }