From 36038516e0924f9dd27b800e7a9d8f38b71f9401 Mon Sep 17 00:00:00 2001 From: wolfcode <37436228+wolf-leo@users.noreply.github.com> Date: Fri, 20 Sep 2024 09:51:17 +0800 Subject: [PATCH] fix(SystemLog): limit response content in admin middleware Implement a limitation on the amount of response content recorded in the system logs to avoid excessively large entries. The response is now truncated to 3000 characters, enhancing performance and readability while still capturing essential data. --- app/admin/middleware/SystemLog.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/admin/middleware/SystemLog.php b/app/admin/middleware/SystemLog.php index 13dc381..2779bd5 100644 --- a/app/admin/middleware/SystemLog.php +++ b/app/admin/middleware/SystemLog.php @@ -66,8 +66,8 @@ class SystemLog $ip = $request->ip(); // 限制记录的响应内容,避免过大 - $response = json_encode($response->getData(), JSON_UNESCAPED_UNICODE); - $response = mb_substr($response, 0, 3000, 'utf-8'); + $_response = json_encode($response->getData(), JSON_UNESCAPED_UNICODE); + $_response = mb_substr($_response, 0, 3000, 'utf-8'); $data = [ 'admin_id' => session('admin.id'), @@ -76,7 +76,7 @@ class SystemLog 'method' => $method, 'ip' => $ip, 'content' => json_encode($params, JSON_UNESCAPED_UNICODE), - 'response' => $response, + 'response' => $_response, 'useragent' => $request->server('HTTP_USER_AGENT'), 'create_time' => time(), ];