Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
exceptionhandlerlog.php
1<?php
2
3namespace Bitrix\Main\Diag;
4
5use Psr\Log\LogLevel;
6
7abstract class ExceptionHandlerLog
8{
11 const IGNORED_ERROR = 2;
13 const ASSERTION = 4;
14 const FATAL = 5;
15
16 public static function logTypeToString($logType)
17 {
18 static $types = [
19 self::UNCAUGHT_EXCEPTION => 'UNCAUGHT_EXCEPTION',
20 self::CAUGHT_EXCEPTION => 'CAUGHT_EXCEPTION',
21 self::IGNORED_ERROR => 'IGNORED_ERROR',
22 self::LOW_PRIORITY_ERROR => 'LOW_PRIORITY_ERROR',
23 self::ASSERTION => 'ASSERTION',
24 self::FATAL => 'FATAL',
25 ];
26
27 if (isset($types[$logType]))
28 {
29 return $types[$logType];
30 }
31
32 return 'UNKNOWN';
33 }
34
35 public static function logTypeToLevel($logType)
36 {
37 static $types = [
38 self::UNCAUGHT_EXCEPTION => LogLevel::ERROR,
39 self::CAUGHT_EXCEPTION => LogLevel::ERROR,
40 self::IGNORED_ERROR => LogLevel::ERROR,
41 self::LOW_PRIORITY_ERROR => LogLevel::WARNING,
42 self::ASSERTION => LogLevel::CRITICAL,
43 self::FATAL => LogLevel::CRITICAL,
44 ];
45
46 if (isset($types[$logType]))
47 {
48 return $types[$logType];
49 }
50
51 return LogLevel::INFO;
52 }
53
54 abstract public function write($exception, $logType);
55
56 abstract public function initialize(array $options);
57}