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

Commit 41b804d

Browse files
authored
Merge pull request #4 from ggrachdev/dev
0.0.4
2 parents 6bc6060 + a157ad2 commit 41b804d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+858
-388
lines changed
-191 KB
Binary file not shown.

assets/images/git/example.png

106 KB
Loading

initializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* https://github.com/ggrachdev/BitrixDebugger
55
6-
* @version 0.03 beta
6+
* @version 0.0.4 beta
77
*
88
* Пример дебага:
99
*

initializers/server.php

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,62 @@
33
use Bitrix\Main\Page\Asset;
44

55
$ggrachDebuggerRootPath = str_replace($_SERVER['DOCUMENT_ROOT'], '', __DIR__ . '/..');
6-
$ggrachPathLogFolder = \realpath('.'.$ggrachDebuggerRootPath.'/logs');
6+
$ggrachPathLogFolder = \realpath('.' . $ggrachDebuggerRootPath . '/logs');
77

88
\Bitrix\Main\Loader::registerAutoLoadClasses(null, [
9-
"\GGrach\BitrixDebugger\Debugger\Debugger" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Debugger/Debugger.php",
10-
"\GGrach\BitrixDebugger\Debugger\DebuggerShowModable" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Debugger/DebuggerShowModable.php",
11-
"\GGrach\BitrixDebugger\Contract\ShowModableContract" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Contract/ShowModableContract.php",
12-
"\GGrach\BitrixDebugger\Configurator\DebuggerConfigurator" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Configurator/DebuggerConfigurator.php",
13-
"\GGrach\BitrixDebugger\Configurator\DebugBarConfigurator" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Configurator/DebugBarConfigurator.php",
14-
"\GGrach\BitrixDebugger\Cache\RuntimeCache" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Cache/RuntimeCache.php",
15-
"\GGrach\BitrixDebugger\Validator\ShowModeDebuggerValidator" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Validator/ShowModeDebuggerValidator.php",
16-
"\GGrach\BitrixDebugger\Representer\DebugBarRepresenter" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Representer/DebugBarRepresenter.php",
17-
"\GGrach\Writer\FileWriter" => $ggrachDebuggerRootPath . "/src/Writer/FileWriter.php",
18-
"\GGrach\Writer\Contract\WritableContract" => $ggrachDebuggerRootPath . "/src/Writer/Contract/WritableContract.php",
19-
"\GGrach\BitrixDebugger\Events\OnEndBufferContent" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Events/OnEndBufferContent.php"
9+
"\GGrach\BitrixDebugger\Debugger\Debugger" => $ggrachDebuggerRootPath . "/module/ggrachdev.debugbar/classes/general/BitrixDebugger/Debugger/Debugger.php",
10+
"\GGrach\BitrixDebugger\Debugger\NoticeDebugger" => $ggrachDebuggerRootPath . "/module/ggrachdev.debugbar/classes/general/BitrixDebugger/Debugger/NoticeDebugger.php",
11+
"\GGrach\BitrixDebugger\Debugger\LogFileDebugger" => $ggrachDebuggerRootPath . "/module/ggrachdev.debugbar/classes/general/BitrixDebugger/Debugger/LogFileDebugger.php",
12+
"\GGrach\BitrixDebugger\Debugger\ConfigurationDebugger" => $ggrachDebuggerRootPath . "/module/ggrachdev.debugbar/classes/general/BitrixDebugger/Debugger/ConfigurationDebugger.php",
13+
"\GGrach\BitrixDebugger\Contract\ShowModableContract" => $ggrachDebuggerRootPath . "/module/ggrachdev.debugbar/classes/general/BitrixDebugger/Contract/ShowModableContract.php",
14+
"\GGrach\BitrixDebugger\Configurator\DebuggerConfigurator" => $ggrachDebuggerRootPath . "/module/ggrachdev.debugbar/classes/general/BitrixDebugger/Configurator/DebuggerConfigurator.php",
15+
"\GGrach\BitrixDebugger\Configurator\DebugBarConfigurator" => $ggrachDebuggerRootPath . "/module/ggrachdev.debugbar/classes/general/BitrixDebugger/Configurator/DebugBarConfigurator.php",
16+
"\GGrach\BitrixDebugger\Cache\RuntimeCache" => $ggrachDebuggerRootPath . "/module/ggrachdev.debugbar/classes/general/BitrixDebugger/Cache/RuntimeCache.php",
17+
"\GGrach\BitrixDebugger\Validator\ShowModeDebuggerValidator" => $ggrachDebuggerRootPath . "/module/ggrachdev.debugbar/classes/general/BitrixDebugger/Validator/ShowModeDebuggerValidator.php",
18+
"\GGrach\BitrixDebugger\Representer\DebugBarRepresenter" => $ggrachDebuggerRootPath . "/module/ggrachdev.debugbar/classes/general/BitrixDebugger/Representer/DebugBarRepresenter.php",
19+
"\GGrach\Writer\FileWriter" => $ggrachDebuggerRootPath . "/module/ggrachdev.debugbar/classes/general/Writer/FileWriter.php",
20+
"\GGrach\Writer\Contract\WritableContract" => $ggrachDebuggerRootPath . "/module/ggrachdev.debugbar/classes/general/Writer/Contract/WritableContract.php",
21+
"\GGrach\BitrixDebugger\Events\OnEndBufferContent" => $ggrachDebuggerRootPath . "/module/ggrachdev.debugbar/classes/general/BitrixDebugger/Events/OnEndBufferContent.php"
2022
]);
2123

2224
$ggrachDebuggerConfigurator = new \GGrach\BitrixDebugger\Configurator\DebuggerConfigurator();
2325
$ggrachDebugBarConfigurator = new \GGrach\BitrixDebugger\Configurator\DebugBarConfigurator();
2426

25-
$ggrachDebuggerConfigurator->setLogPath('error', $ggrachPathLogFolder . '/error.log');
26-
$ggrachDebuggerConfigurator->setLogPath('warning', $ggrachPathLogFolder . '/warning.log');
27-
$ggrachDebuggerConfigurator->setLogPath('success', $ggrachPathLogFolder . '/success.log');
28-
$ggrachDebuggerConfigurator->setLogPath('notice', $ggrachPathLogFolder . '/notice.log');
27+
$ggrachDebuggerConfigurator->setLogPath('error', $ggrachPathLogFolder . '/error.log')
28+
->setLogPath('warning', $ggrachPathLogFolder . '/warning.log')
29+
->setLogPath('success', $ggrachPathLogFolder . '/success.log')
30+
->setLogPath('notice', $ggrachPathLogFolder . '/notice.log');
2931

3032
$GLOBALS["DD"] = new \GGrach\BitrixDebugger\Debugger\Debugger($ggrachDebuggerConfigurator, $ggrachDebugBarConfigurator);
3133

3234
/*
3335
* code - отображать дебаг-данные в коде
3436
* debug_bar - отображать дебаг-данные в debug_bar
3537
*/
36-
$GLOBALS["DD"]->setShowModes(['debug_bar']);
38+
$GLOBALS["DD"]->getConfiguratorDebugger()->setShowModes(['debug_bar']);
39+
40+
function DD(...$data) {
41+
if (!empty($data)) {
42+
foreach ($data as $item) {
43+
$GLOBALS["DD"]->notice($item);
44+
}
45+
}
3746

38-
function DD() {
3947
return $GLOBALS["DD"];
4048
}
4149

42-
if (\GGrach\BitrixDebugger\Validator\ShowModeDebuggerValidator::needShowInDebugBar($GLOBALS["DD"])) {
50+
if (\GGrach\BitrixDebugger\Validator\ShowModeDebuggerValidator::needShowInDebugBar(DD()->getConfiguratorDebugger())) {
51+
52+
Asset::getInstance()->addJs(
53+
$ggrachDebuggerRootPath . '/module/ggrachdev.debugbar/install/js/initializer.js'
54+
);
55+
Asset::getInstance()->addCss(
56+
$ggrachDebuggerRootPath . '/module/ggrachdev.debugbar/install/css/general.css'
57+
);
58+
Asset::getInstance()->addCss(
59+
$ggrachDebuggerRootPath . '/module/ggrachdev.debugbar/install/css/' . $ggrachDebugBarConfigurator->getColorTheme() . '/theme.css'
60+
);
4361

44-
Asset::getInstance()->addJs($ggrachDebuggerRootPath . "/assets/DebugBar/js/initializer.js");
45-
Asset::getInstance()->addCss($ggrachDebuggerRootPath . '/assets/DebugBar/css/themes/general.css');
46-
Asset::getInstance()->addCss($ggrachDebuggerRootPath . '/assets/DebugBar/css/themes/' . $ggrachDebugBarConfigurator->getColorTheme() . '/theme.css');
47-
48-
include __DIR__.'/../functions.php';
49-
include __DIR__.'/../events.php';
62+
include __DIR__ . '/../module/ggrachdev.debugbar/functions.php';
63+
include __DIR__ . '/../module/ggrachdev.debugbar/events.php';
5064
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
defined('B_PROLOG_INCLUDED') and (B_PROLOG_INCLUDED === true) or die();
3+
use Bitrix\Main\Localization\Loc;
4+
Loc::loadMessages(__FILE__);
5+
$aMenu = array(
6+
array(
7+
'parent_menu' => 'global_menu_content',
8+
'sort' => 400,
9+
'text' => "Òåñòîâûé ìîäóëü",
10+
'title' => "",
11+
'url' => 'perfmon_table.php?lang=ru&table_name=brainkit_test',
12+
'items_id' => 'menu_references'
13+
)
14+
);
15+
return $aMenu;

src/BitrixDebugger/.gitkeep renamed to module/ggrachdev.debugbar/classes/general/BitrixDebugger/.gitkeep

File renamed without changes.

src/BitrixDebugger/Cache/RuntimeCache.php renamed to module/ggrachdev.debugbar/classes/general/BitrixDebugger/Cache/RuntimeCache.php

File renamed without changes.

src/BitrixDebugger/Configurator/.gitkeep renamed to module/ggrachdev.debugbar/classes/general/BitrixDebugger/Configurator/.gitkeep

File renamed without changes.

src/BitrixDebugger/Configurator/DebugBarConfigurator.php renamed to module/ggrachdev.debugbar/classes/general/BitrixDebugger/Configurator/DebugBarConfigurator.php

File renamed without changes.

src/BitrixDebugger/Configurator/DebuggerConfigurator.php renamed to module/ggrachdev.debugbar/classes/general/BitrixDebugger/Configurator/DebuggerConfigurator.php

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
namespace GGrach\BitrixDebugger\Configurator;
44

5+
use \GGrach\BitrixDebugger\Contract\ShowModableContract;
6+
57
/**
68
* Description of DebugConfigurator
79
*
810
* @author ggrachdev
911
*/
10-
class DebuggerConfigurator {
12+
class DebuggerConfigurator implements ShowModableContract {
1113

1214
/**
1315
* Путь до лог файлов разного уровня
@@ -28,6 +30,53 @@ class DebuggerConfigurator {
2830
*/
2931
protected $logChunkDelimeter = "\n======\n";
3032

33+
/**
34+
* Где показывать
35+
*
36+
* code - в коде
37+
* debug_bar - в дебаг-баре
38+
*
39+
* @var array
40+
*/
41+
protected $showModes = ['code', 'debug_bar'];
42+
43+
public function getShowModes(): array {
44+
return $this->showModes;
45+
}
46+
47+
public function getShowModesEnum(): array {
48+
return ['code', 'debug_bar'];
49+
}
50+
51+
public function setShowModes(array $showModes): bool {
52+
$result = true;
53+
54+
if (!empty($showModes)) {
55+
56+
$avaliableModes = $this->getShowModesEnum();
57+
58+
// @todo array_udiff
59+
foreach ($showModes as $mode) {
60+
if (!\in_array($mode, $avaliableModes)) {
61+
$result = false;
62+
break;
63+
}
64+
}
65+
66+
if ($result) {
67+
$this->showModes = $showModes;
68+
}
69+
} else {
70+
$result = false;
71+
}
72+
73+
return $result;
74+
}
75+
76+
public function setShowMode(string $showMode): bool {
77+
return $this->setShowModes([$showMode]);
78+
}
79+
3180
public function setLogPath(string $logType, string $pathFile): self {
3281
$this->logPaths[$logType] = $pathFile;
3382
return $this;
@@ -55,13 +104,17 @@ public function getLogPath(string $typeLog) {
55104
}
56105
}
57106

107+
/**
108+
* Получить разделитель при записи в лог-файл
109+
*
110+
* @return type
111+
*/
58112
public function getLogChunkDelimeter() {
59113
return $this->logChunkDelimeter;
60114
}
61115

62116
public function setLogChunkDelimeter(string $logChunkDelimeter): self {
63117
$this->logChunkDelimeter = $logChunkDelimeter;
64-
65118
return $this;
66119
}
67120

0 commit comments

Comments
 (0)