1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
loggerservice.php
См. документацию.
1<?php
2
3namespace Bitrix\Location\Infrastructure\Service;
4
5use Bitrix\Location\Common\BaseService;
6use Bitrix\Location\Infrastructure\Service\LoggerService\ILogger;
7use Bitrix\Location\Infrastructure\Service\Config\Container;
8
9final class LoggerService extends BaseService implements ILogger
10{
12 protected static $instance;
13
15 private $logger;
16 private $logLevel;
17 private $eventsToLog;
18
19 public function log(int $level, string $message, int $eventType = 0, array $context = [])
20 {
21 if(!$this->isLevelSatisfied($level) && !$this->isEventSatisfied($eventType))
22 {
23 return;
24 }
25
26 if(count($context) > 0)
27 {
28 $message = $this->interpolate($message, $context);
29 }
30
31 $this->logger->log($level, $message, $eventType, $context);
32 }
33
34 protected function isLevelSatisfied(int $level): bool
35 {
36 return $this->logLevel >= $level;
37 }
38
39 protected function isEventSatisfied(int $eventType): bool
40 {
41 return $eventType > 0 && in_array($eventType, $this->eventsToLog);
42 }
43
44 protected function __construct(Container $config)
45 {
46 parent::__construct($config);
47 $loggerClass = $config->get('logger');
48 $this->logLevel = $config->get('logLevel');
49 $this->eventsToLog = $config->get('eventsToLog');
50 $this->logger = new $loggerClass();
51 }
52
53 private function interpolate($message, array $context = array())
54 {
55 $replace = [];
56
57 foreach ($context as $key => $val)
58 {
59 if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString')))
60 {
61 $replace['{' . $key . '}'] = $val;
62 }
63 }
64
65 return strtr($message, $replace);
66 }
67}
log(int $level, string $message, int $eventType=0, array $context=[])
Определения loggerservice.php:19
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$context
Определения csv_new_setup.php:223
$message
Определения payment.php:8
$config
Определения quickway.php:69
if(empty($signedUserToken)) $key
Определения quickway.php:257
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$val
Определения options.php:1793