1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Logger.php
См. документацию.
1<?php
2
3declare(strict_types=1);
4
5namespace Bitrix\Socialnetwork\Log;
6
7use Bitrix\Main\Error;
8use Bitrix\Main\ErrorCollection;
9use Throwable;
10
11class Logger
12{
13 public static function log(mixed $data, string $marker = 'DEBUG_SOCIALNETWORK'): void
14 {
15 $log = new Log($marker);
16
17 if ($data instanceof Throwable)
18 {
19 $collectedData = static::collectThrowable($data);
20 }
21 elseif ($data instanceof Error)
22 {
23 $collectedData = static::collectError($data);
24 }
25 elseif ($data instanceof ErrorCollection)
26 {
27 $collectedData = static::collectErrorCollection($data);
28 }
29 else
30 {
31 $collectedData = $data;
32 }
33
34 $log->collect($collectedData);
35 }
36
37 private static function collectThrowable(Throwable $throwable): array
38 {
39 return [
40 'type' => 'throwable',
41 'message' => $throwable->getMessage(),
42 'file' => $throwable->getFile(),
43 'line' => $throwable->getLine(),
44 'backtrace' => $throwable->getTraceAsString(),
45 ];
46 }
47
48 private static function collectError(Error $error): array
49 {
50 return [
51 'type' => 'error',
52 'message' => $error->getMessage(),
53 'code' => $error->getCode(),
54 'customData' => $error->getCustomData(),
55 ];
56 }
57
58 private static function collectErrorCollection(ErrorCollection $errorCollection): array
59 {
60 $errors = [];
61 foreach ($errorCollection as $error)
62 {
63 $errors[] = static::collectError($error);
64 }
65
66 return [
67 'type' => 'errorCollection',
68 'errors' => $errors,
69 ];
70 }
71}
Определения error.php:15
static log(mixed $data, string $marker='DEBUG_SOCIALNETWORK')
Определения Logger.php:13
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$errors
Определения iblock_catalog_edit.php:74
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$error
Определения subscription_card_product.php:20