fix request log

This commit is contained in:
2026-03-18 08:37:14 +08:00
parent cdc88ba1e4
commit 58afb7c385
7 changed files with 24 additions and 11 deletions
+8 -2
View File
@@ -57,7 +57,10 @@ class OperationLogService
$container = \Hyperf\Context\ApplicationContext::getContainer();
$request = $container->get(ServerRequestInterface::class);
return RequestLogMiddleware::getClientIp($request);
} catch (\Throwable) {
} catch (\Throwable $e) {
Log::get()->warning('OperationLogService: 获取客户端 IP 失败', [
'error' => $e->getMessage(),
]);
return null;
}
}
@@ -75,7 +78,10 @@ class OperationLogService
return $user->id;
}
return $user?->getId();
} catch (\Throwable) {
} catch (\Throwable $e) {
Log::get()->warning('OperationLogService: 获取当前用户 ID 失败', [
'error' => $e->getMessage(),
]);
return null;
}
}