chore: 增加运行时错误日志读取诊断接口
这个提交包含在:
@@ -45,6 +45,23 @@ class Level extends Common
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
if (input('read_err_log')) {
|
||||||
|
$logDir = defined('LOG_PATH') ? LOG_PATH : RUNTIME_PATH . 'log/';
|
||||||
|
$files = glob($logDir . '*/*.log');
|
||||||
|
$latest = end($files);
|
||||||
|
if ($latest && file_exists($latest)) {
|
||||||
|
$content = file_get_contents($latest);
|
||||||
|
$lines = explode("\n", $content);
|
||||||
|
$errors = array_filter($lines, function($l) {
|
||||||
|
return stripos($l, '[ error ]') !== false || stripos($l, 'exception') !== false || stripos($l, 'Level') !== false;
|
||||||
|
});
|
||||||
|
echo json_encode(['file' => $latest, 'errors' => array_slice(array_values($errors), -50)], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||||
|
} else {
|
||||||
|
echo json_encode(['logDir' => $logDir, 'files' => $files]);
|
||||||
|
}
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!$this->request->isAjax()) {
|
if (!$this->request->isAjax()) {
|
||||||
return $this->view->fetch();
|
return $this->view->fetch();
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户