Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
syslogger.php
1<?php
2
10namespace Bitrix\Main\Diag;
11
12class SysLogger extends Logger
13{
14 protected $prefix;
15 protected $flags;
16 protected $facility;
17 protected $connected = false;
18
19 public function __construct(string $prefix = '', int $flags = LOG_ODELAY, int $facility = LOG_USER)
20 {
21 $this->prefix = $prefix;
22 $this->flags = $flags;
23 $this->facility = $facility;
24 }
25
26 protected function connect()
27 {
28 if (!$this->connected)
29 {
30 openlog($this->prefix, $this->flags, $this->facility);
31
32 $this->connected = true;
33 }
34 }
35
36 protected function logMessage(string $level, string $message)
37 {
38 $this->connect();
39
40 syslog(static::$supportedLevels[$level], $message);
41 }
42
48 public static function priorityToLevel(int $priority)
49 {
50 static $levels = null;
51
52 if ($levels === null)
53 {
54 $levels = array_flip(static::$supportedLevels);
55 }
56
57 return $levels[$priority] ?? \Psr\Log\LogLevel::WARNING;
58 }
59}
logMessage(string $level, string $message)
Definition syslogger.php:36
__construct(string $prefix='', int $flags=LOG_ODELAY, int $facility=LOG_USER)
Definition syslogger.php:19
static priorityToLevel(int $priority)
Definition syslogger.php:48