Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit ad61aee

Browse files
committed
Add possibility set name debug data
1 parent ff67208 commit ad61aee

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

ggrachdev.debugbar/classes/general/BitrixDebugger/Debugger/NoticeDebugger.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@
1212
class NoticeDebugger extends FilterDebugger {
1313

1414
protected $log = [];
15+
16+
/*
17+
* Заголовок для дебага
18+
*/
19+
protected $nameDebug = null;
20+
21+
public function name(string $name)
22+
{
23+
$this->nameDebug = $name;
24+
return $this;
25+
}
1526

1627
public function notice(...$item) {
1728
$this->noticeRaw('notice', $item);
@@ -149,10 +160,14 @@ public function noticeRaw(string $type, array $arLogItems) {
149160
$db = debug_backtrace();
150161

151162
$this->log[$type][] = [
163+
'name' => $this->nameDebug,
152164
'file' => $db[1]['file'],
153165
'line' => $db[1]['line'],
154166
'data' => $arLogItems
155167
];
168+
169+
// Сбрасываем имя
170+
$this->nameDebug = null;
156171
}
157172

158173
if (ShowModeDebuggerValidator::needShowInCode($this->getConfiguratorDebugger())) {

ggrachdev.debugbar/classes/general/BitrixDebugger/View/DebugBarView.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,21 @@ public static function render(Debugger $debugger): string {
8484
}
8585

8686
$needHideBlocks = !(in_array($typeLog, self::SYSTEM_KEYS_LOG));
87+
88+
if(is_array($logValue) && \sizeof($logValue) <= 10)
89+
{
90+
$needHideBlocks = false;
91+
}
92+
else if(\is_string($logValue) || \is_numeric($logValue))
93+
{
94+
$needHideBlocks = false;
95+
}
8796

88-
$viewLeft .= str_replace(['<span style="color: #0000BB">&lt;?</span>', '<span style="color: #0000BB">?&gt;</span>', '&lt;?', '?&gt;', '&lt;?php'], ['', '', '', ''], '<pre>' . \ggrach_highlight_data($logValue, $needHideBlocks) . $lineView . '</pre>');
97+
$viewLeft .= str_replace(
98+
['<span style="color: #0000BB">&lt;?</span>', '<span style="color: #0000BB">?&gt;</span>', '&lt;?', '?&gt;', '&lt;?php'],
99+
['', '', '', ''],
100+
'<pre>' . ($arLogType['name'] !== null ? \ggrach_highlight_data($logValue, $needHideBlocks, $arLogType['name']) : \ggrach_highlight_data($logValue, $needHideBlocks)) . $lineView . '</pre>'
101+
);
89102
}
90103
}
91104

ggrachdev.debugbar/functions.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @param type $data
77
* @return type
88
*/
9-
function ggrach_highlight_data($data = [], $needHideBlocks = false) {
9+
function ggrach_highlight_data($data = [], $needHideBlocks = false, $name = null) {
1010

1111
$viewResult = '';
1212

@@ -54,18 +54,24 @@ function ggrach_highlight_data($data = [], $needHideBlocks = false) {
5454
return $viewRes;
5555
};
5656

57-
$highlight = function ($in, $opened = true) use ($highlightItem) {
57+
$highlight = function ($in, $opened = true) use ($highlightItem, $name) {
5858

5959
$view = '<div>';
6060

6161
if ($opened) {
6262
$opened = ' open';
6363
}
6464

65-
if (is_object($in) or is_array($in)) {
65+
if ($name && !(is_object($in) || is_array($in))) {
66+
$in = [
67+
$in
68+
];
69+
}
70+
71+
if (is_object($in) || is_array($in)) {
6672
$view .= '<details' . $opened . '>';
6773
$view .= '<summary style="cursor: pointer; margin-top: 5px; margin-bottom: 5px; text-decoration: underline;">';
68-
$view .= (is_object($in)) ? 'Object {' . count((array) $in) . '}' : 'Array [' . count($in) . ']';
74+
$view .= (is_object($in)) ? ($name ? $name . ' - ' : '') . 'Object {' . count((array) $in) . '}' : ($name ? $name . ' - ' : '') . 'Array [' . count($in) . ']';
6975
$view .= '</summary>';
7076
$view .= $highlightItem($in, $opened);
7177
$view .= '</details>';
@@ -77,7 +83,7 @@ function ggrach_highlight_data($data = [], $needHideBlocks = false) {
7783
$in = \strip_tags($in);
7884

7985
if (\strlen($in) > 200) {
80-
$in = '[Очень длинная строка]';
86+
$in = '[Very long string]';
8187
}
8288

8389
break;
@@ -95,7 +101,6 @@ function ggrach_highlight_data($data = [], $needHideBlocks = false) {
95101

96102
$view .= '</div>';
97103

98-
99104
return $view;
100105
};
101106

0 commit comments

Comments
 (0)