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.
This commit is contained in:
wolfcode
2024-09-20 09:49:26 +08:00
parent cb34bf1758
commit aeb3b28184

View File

@@ -63,7 +63,12 @@ class SystemLog
}
}catch (\Throwable $exception) {
}
$ip = $request->ip();
$ip = $request->ip();
// 限制记录的响应内容,避免过大
$response = json_encode($response->getData(), JSON_UNESCAPED_UNICODE);
$response = mb_substr($response, 0, 3000, 'utf-8');
$data = [
'admin_id' => session('admin.id'),
'title' => $title,
@@ -71,7 +76,7 @@ class SystemLog
'method' => $method,
'ip' => $ip,
'content' => json_encode($params, JSON_UNESCAPED_UNICODE),
'response' => json_encode($response->getData(), JSON_UNESCAPED_UNICODE),
'response' => $response,
'useragent' => $request->server('HTTP_USER_AGENT'),
'create_time' => time(),
];