Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
logger.php
1<?php
2
4
5use Throwable;
6
7class Logger
8{
9 private const DEFAULT_MARKER = 'DEBUG_CALENDAR';
10 private const MODULE_ID = 'calendar';
11
12 public function __construct(private string $marker = self::DEFAULT_MARKER)
13 {
14 }
15
16 public function log(mixed $data): void
17 {
18 if ($data instanceof Throwable)
19 {
20 $data = $data->getMessage();
21 }
22 elseif (!is_scalar($data))
23 {
24 $data = var_export($data, true);
25 }
26
27 $message = [$this->marker];
28 $message[] = $data;
29 $message = implode("\n", $message);
30
31 AddMessage2Log($message, static::MODULE_ID);
32 }
33}
__construct(private string $marker=self::DEFAULT_MARKER)
Definition logger.php:12