Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
eventlogger.php
1<?php
2
10namespace Bitrix\Main\Diag;
11
12class EventLogger extends Logger
13{
14 protected $module;
15 protected $auditType;
16 protected $callback;
17
23 public function __construct(string $module = null, string $auditType = null, callable $callback = null)
24 {
25 $this->module = $module;
26 $this->auditType = $auditType;
27 $this->callback = $callback;
28 }
29
30 protected function logMessage(string $level, string $message)
31 {
32 if (is_callable($this->callback))
33 {
34 $info = call_user_func($this->callback, $this->context, $this->message);
35 }
36
37 \CEventLog::Add([
38 'SEVERITY' => $info['SEVERITY'] ?? strtoupper($level),
39 'AUDIT_TYPE_ID' => $info['AUDIT_TYPE_ID'] ?? $this->auditType,
40 'MODULE_ID' => $info['MODULE_ID'] ?? $this->module,
41 'ITEM_ID' => $info['ITEM_ID'] ?? '',
42 'DESCRIPTION' => $info['DESCRIPTION'] ?? $message
43 ]);
44 }
45}
logMessage(string $level, string $message)
__construct(string $module=null, string $auditType=null, callable $callback=null)