1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
exceptionhandlerformatter.php
См. документацию.
1<?php
2
3namespace Bitrix\Main\Diag;
4
5use Bitrix\Main;
6
8{
9 const MAX_CHARS = 30;
10
11 const SHOW_PARAMETERS = 1;
12 const DELIMITER = '----------';
13
20 public static function format($exception, $htmlMode = false, $level = 0)
21 {
22 $formatter = new LogFormatter((bool)($level & static::SHOW_PARAMETERS), static::MAX_CHARS);
23
24 $result = '';
25 do
26 {
27 if ($result != '')
28 {
29 $result .= "Previous exception: ";
30 }
31 $result .= $formatter->format("{exception}{trace}{delimiter}\n", [
32 'exception' => $exception,
33 'trace' => static::getTrace($exception),
34 ]);
35 }
36 while (($exception = $exception->getPrevious()) !== null);
37
38 if ($htmlMode)
39 {
40 $result = '<pre>'.Main\Text\HtmlFilter::encode($result).'</pre>';
41 }
42
43 return $result;
44 }
45
50 protected static function getTrace($exception)
51 {
52 $backtrace = $exception->getTrace();
53
54 $skip = "Bitrix\\Main\\Diag\\ExceptionHandler";
55
56 $result = [];
57 foreach ($backtrace as $item)
58 {
59 if (!isset($item['class']) || ($item['class'] != $skip))
60 {
61 $result[] = $item;
62 }
63 }
64
65 return $result;
66 }
67
71 protected static function getMessage($exception)
72 {
73 return $exception->getMessage().' ('.$exception->getCode().')';
74 }
75
79 public static function severityToString($severity)
80 {
81 return LogFormatter::severityToString($severity);
82 }
83
87 protected static function getArguments($args, $level)
88 {
89 $formatter = new LogFormatter((bool)($level & static::SHOW_PARAMETERS), static::MAX_CHARS);
90
91 return $formatter->formatArguments($args);
92 }
93
97 protected static function convertArgumentToString($arg, $level)
98 {
99 $formatter = new LogFormatter((bool)($level & static::SHOW_PARAMETERS), static::MAX_CHARS);
100
101 return $formatter->formatArgument($arg);
102 }
103
107 protected static function getFileLink($file, $line)
108 {
109 if (!empty($file))
110 {
111 return $file . ':' . $line;
112 }
113 return '';
114 }
115}
static format($exception, $htmlMode=false, $level=0)
Определения exceptionhandlerformatter.php:20
static convertArgumentToString($arg, $level)
Определения exceptionhandlerformatter.php:97
static severityToString($severity)
Определения logformatter.php:288
$result
Определения get_property_values.php:14