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

Commit 28ff737

Browse files
committed
Улучшена структура, GD() поменял на DD()
1 parent 7c64a9f commit 28ff737

6 files changed

Lines changed: 22 additions & 20 deletions

File tree

File renamed without changes.

initializer.php

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@
33
/**
44
* https://github.com/ggrachdev/BitrixDebugger
55
* @author ggrachdev@yandex.ru
6-
* @version 0.02
6+
* @version 0.03 beta
77
*
88
* Пример дебага:
99
*
10-
* GD()->notice('Моя переменная', 'Моя переменная 2');
11-
* GD()->error('Моя переменная', 'Моя переменная 2');
12-
* GD()->warning('Моя переменная', 'Моя переменная 2');
13-
* GD()->success('Моя переменная', 'Моя переменная 2');
10+
* DD()->notice('Моя переменная', 'Моя переменная 2');
11+
* DD()->error('Моя переменная', 'Моя переменная 2');
12+
* DD()->warning('Моя переменная', 'Моя переменная 2');
13+
* DD()->success('Моя переменная', 'Моя переменная 2');
1414
*
1515
* Залогировать в файлы
16-
* GD()->noticeLog('Моя переменная', 'Моя переменная 2');
17-
* GD()->errorLog('Моя переменная', 'Моя переменная 2');
18-
* GD()->warningLog('Моя переменная', 'Моя переменная 2');
19-
* GD()->successLog('Моя переменная', 'Моя переменная 2');
16+
* DD()->noticeLog('Моя переменная', 'Моя переменная 2');
17+
* DD()->errorLog('Моя переменная', 'Моя переменная 2');
18+
* DD()->warningLog('Моя переменная', 'Моя переменная 2');
19+
* DD()->successLog('Моя переменная', 'Моя переменная 2');
2020
*
2121
* Нужно подключить этот файл в init.php
2222
* include 'BitrixDebugger/initializer.php';
2323
*
2424
*/
2525
use Bitrix\Main\Page\Asset;
2626

27-
if (!empty($_SERVER['DOCUMENT_ROOT'])) {
27+
if (\php_sapi_name() !== 'cli') {
2828

2929
$ggrachDebuggerRootPath = str_replace($_SERVER['DOCUMENT_ROOT'], '', __DIR__);
3030

@@ -49,25 +49,23 @@
4949
$ggrachDebuggerConfigurator->setLogPath('success', __DIR__ . '/logs/success.log');
5050
$ggrachDebuggerConfigurator->setLogPath('notice', __DIR__ . '/logs/notice.log');
5151

52-
global $DD;
53-
$DD = new \GGrach\BitrixDebugger\Debugger\Debugger($ggrachDebuggerConfigurator, $ggrachDebugBarConfigurator);
52+
$GLOBALS["DD"] = new \GGrach\BitrixDebugger\Debugger\Debugger($ggrachDebuggerConfigurator, $ggrachDebugBarConfigurator);
5453

5554
/*
5655
* code - отображать дебаг-данные в коде
5756
* debug_bar - отображать дебаг-данные в debug_bar
5857
*/
59-
$DD->setShowModes(['code', 'debug_bar']);
58+
$GLOBALS["DD"]->setShowModes(['code', 'debug_bar']);
6059

6160
function DD() {
62-
global $DD;
63-
return $DD;
61+
return $GLOBALS["DD"];
6462
}
6563

66-
if (\GGrach\BitrixDebugger\Validator\ShowModeDebuggerValidator::needShowInDebugBar($DD)) {
64+
if (\GGrach\BitrixDebugger\Validator\ShowModeDebuggerValidator::needShowInDebugBar($GLOBALS["DD"])) {
6765

6866
Asset::getInstance()->addJs($ggrachDebuggerRootPath . "/assets/DebugBar/js/initializer.js");
69-
Asset::getInstance()->addCss($ggrachDebuggerRootPath . '/assets/DebugBar/themes/general.css');
70-
Asset::getInstance()->addCss($ggrachDebuggerRootPath . '/assets/DebugBar/themes/' . $ggrachDebugBarConfigurator->getColorTheme() . '/theme.css');
67+
Asset::getInstance()->addCss($ggrachDebuggerRootPath . '/assets/DebugBar/css/themes/general.css');
68+
Asset::getInstance()->addCss($ggrachDebuggerRootPath . '/assets/DebugBar/css/themes/' . $ggrachDebugBarConfigurator->getColorTheme() . '/theme.css');
7169

7270
include 'functions.php';
7371

src/BitrixDebugger/Debugger/Debugger.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,10 @@ protected function noticeRaw(string $type, $arLogItems) {
159159
}
160160

161161
if (ShowModeDebuggerValidator::needShowInCode($this)) {
162-
162+
163+
foreach ($arLogItems as $item) {
164+
echo \ggrach_highlight_data($item);
165+
}
163166
}
164167
}
165168

src/BitrixDebugger/Validator/ShowModeDebuggerValidator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ public static function needShowInDebugBar(ShowModableContract $debugger) {
1616
}
1717

1818
public static function needShowInCode(ShowModableContract $debugger) {
19-
return in_array('code', $debugger->getShowModes());
19+
global $USER;
20+
return in_array('code', $debugger->getShowModes()) && \is_object($USER) && $USER->IsAdmin();
2021
}
2122

2223
}

0 commit comments

Comments
 (0)