vb2005xu 发表于 2013-1-25 03:14:00

我终于实现了 把 firephp 集成进 magento了 终于能监测 sql了

坑爹的 magento , 我终于实现了 把 firephp 集成进 magento了 终于能监测 sql了
 
look
 
http://dl.iteye.com/upload/attachment/0071/9370/c36d41ad-3ecc-3ef7-9b52-b0f546d81f8c.jpg
 
 
自己建了个类
<?php/** * Varien_Iwpken_Dumper 用于测试输出 * * @author xuxh */final class Varien_Iwpken_Dumper {/** * 使用 Firephp 输出调试信息 ** @param mixed $obj * @param string $title * @param string $level*/static function fb($obj, $title = '', $level = 'info'){static $fb = NULL;if ( !$fb ){if (!class_exists('FirePHP',false)){require_once dirname(__FILE__) . '/3rd/FirePHP.class.php';}$fb = FirePHP::getInstance(true);}switch($level){case 'info':case 'debug':$fb->info($obj, $title);break;case 'notice':$fb->log($obj, $title);break;case 'exception':$fb->warn($obj, $title);break;case 'error':$fb->error($obj, $title);break;}}/** * 输出变量的内容,通常用于调试 * * @package Core * * @param mixed $vars 要输出的变量 * @param string $label * @param boolean $return */static function dump($vars, $label = '', $return = false){    if (ini_get('html_errors')) {      $content = "<pre>\n";      if ($label != '') {            $content .= "<strong>{$label} :</strong>\n";      }      $content .= htmlspecialchars(print_r($vars, true));      $content .= "\n</pre>\n";    } else {      $content = $label . " :\n" . print_r($vars, true);    }    if ($return) { return $content; }    echo $content;    return null;}/** * 显示应用程序执行路径,通常用于调试 * * @package Core * * @return string */static function dump_trace(){    $debug = debug_backtrace();    $lines = '';    $index = 0;    for ($i = 0; $i < count($debug); $i++) {      if ($i == 0) { continue; }      $file = $debug[$i];      if ($file['file'] == '') { continue; }      if (substr($file['file'], 0, strlen(COREPATH)) != COREPATH) {            $line = "#<strong>{$index} {$file['file']}({$file['line']}): </strong>";      } else {            $line = "#{$index} {$file['file']}({$file['line']}): ";      }      if (isset($file['class'])) {            $line .= "{$file['class']}{$file['type']}";      }      $line .= "{$file['function']}(";      if (isset($file['args']) && count($file['args'])) {            foreach ($file['args'] as $arg) {                $line .= gettype($arg) . ', ';            }            $line = substr($line, 0, -2);      }      $line .= ')';      $lines .= $line . "\n";      $index++;    } // for    $lines .= "#{$index} {main}\n";    if (ini_get('html_errors')) {      echo nl2br(str_replace(' ', ' ', $lines));    } else {      echo $lines;    }}/** * 打印异常的详细信息 * * @param Exception $ex * @param boolean $return 为 true 时返回输出信息,而不是直接显示 * @param boolean $deployMode 为 true 时不输出物理路径信息 */static function print_ex($ex, $return = false, $deployMode = false){    $out = "exception '" . get_class($ex) . "'";    if ($ex->getMessage() != '') {      $out .= " with message '" . $ex->getMessage() . "'";    }    if ($deployMode) {      $out .= ' in ' . basename($ex->getFile()) . ':' . $ex->getLine() . "\n\n";    } else {      $out .= ' in ' . $ex->getFile() . ':' . $ex->getLine() . "\n\n";      $out .= $ex->getTraceAsString();    }    if ($return) { return $out; }    if (ini_get('html_errors')) {      echo nl2br(htmlspecialchars($out));    } else {      echo $out;    }    return '';}}  
变更了 Varien\Db\Adapter\Pdo\Mysql.php 的某些方法 ..... 于是 后面就似乎更好了
 
貌似里面有调试的东西,但是不知道怎么用 擦 难不成官方开发都不用 调试的么?
页: [1]
查看完整版本: 我终于实现了 把 firephp 集成进 magento了 终于能监测 sql了