getFile() public static method

获取文件加载信息
public static getFile ( boolean $detail = false ) : integer | array
$detail boolean 是否显示详细
return integer | array
コード例 #1
0
ファイル: Html.php プロジェクト: GDdark/cici
 /**
  * 调试输出接口
  * @access public
  * @param Response  $response Response对象
  * @param array     $log 日志信息
  * @return bool
  */
 public function output(Response $response, array $log = [])
 {
     $request = Request::instance();
     $contentType = $response->getHeader('Content-Type');
     $accept = $request->header('accept');
     if (strpos($accept, 'application/json') === 0 || $request->isAjax()) {
         return false;
     } elseif (!empty($contentType) && strpos($contentType, 'html') === false) {
         return false;
     }
     // 获取基本信息
     $runtime = number_format(microtime(true), 8, '.', '') - THINK_START_TIME;
     $reqs = number_format(1 / $runtime, 2);
     $mem = number_format((memory_get_usage() - THINK_START_MEM) / 1024, 2);
     // 页面Trace信息
     if (isset($_SERVER['HTTP_HOST'])) {
         $uri = $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     } else {
         $uri = 'cmd:' . implode(' ', $_SERVER['argv']);
     }
     $base = ['请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $uri, '运行时间' => number_format($runtime, 6) . 's [ 吞吐率:' . $reqs . 'req/s ] 内存消耗:' . $mem . 'kb 文件加载:' . count(get_included_files()), '查询信息' => Db::$queryTimes . ' queries ' . Db::$executeTimes . ' writes ', '缓存信息' => Cache::$readTimes . ' reads,' . Cache::$writeTimes . ' writes', '配置加载' => count(Config::get())];
     if (session_id()) {
         $base['会话信息'] = 'SESSION_ID=' . session_id();
     }
     $info = Debug::getFile(true);
     // 页面Trace信息
     $trace = [];
     foreach ($this->config['trace_tabs'] as $name => $title) {
         $name = strtolower($name);
         switch ($name) {
             case 'base':
                 // 基本信息
                 $trace[$title] = $base;
                 break;
             case 'file':
                 // 文件信息
                 $trace[$title] = $info;
                 break;
             default:
                 // 调试信息
                 if (strpos($name, '|')) {
                     // 多组信息
                     $names = explode('|', $name);
                     $result = [];
                     foreach ($names as $name) {
                         $result = array_merge($result, isset($log[$name]) ? $log[$name] : []);
                     }
                     $trace[$title] = $result;
                 } else {
                     $trace[$title] = isset($log[$name]) ? $log[$name] : '';
                 }
         }
     }
     // 调用Trace页面模板
     ob_start();
     include $this->config['trace_file'];
     return ob_get_clean();
 }
コード例 #2
0
ファイル: Trace.php プロジェクト: cnzin/think
 /**
  * 日志写入接口
  * @access public
  * @param array $log 日志信息
  * @return bool
  */
 public function save(array $log = [])
 {
     if (IS_AJAX || IS_CLI || IS_API || 'html' != Config::get('default_return_type')) {
         // ajax cli api方式下不输出
         return false;
     }
     // 获取基本信息
     $runtime = microtime(true) - START_TIME;
     $reqs = number_format(1 / $runtime, 2);
     $runtime = number_format($runtime, 6);
     $mem = number_format((memory_get_usage() - START_MEM) / 1024, 2);
     // 页面Trace信息
     $base = ['请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], '运行时间' => "{$runtime}s [ 吞吐率:{$reqs}req/s ] 内存消耗:{$mem}kb 文件加载:" . count(get_included_files()), '查询信息' => \think\Db::$queryTimes . ' queries ' . \think\Db::$executeTimes . ' writes ', '缓存信息' => \think\Cache::$readTimes . ' reads,' . \think\Cache::$writeTimes . ' writes', '配置加载' => count(Config::get())];
     if (session_id()) {
         $base['会话信息'] = 'SESSION_ID=' . session_id();
     }
     $info = Debug::getFile(true);
     // 获取调试日志
     $debug = [];
     foreach ($log as $line) {
         $debug[$line['type']][] = $line['msg'];
     }
     // 页面Trace信息
     $trace = [];
     foreach ($this->config['trace_tabs'] as $name => $title) {
         $name = strtolower($name);
         switch ($name) {
             case 'base':
                 // 基本信息
                 $trace[$title] = $base;
                 break;
             case 'file':
                 // 文件信息
                 $trace[$title] = $info;
                 break;
             default:
                 // 调试信息
                 if (strpos($name, '|')) {
                     // 多组信息
                     $names = explode('|', $name);
                     $result = [];
                     foreach ($names as $name) {
                         $result = array_merge($result, isset($debug[$name]) ? $debug[$name] : []);
                     }
                     $trace[$title] = $result;
                 } else {
                     $trace[$title] = isset($debug[$name]) ? $debug[$name] : '';
                 }
         }
     }
     // 调用Trace页面模板
     ob_start();
     include $this->config['trace_file'];
     echo ob_get_clean();
     return true;
 }
コード例 #3
0
ファイル: trace.php プロジェクト: zhaomingliang/think
 /**
  * 日志写入接口
  * @access public
  * @param array $log 日志信息
  * @return void
  */
 public function save($log = [])
 {
     // 获取基本信息
     $current_uri = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $runtime = number_format(microtime(true) - START_TIME, 6);
     $reqs = number_format(1 / $runtime, 2);
     // 页面Trace信息
     $base = ['请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $current_uri, '运行时间' => "{$runtime}s [ 吞吐率:{$reqs}req/s ]", '内存消耗' => number_format((memory_get_usage() - START_MEM) / 1024, 2) . 'kb', '查询信息' => \think\Db::$queryTimes . ' queries ' . \think\Db::$executeTimes . ' writes ', '缓存信息' => \think\Cache::$readTimes . ' reads,' . \think\Cache::$writeTimes . ' writes', '文件加载' => count(get_included_files()), '配置加载' => count(\think\Config::get()), '会话信息' => 'SESSION_ID=' . session_id()];
     $info = \think\Debug::getFile(true);
     // 获取调试日志
     $debug = [];
     foreach ($log as $line) {
         $debug[$line['type']][] = $line['msg'];
     }
     // 页面Trace信息
     $trace = [];
     foreach ($this->tabs as $name => $title) {
         $name = strtolower($name);
         switch ($name) {
             case 'base':
                 // 基本信息
                 $trace[$title] = $base;
                 break;
             case 'file':
                 // 文件信息
                 $trace[$title] = $info;
                 break;
             default:
                 // 调试信息
                 if (strpos($name, '|')) {
                     // 多组信息
                     $names = explode('|', $name);
                     $result = [];
                     foreach ($names as $name) {
                         $result = array_merge($result, isset($debug[$name]) ? $debug[$name] : []);
                     }
                     $trace[$title] = $result;
                 } else {
                     $trace[$title] = isset($debug[$name]) ? $debug[$name] : '';
                 }
         }
     }
     // 调用Trace页面模板
     ob_start();
     include $this->config['trace_file'];
     echo ob_get_clean();
 }
コード例 #4
0
ファイル: debugTest.php プロジェクト: yuhongjie/think
 /**
  * @covers think\Debug::getFile
  * @todo Implement testGetFile().
  */
 public function testGetFile()
 {
     $count = \think\Debug::getFile();
     $this->assertEquals(count(get_included_files()), $count);
     $info = \think\Debug::getFile(true);
     $this->assertEquals(count(get_included_files()), count($info));
     $this->assertContains("KB", $info[0]);
 }