协程版仓库后端项目
Some checks failed
Build Docker / build (push) Has been cancelled

This commit is contained in:
2025-07-08 14:59:47 +08:00
commit 0b2299c427
134 changed files with 19277 additions and 0 deletions

View File

@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
namespace App\Job;
use App\JsonRpc\EasyAppServiceInterface;
use App\Log\Log;
use function Hyperf\Support\make;
/**
* Author: ykxiao
* Date: 2025/6/4
* Time: 上午10:23
* Description: 请求日志写入任务.
*
* (c) ykxiao <yk_9001@hotmail.com>
*
* 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 %s',
$this->data['client_ip'] . ' ' . $clientIPInfo,
$this->data['method'],
$this->data['uri']
);
if (!empty($params)) {
$logMessage .= ' params: ' . json_encode($params, JSON_UNESCAPED_UNICODE);
}
// 记录日志
$log = Log::get('request', 'request');
$log->info($logMessage);
}
}