예제 #1
0
define('FIREPHP_INFO', false);
define('FIREPHP_WARN', false);
define('FIREPHP_ERROR', false);
define('FIREPHP_TRACE', true);
require_once '../../Grace/FirePHPCore/fb.php';
FB::log('Hello World !');
// 常规记录
\FB::group('Test Group A', ['Collapsed' => true]);
// 记录分组
// 以下为按照不同类别或者类型进行信息记录
FB::log('Plain Message');
FB::info('Info Message');
FB::warn('Warn Message');
FB::error('Error Message');
FB::log('Message', 'Optional Label');
FB::info([1, 2, 3, 5, 56], "All Turtles");
FB::groupEnd();
FB::group('Test Group B');
FB::log('Hello World B');
FB::log('Plain Message');
FB::info('Info Message');
FB::warn('Warn Message');
FB::error('Error Message');
FB::log('Message', 'Optional Label');
FB::groupEnd();
$table[] = array('Col 1 Heading', 'Col 2 Heading', 'Col 2 Heading');
$table[] = array('Row 1 Col 1', 'Row 1 Col 2', 'Row 1 Col 2');
$table[] = array('Row 2 Col 1', 'Row 2 Col 2');
$table[] = array('Row 3 Col 1', 'Row 3 Col 2');
FB::table('Table Label', $table);
FB::trace('123', [1, 23, 4]);
예제 #2
0
 public static function sql_log()
 {
     self::sql_do_spool();
     if (IN_DEV) {
         if (count(self::$sqls) > 1) {
             $time = 0;
             foreach (self::$sqls as $v) {
                 $time += $v[0];
             }
             FB::table(count(self::$sqls) - 1 . ' SQL ' . $time . 'msec', self::$sqls);
         }
         FB::info(sprintf('%01.3f', microtime(true) - START), 'Temps php (sec)');
     }
 }
예제 #3
0
function test($table)
{
    FB::table('Test deep table', $table);
    FB::send(array('Test deep table', $table), FirePHP::TABLE);
    throw new Exception('Test Exception');
}
예제 #4
0
파일: Debug.php 프로젝트: 645248882/CocoPHP
 /**
  * Output for FirePHP
  * @uses http://www.firephp.org
  *
  * @return void
  */
 public static function firePHP()
 {
     echo "<pre>";
     // 页面汇总信息
     $table = array();
     $table[] = array('Total Time: ' . round(microtime(true) - $GLOBALS['_START_TIME'], 3));
     $table[] = array('Total Memory: ' . self::_size(round(memory_get_usage() - $GLOBALS['_START_MEM'], 3)));
     $table[] = array('Timezone: ' . date_default_timezone_get());
     isset($_SERVER['SERVER_ADDR']) && ($table[] = array('Server IP: ' . $_SERVER['SERVER_ADDR']));
     isset($_SERVER['HTTP_HOST']) && ($table[] = array('Server Host: ' . $_SERVER['HTTP_HOST']));
     FB::table('Debug Info', $table);
     // SQL
     if (isset($GLOBALS['_SQLs']) && !empty($GLOBALS['_SQLs'])) {
         // SQL Info
         $table = array();
         $table[] = array('Elapse', 'Host', 'Database', 'SQL', 'Params', 'RealSQL');
         foreach ($GLOBALS['_SQLs'] as $v) {
             $elapsed = round($v['time'] * 1000, 3);
             // SQL 耗时
             if ($v['params']) {
                 $table[] = array($elapsed . 'ms', $v['host'], $v['dbName'], $v['sql'], $v['params'], $v['realSql']);
             } else {
                 $table[] = array($elapsed . 'ms', $v['host'], $v['dbName'], $v['sql']);
             }
         }
         FB::table('SQL Info (' . count($GLOBALS['_SQLs']) . ' SQLs)', $table);
         // SQL Explain
         if (DEBUG_EXPLAIN_SQL) {
             $titles = array('id', 'select_type', 'table', 'type', 'possible_keys', 'key', 'key_len', 'ref', 'rows', 'Extra', 'sql');
             $table = array($titles);
             foreach ($GLOBALS['_SQLs'] as $v) {
                 if ($v['explain']) {
                     $line = array();
                     foreach ($titles as $title) {
                         $line[] = isset($v['explain'][$title]) ? $v['explain'][$title] : '-';
                     }
                     $table[] = $line;
                 }
             }
             FB::table('SQL Explain', $table);
         }
     }
     // 引入文件
     /*
     if ($files = get_included_files()) {
         $table = array();
         foreach ($files as $file) {
             $table[] = array($file);
         }
         FB::table('Included Files (' . count($files) . ' PHP files)', $table);
     }
     */
     print_r($table);
     // 全局变量、预定义变量
     FB::group('Predefined Variables', array('Collapsed' => true));
     FB::info($_COOKIE, '_COOKIE');
     FB::info($_ENV, '_ENV');
     FB::info($_FILES, '_FILES');
     FB::info($_GET, '_GET');
     FB::info($_POST, '_POST');
     FB::info($_REQUEST, '_REQUEST');
     FB::info($_SERVER, '_SERVER');
     isset($_SESSION) && FB::info($_SESSION, '_SESSION');
     FB::groupEnd();
 }
예제 #5
0
<?php

FB::group('Test Group');
FB::send('Hello World');
FB::groupEnd();
FB::log('Log Message');
FB::info('Info Message');
FB::warn('Info Message');
FB::error('Info Message');
FB::trace('Trace to here');
FB::send('Trace to here', FirePHP::TRACE);
FB::table('2 SQL queries took 0.06 seconds', array(array('SQL Statement', 'Time', 'Result'), array('SELECT * FROM Foo', '0.02', array('row1', 'row2')), array('SELECT * FROM Bar', '0.04', array('row1', 'row2'))));
FB::dump('PHP Version', phpversion());
예제 #6
0
 /**
  * リソースのデバック表示
  *
  * firePHPコンソールにリソースを表示します。
  *
  * @param BEAR_Ro $ro リソースオブジェクト
  *
  * @return void
  */
 public function debugShowResource(BEAR_Ro $ro)
 {
     $config = $ro->getConfig();
     if (!isset($config['method'])) {
         return;
     }
     $labelUri = "[resource] {$config['method']} {$config['uri']}";
     $labelUri .= $config['values'] ? '?' . http_build_query($config['values']) : "";
     $body = $ro->getBody();
     if (is_array($body) && isset($body[0]) && is_array($body[0])) {
         // bodyが表構造と仮定
         $table = array();
         $table[] = array_values(array_keys($body[0]));
         foreach ((array) $body as $key => $val) {
             $table[] = array_values((array) $val);
         }
         FB::table($labelUri, $table);
     } else {
         FB::group("{$labelUri}", array('Collapsed' => true));
         FB::log($body);
         FB::groupEnd();
     }
 }
예제 #7
0
 /**
  * Logs info about a file
  *
  * @author Anthony Short
  * @param $file
  * @return void
  */
 private static function _file($file, $name = false)
 {
     if ($name === false) {
         $name = $file;
     }
     # Log about the compiled file
     $contents = file_get_contents($file);
     $gzipped = gzcompress($contents, 9);
     $table = array();
     $table[] = array('Name', 'Value');
     $table[] = array('Compressed Size', Scaffold_Utils::readable_size($contents));
     $table[] = array('Gzipped Size', Scaffold_Utils::readable_size($gzipped));
     FB::table($name, $table);
 }
예제 #8
0
 /**
  * (non-PHPdoc)
  * @see debugObject::exception()
  */
 public function exception(Exception $e, $trace = null, $source = null, $lines = null)
 {
     if (error_reporting() & $e->getCode()) {
         $this->msg('exception \'' . get_class($e) . '\' with message \'[' . $e->getCode() . ']: ' . $e->getMessage() . '\' in ' . $e->getFile() . ':' . $e->getLine(), $e->getCode());
         if (isset($trace) || $this->_trace) {
             $trace_array = $e->getTrace();
             if (!empty($trace_array)) {
                 $trace_table = array();
                 $trace_table[] = array('File', 'Line', 'Instruction');
                 foreach ($e->getTrace() as $t) {
                     if ($t['function'] == 'PokemonErrorHandler') {
                         // elimino il 4^ argomento dell'error handler (in questo caso la funzione PokemonErrorHandler)
                         unset($t['args'][4]);
                         // perche' da' problemi di ricorsione in quanto contine riferiemnto a $GLOBAL
                     }
                     $trace_table[] = array(isset($t['file']) ? $t['file'] : '-', isset($t['line']) ? $t['line'] : '-', (isset($t['class']) ? $t['class'] . '::' : '') . (isset($t['function']) ? $t['function'] . '(' . (isset($t['args']) ? array_reduce($t['args'], array($this, 'args2string')) : '') . ')' : '-'));
                 }
                 FB::table('TRACE', $trace_table);
             }
         }
         if ((isset($source) || $this->_source) && method_exists($e, 'get_source')) {
             $lines = isset($lines) ? $lines : $this->_source_lines;
             $line = $e->getLine() - floor($lines / 2);
             $source_table = array();
             $source_table[] = array('Line', 'Code');
             foreach ($e->get_source($lines) as $l) {
                 $source_table[] = array($line++, $l);
             }
             FB::table('SOURCE', $source_table);
         }
         unset($msg);
     }
 }