Ejemplo n.º 1
0
 public static function bt($file = false)
 {
     if (!Kwf_Debug::isEnabled()) {
         return;
     }
     if (php_sapi_name() == 'cli' || $file) {
         $ret = self::btString();
         if ($file) {
             $ret = str_repeat("=", 45) . "\n" . php_sapi_name() . ' ' . (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '') . "\n" . $ret;
             file_put_contents('backtrace', $ret, FILE_APPEND);
         } else {
             echo $ret;
         }
     } else {
         $bt = debug_backtrace();
         unset($bt[0]);
         $out = array(array('File', 'Line', 'Function', 'Args'));
         foreach ($bt as $i) {
             $out[] = array(isset($i['file']) ? $i['file'] : '', isset($i['line']) ? $i['line'] : '', isset($i['function']) ? $i['function'] : null, self::_btArgsString($i['args']));
         }
         p(array('Backtrace for ' . self::_btString($bt[1]), $out), 'TABLE');
     }
 }