feat(log): 新增框架日志查看器,integrate log viewer and improve log management

- Add log viewer functionality using wolf-leo/phplogviewer package
- Implement log record feature in admin system
- Update log table to include log record button
- Configure default and common log modules in logviewer config

Signed-off-by: wolfcode <37436228+wolf-leo@users.noreply.github.com>
This commit is contained in:
wolfcode
2024-10-09 09:51:25 +08:00
parent 4b8e163454
commit a1d4aa97d5
5 changed files with 36 additions and 2 deletions

View File

@@ -95,4 +95,12 @@ class Log extends AdminController
return Excel::exportData($list, $header, $fileName, 'xlsx');
}
/**
* @NodeAnnotation(title="框架日志")
*/
public function record(): string
{
return (new \Wolfcode\PhpLogviewer\thinkphp\LogViewer())->fetch();
}
}

View File

@@ -1,6 +1,7 @@
<div class="layuimini-container">
<div class="layuimini-main">
<table id="currentTable" class="layui-table layui-hide"
data-auth-record="{:auth('system.log/record')}"
lay-filter="currentTable">
</table>
</div>

View File

@@ -36,7 +36,8 @@
"ext-json": "*",
"qiniu/php-sdk": "v7.11.0",
"ext-mysqli": "*",
"ext-pdo": "*"
"ext-pdo": "*",
"wolf-leo/phplogviewer": "^0.05.0"
},
"require-dev": {
"symfony/var-dumper": ">=4.2",

13
config/logviewer.php Normal file
View File

@@ -0,0 +1,13 @@
<?php
return [
// 默认显示日志应用模块
'default_module' => 'admin',
// 常用的日志应用模块
'modules' => [
'admin',
'home',
'index',
'api'
],
];

View File

@@ -14,7 +14,18 @@ define(["jquery", "easy-admin"], function ($, ea) {
ea.table.render({
init: init,
lineStyle: 'height: auto;word-break: break-all;',
toolbar: ['refresh', 'export'],
toolbar: ['refresh', 'export',
[{
text: '框架日志',
url: 'system.log/record',
method: 'open',
auth: 'record',
class: 'layui-btn layui-btn-sm',
icon: 'fa fa-book',
extend: 'data-width="95%" data-height="95%"'
},
]
],
cols: [[
{field: 'id', width: 80, title: 'ID', search: false},
{field: 'month', width: 80, title: '日志月份', hide: true, search: 'time', timeType: 'month', searchValue: util.toDateString(new Date(), 'yyyy-MM')},