1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
RestServerProcessLogger.php
См. документацию.
1<?php
2
3namespace Bitrix\Rest\Tools\Diagnostics;
4
5use Bitrix\Main;
6use Bitrix\Rest\LogTable;
7use Exception;
8
10{
11 private ?int $requestLogId;
12
13 public function __construct(private readonly \CRestServer $restServer)
14 {
15 }
16
17 public function logRequest(): void
18 {
19 if (!is_null($this->restServer))
20 {
21 $request = Main\Context::getCurrent()?->getRequest();
22 $logger = LoggerManager::getInstance()->getLogger();
23 $logger?->info('Start', [
24 'CLIENT_ID' => $this->restServer->getClientId(),
25 'PASSWORD_ID' => $this->restServer->getPasswordId(),
26 'SCOPE' => $this->restServer->getScope(),
27 'METHOD' => $this->restServer->getMethod(),
28 'REQUEST_METHOD' => $request->getRequestMethod(),
29 'REQUEST_URI' => $request->getRequestUri(),
30 'REQUEST_AUTH' => $this->restServer->getAuth(),
31 'REQUEST_DATA' => $this->restServer->getQuery(),
32 ]);
33 $this->requestLogId = $logger instanceof DataBaseLogger ? $logger->getLogId() : null;
34 }
35 }
36
40 public function logResponse(mixed $responseData): bool
41 {
42 if (is_null($this->requestLogId))
43 {
44 return false;
45 }
46
47 LogTable::filterResponseData($responseData);
48 $this->restServer->sendHeaders();
49 $fields = [
50 'RESPONSE_STATUS' => \CHTTP::GetLastStatus(),
51 'RESPONSE_DATA' => $responseData,
52 'MESSAGE' => 'Successful response',
53 ];
54
55 return LogTable::update($this->requestLogId, $fields)->isSuccess();
56 }
57}
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
Определения catalog_reindex.php:36
static filterResponseData(&$data)
Определения log.php:158
__construct(private readonly \CRestServer $restServer)
Определения RestServerProcessLogger.php:13
static GetLastStatus()
Определения http.php:486
$fields
Определения yandex_run.php:501