mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 07:12:47 +08:00
trace日志驱动简化显示
This commit is contained in:
@@ -40,18 +40,16 @@ class Trace
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 获取基本信息
|
// 获取基本信息
|
||||||
$current_uri = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
$runtime = number_format(microtime(true) - START_TIME, 6);
|
||||||
$runtime = number_format(microtime(true) - START_TIME, 6);
|
$reqs = number_format(1 / $runtime, 2);
|
||||||
$reqs = number_format(1 / $runtime, 2);
|
$mem = number_format((memory_get_usage() - START_MEM) / 1024, 2);
|
||||||
|
|
||||||
// 页面Trace信息
|
// 页面Trace信息
|
||||||
$base = [
|
$base = [
|
||||||
'请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $current_uri,
|
'请求信息' => 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 ]",
|
'运行时间' => "{$runtime}s [ 吞吐率:{$reqs}req/s ] 内存消耗:{$mem}kb 文件加载:" . count(get_included_files()),
|
||||||
'内存消耗' => number_format((memory_get_usage() - START_MEM) / 1024, 2) . 'kb',
|
|
||||||
'查询信息' => \think\Db::$queryTimes . ' queries ' . \think\Db::$executeTimes . ' writes ',
|
'查询信息' => \think\Db::$queryTimes . ' queries ' . \think\Db::$executeTimes . ' writes ',
|
||||||
'缓存信息' => \think\Cache::$readTimes . ' reads,' . \think\Cache::$writeTimes . ' writes',
|
'缓存信息' => \think\Cache::$readTimes . ' reads,' . \think\Cache::$writeTimes . ' writes',
|
||||||
'文件加载' => count(get_included_files()),
|
|
||||||
'配置加载' => count(\think\Config::get()),
|
'配置加载' => count(\think\Config::get()),
|
||||||
'会话信息' => 'SESSION_ID=' . session_id(),
|
'会话信息' => 'SESSION_ID=' . session_id(),
|
||||||
];
|
];
|
||||||
@@ -69,13 +67,13 @@ class Trace
|
|||||||
foreach ($this->tabs as $name => $title) {
|
foreach ($this->tabs as $name => $title) {
|
||||||
$name = strtolower($name);
|
$name = strtolower($name);
|
||||||
switch ($name) {
|
switch ($name) {
|
||||||
case 'base': // 基本信息
|
case 'base': // 基本信息
|
||||||
$trace[$title] = $base;
|
$trace[$title] = $base;
|
||||||
break;
|
break;
|
||||||
case 'file': // 文件信息
|
case 'file': // 文件信息
|
||||||
$trace[$title] = $info;
|
$trace[$title] = $info;
|
||||||
break;
|
break;
|
||||||
default: // 调试信息
|
default: // 调试信息
|
||||||
if (strpos($name, '|')) {
|
if (strpos($name, '|')) {
|
||||||
// 多组信息
|
// 多组信息
|
||||||
$names = explode('|', $name);
|
$names = explode('|', $name);
|
||||||
|
|||||||
Reference in New Issue
Block a user