* * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ class RequestWriteLogsJob extends BaseJob { protected function process(): void { $params = $this->data['params']; // 提取请求参数 // 从参数中删除敏感信息 foreach ($params as $key => $value) { if (in_array($key, ['password', 'pwd', 'pwd_conf', 'original_pwd'])) { unset($params[$key]); } } $rpcResult = make(EasyAppServiceInterface::class)->getClientIPInfo([ 'ip' => $this->data['client_ip'] ]); $clientIPInfo = $rpcResult['result']['ip_info'] ?? ''; $logMessage = sprintf('%s %s', $this->data['client_ip'] . ' ' . $clientIPInfo, $this->data['method'] ); if (!empty($params)) { $logMessage .= ' params: ' . json_encode($params, JSON_UNESCAPED_UNICODE); } // 记录日志 $log = Log::get('request', 'request'); $log->info($logMessage); } }