55use GGrach \BitrixDebugger \Configurator \DebuggerConfigurator ;
66use GGrach \BitrixDebugger \Configurator \DebugBarConfigurator ;
77use GGrach \BitrixDebugger \Contract \ShowModableContract ;
8-
8+ use GGrach \BitrixDebugger \Validator \ShowModeDebuggerValidator ;
9+ use GGrach \BitrixDebugger \Debugger \DebuggerShowModable ;
910
1011/**
1112 * Description of Debugger
1213 *
1314 * @author ggrachdev
1415 * @version 0.01
1516 */
16- class Debugger implements ShowModableContract {
17-
18- public function __construct ($ debuggerConfigurator = null , $ debugBarConfigurator = null ) {
19- if ($ debuggerConfigurator === null ) {
20- $ this ->configuratorDebugger = new DebuggerConfigurator ();
21- } elseif ($ debuggerConfigurator instanceof DebuggerConfigurator) {
22- $ this ->configuratorDebugger = $ debuggerConfigurator ;
23- }
24-
25- if ($ debugBarConfigurator === null ) {
26- $ this ->configuratorDebugBar = new DebugBarConfigurator ();
27- } elseif ($ debugBarConfigurator instanceof DebugBarConfigurator) {
28- $ this ->configuratorDebugBar = $ debugBarConfigurator ;
29- }
30- }
17+ class Debugger extends DebuggerShowModable implements ShowModableContract {
3118
3219 /**
3320 *
3421 * @var DebuggerConfigurator
3522 */
36- private $ configuratorDebugger ;
23+ protected $ configuratorDebugger ;
3724
3825 /**
3926 *
4027 * @var DebugBarConfigurator
4128 */
42- private $ configuratorDebugBar ;
29+ protected $ configuratorDebugBar ;
4330
4431 /**
4532 * Лог
4633 *
4734 * @var array
4835 */
49- private $ log = [];
36+ protected $ log = [];
5037
5138 /**
5239 * a - показывать только для администратора
5340 * d - показывать только в дебаг-баре
5441 *
5542 * @var string
5643 */
57- private $ options = 'ad ' ;
44+ protected $ options = 'ad ' ;
5845
59- /**
60- * Где показывать
61- *
62- * everywhere - и в дебаг-баре и в коде и залогировать
63- * code - в коде
64- * debug_bar - в дебаг-баре
65- * log - залогировать
66- * no - не показывать нигде
67- *
68- * @var array
69- */
70- protected $ showModes = ['everywhere ' ];
71-
72- public function getShowModes ()
73- {
74- return $ this ->showModes ;
46+ public function __construct ($ debuggerConfigurator = null , $ debugBarConfigurator = null ) {
47+ if ($ debuggerConfigurator === null ) {
48+ $ this ->configuratorDebugger = new DebuggerConfigurator ();
49+ } elseif ($ debuggerConfigurator instanceof DebuggerConfigurator) {
50+ $ this ->configuratorDebugger = $ debuggerConfigurator ;
51+ }
52+
53+ if ($ debugBarConfigurator === null ) {
54+ $ this ->configuratorDebugBar = new DebugBarConfigurator ();
55+ } elseif ($ debugBarConfigurator instanceof DebugBarConfigurator) {
56+ $ this ->configuratorDebugBar = $ debugBarConfigurator ;
57+ }
7558 }
7659
77- public function options ($ options ) {
78-
60+ public function options (array $ options ) {
61+ $ this -> options = $ options ;
7962 }
8063
8164 public function notice (...$ item ) {
@@ -90,21 +73,33 @@ public function success(...$item) {
9073 $ this ->noticeRaw ('success ' , $ item );
9174 }
9275
93- public function noticeRaw (string $ type , $ items ) {
76+ /**
77+ * Кастомизированное уведомление
78+ *
79+ * @param type $typeNotice
80+ * @param type $item
81+ */
82+ public function debug ($ typeNotice , ...$ item ) {
83+ $ this ->noticeRaw ($ typeNotice , $ item );
84+ }
85+
86+ protected function noticeRaw (string $ type , $ items ) {
9487
95- if ($ this -> needShowInDebugBar ()) {
96- $ this ->log [] = $ items ;
88+ if (ShowModeDebuggerValidator:: needShowInDebugBar ($ this )) {
89+ $ this ->log = array_merge ( $ this -> log , $ items) ;
9790 }
98- }
9991
100- public function getShowModesEnum (): array {
101- // @todo
102- return [];
103- }
92+ if (ShowModeDebuggerValidator::needShowInCode ($ this )) {
93+
94+ }
10495
105- public function setShowModes (array $ showModes ): bool {
106- // @todo
107- return true ;
96+ if (ShowModeDebuggerValidator::needWriteInLog ($ this )) {
97+ $ logFile = $ this ->configuratorDebugger ->getLogPath ($ type );
98+
99+ if ($ logFile ) {
100+
101+ }
102+ }
108103 }
109104
110105}
0 commit comments