Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/im/lib/V2/ |
Upload File : |
<?php namespace Bitrix\Im\V2; use Bitrix\Main\ErrorCollection; use Bitrix\Main\Web\Json; class Logger { private const MODULE = 'im'; private const TRACE_DEPTH = 10; private string $uniqueString; public function __construct(string $uniqueString) { $this->uniqueString = $uniqueString; } public function log(string $text): void { $text = 'unique-string: ' . $this->uniqueString . "\n" . $text; AddMessage2Log($text, self::MODULE, self::TRACE_DEPTH); } public function logArray(array $array): void { $text = Json::encode($array); $this->log($text); } public function logThrowable(\Throwable $throwable): void { $array = [ 'type' => 'exception', 'message' => $throwable->getMessage(), 'code' => $throwable->getCode(), 'trace' => $throwable->getTraceAsString(), ]; $this->logArray($array); } public function logErrors(ErrorCollection $errors): void { $array = []; /** @var \Bitrix\Main\Error $error */ foreach ($errors as $error) { $array[] = [ 'type' => 'error', 'message' => $error->getMessage(), 'code' => $error->getCode(), 'customData' => $error->getCustomData(), ]; } $this->logArray($array); } }