mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 20:52:48 +08:00
改进Trave调试输出 socket方式支持所有的请求
This commit is contained in:
@@ -201,12 +201,8 @@ class Debug
|
||||
|
||||
if ($response instanceof Redirect) {
|
||||
//TODO 记录
|
||||
} elseif (strpos($accept, 'application/json') === 0 || $request->isAjax()) {
|
||||
//TODO 记录
|
||||
} elseif (!empty($contentType) && strpos($contentType, 'html') === false) {
|
||||
//TODO 记录
|
||||
} else {
|
||||
$output = $trace->output(Log::getLog());
|
||||
$output = $trace->output($response, Log::getLog());
|
||||
if (is_string($output)) {
|
||||
// trace调试信息注入
|
||||
$content = $response->getContent();
|
||||
|
||||
@@ -15,6 +15,8 @@ use think\Cache;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Debug;
|
||||
use think\Request;
|
||||
use think\Response;
|
||||
|
||||
/**
|
||||
* 浏览器调试输出
|
||||
@@ -36,11 +38,20 @@ class Console
|
||||
/**
|
||||
* 调试输出接口
|
||||
* @access public
|
||||
* @param array $log 日志信息
|
||||
* @param Response $response Response对象
|
||||
* @param array $log 日志信息
|
||||
* @return bool
|
||||
*/
|
||||
public function output(array $log = [])
|
||||
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);
|
||||
|
||||
@@ -15,6 +15,8 @@ use think\Cache;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Debug;
|
||||
use think\Request;
|
||||
use think\Response;
|
||||
|
||||
/**
|
||||
* 页面Trace调试
|
||||
@@ -36,12 +38,20 @@ class Html
|
||||
/**
|
||||
* 调试输出接口
|
||||
* @access public
|
||||
* @param array $log 日志信息
|
||||
* @param Response $response Response对象
|
||||
* @param array $log 日志信息
|
||||
* @return bool
|
||||
*/
|
||||
public function output(array $log = [])
|
||||
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);
|
||||
|
||||
@@ -57,10 +57,11 @@ class Socket
|
||||
/**
|
||||
* 调试输出接口
|
||||
* @access public
|
||||
* @param array $logs 日志信息
|
||||
* @param Response $response Response对象
|
||||
* @param array $log 日志信息
|
||||
* @return bool
|
||||
*/
|
||||
public function output(array $logs = [])
|
||||
public function output(Response $response, array $log = [])
|
||||
{
|
||||
if (!$this->check()) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user