mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-10 00:22:48 +08:00
改进trace
This commit is contained in:
@@ -245,30 +245,10 @@ class Response
|
|||||||
*/
|
*/
|
||||||
public function contentType($contentType, $charset = 'utf-8')
|
public function contentType($contentType, $charset = 'utf-8')
|
||||||
{
|
{
|
||||||
$this->contentType = $contentType;
|
|
||||||
$this->charset = $charset;
|
|
||||||
|
|
||||||
$this->header['Content-Type'] = $contentType . '; charset=' . $charset;
|
$this->header['Content-Type'] = $contentType . '; charset=' . $charset;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取页面输出类型
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getContentType()
|
|
||||||
{
|
|
||||||
return $this->contentType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取页面输出字符集
|
|
||||||
*/
|
|
||||||
public function getCharset()
|
|
||||||
{
|
|
||||||
return $this->charset;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取头部信息
|
* 获取头部信息
|
||||||
* @param string $name 头部名称
|
* @param string $name 头部名称
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ use think\Config;
|
|||||||
use think\Log;
|
use think\Log;
|
||||||
use think\Request;
|
use think\Request;
|
||||||
use think\Response;
|
use think\Response;
|
||||||
|
use think\response\Redirect;
|
||||||
|
|
||||||
class Trace
|
class Trace
|
||||||
{
|
{
|
||||||
@@ -23,13 +24,22 @@ class Trace
|
|||||||
|
|
||||||
$type = isset($config['type']) ? $config['type'] : 'Html';
|
$type = isset($config['type']) ? $config['type'] : 'Html';
|
||||||
|
|
||||||
if ($type !== false && !Request::instance()->isAjax() && $response->getContentType() == 'text/html') {
|
if ($type !== false) {
|
||||||
|
$request = Request::instance();
|
||||||
|
$accept = $request->header('accept');
|
||||||
|
$contentType = $response->getHeader('Content-Type');
|
||||||
|
|
||||||
$class = false !== strpos($type, '\\') ? $type : '\\think\\debug\\trace\\' . ucwords($type);
|
$class = false !== strpos($type, '\\') ? $type : '\\think\\debug\\trace\\' . ucwords($type);
|
||||||
|
|
||||||
unset($config['type']);
|
unset($config['type']);
|
||||||
$trace = new $class($config);
|
$trace = new $class($config);
|
||||||
|
|
||||||
|
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(Log::getLog());
|
||||||
|
|
||||||
$content = $response->getContent();
|
$content = $response->getContent();
|
||||||
@@ -45,3 +55,4 @@ class Trace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user