1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Log.php
См. документацию.
1<?php
2
4
6use Exception;
7
8class Log
9{
10 public const DEFAULT_MARKER = 'DEBUG_TASKS';
11
12 private $marker;
13 private $currentPortal = '';
14 private $portals = [];
15
16 public function __construct(string $marker = self::DEFAULT_MARKER)
17 {
18 $this->marker = $marker;
19 }
20
25 public function collect($data): self
26 {
27 try
28 {
29 if (!Loader::includeModule('intranet'))
30 {
31 return $this;
32 }
33
34 $this->currentPortal = \CIntranetUtils::getHostName();
35
36 $this->checkPortal() && $this->save($data);
37 }
38 catch (Exception)
39 {
40 return $this;
41 }
42 return $this;
43 }
44
45 private function checkPortal(): bool
46 {
47 if (!$this->currentPortal)
48 {
49 return true;
50 }
51
52 if (empty($this->portals))
53 {
54 return true;
55 }
56
57 return in_array($this->currentPortal, $this->portals);
58 }
59
60 private function save($data): void
61 {
62 if (!is_scalar($data))
63 {
64 $data = var_export($data, true);
65 }
66
67 $message = [$this->marker];
68 $message[] = $data;
69 $message = implode("\n", $message);
70
71 AddMessage2Log($message, 'socialnetwork');
72 }
73}
Определения loader.php:13
__construct(string $marker=self::DEFAULT_MARKER)
Определения Log.php:16
const DEFAULT_MARKER
Определения Log.php:10
collect($data)
Определения Log.php:25
$data['IS_AVAILABLE']
Определения .description.php:13
AddMessage2Log($text, $module='', $traceDepth=6, $showArgs=false)
Определения tools.php:3941
Определения Log.php:3
$message
Определения payment.php:8