@@ -104,12 +104,12 @@ public function processLogEntries($event = null)
104104 $ this ->dumper ->crateRaw = false ;
105105 $ this ->data = $ this ->debug ->data ->get ();
106106 $ this ->data ['log ' ] = \array_values ($ this ->data ['log ' ]);
107- $ this ->buildJsonData ();
107+ $ this ->processChannels ();
108108 $ this ->max = $ this ->getMaxLength ();
109109 $ encoded = $ this ->encode ($ this ->jsonData );
110110 if ($ this ->max && \strlen ($ encoded ) > $ this ->max ) {
111111 $ this ->reduceData ();
112- $ this ->buildJsonData ();
112+ $ this ->processChannels ();
113113 $ encoded = $ this ->encode ($ this ->jsonData );
114114 $ encoded = $ this ->assertEncodedLength ($ encoded );
115115 }
@@ -164,34 +164,14 @@ private function assertEncodedLength($encoded)
164164 return $ this ->encode ($ this ->jsonData );
165165 }
166166
167- /**
168- * Build Chromelogger JSON
169- *
170- * @return void
171- */
172- protected function buildJsonData ()
173- {
174- $ this ->jsonData ['rows ' ] = [];
175- $ this ->processAlerts ();
176- $ this ->processSummary ();
177- $ this ->processLog ();
178- $ heading = ['PHP ' , $ this ->getRequestMethodUri ()];
179- if (!$ this ->cfg ['group ' ]) {
180- \array_unshift ($ this ->jsonData ['rows ' ], [$ heading , null , 'info ' ]);
181- return ;
182- }
183- \array_unshift ($ this ->jsonData ['rows ' ], [$ heading , null , 'groupCollapsed ' ]);
184- \array_push ($ this ->jsonData ['rows ' ], [[], null , 'groupEnd ' ]);
185- }
186-
187167 /**
188168 * Calculate header size
189169 *
190170 * @return int
191171 */
192172 protected function calcHeaderSize ()
193173 {
194- $ this ->buildJsonData ();
174+ $ this ->processChannels ();
195175 $ encoded = $ this ->encode ($ this ->jsonData );
196176 return \strlen (self ::HEADER_NAME . ': ' ) + \strlen ($ encoded );
197177 }
@@ -224,6 +204,73 @@ protected function getMaxLength()
224204 return \min ($ maxVals );
225205 }
226206
207+ /**
208+ * Process log entries for given channel
209+ *
210+ * @param Debug $instance Debug instance
211+ *
212+ * @return void
213+ */
214+ protected function processChannel (Debug $ instance )
215+ {
216+ $ channelKey = $ instance ->getCfg ('channelKey ' , Debug::CONFIG_DEBUG );
217+ $ name = $ instance ->getCfg ('channelName ' , Debug::CONFIG_DEBUG );
218+ $ this ->setChannelRegex ('#^ ' . \preg_quote ($ channelKey , '# ' ) . '(\.|$)# ' );
219+
220+ $ include = $ this ->testChannelKeyMatch ($ channelKey , $ this ->cfg ['channels ' ])
221+ && !$ this ->testChannelKeyMatch ($ channelKey , $ this ->cfg ['channelsExclude ' ]);
222+
223+ if ($ include === false ) {
224+ return ;
225+ }
226+
227+ if ($ instance === $ instance ->rootInstance ) {
228+ $ name = $ this ->debug ->i18n ->trans ('channel.log ' );
229+ }
230+
231+ return $ this ->processLogEntryViaEvent (new LogEntry (
232+ $ this ->debug ,
233+ 'groupCollapsed ' ,
234+ [$ name ]
235+ ))
236+ . $ this ->processAlerts ()
237+ . $ this ->processSummary ()
238+ . $ this ->processLog ()
239+ . $ this ->processLogEntryViaEvent (new LogEntry (
240+ $ this ->debug ,
241+ 'groupEnd '
242+ ));
243+ }
244+
245+ /**
246+ * Process log entries grouped by top-level channels ("tabs")
247+ *
248+ * @return void
249+ */
250+ protected function processChannels ()
251+ {
252+ $ this ->jsonData ['rows ' ] = [];
253+ $ channels = $ this ->debug ->getChannelsTop ();
254+ foreach ($ channels as $ instance ) {
255+ $ key = $ instance ->getCfg ('channelKey ' , Debug::CONFIG_DEBUG );
256+ if (\in_array ($ key , $ this ->cfg ['channelsExclude ' ], true )) {
257+ continue ;
258+ }
259+ if ($ instance ->getCfg ('output ' , Debug::CONFIG_DEBUG ) === false ) {
260+ continue ;
261+ }
262+ $ this ->processChannel ($ instance );
263+ }
264+ $ heading = ['PHP ' , $ this ->getRequestMethodUri ()];
265+ if (!$ this ->cfg ['group ' ]) {
266+ // not wrapping in group, just prepend an info heading
267+ \array_unshift ($ this ->jsonData ['rows ' ], [$ heading , null , 'info ' ]);
268+ return ;
269+ }
270+ \array_unshift ($ this ->jsonData ['rows ' ], [$ heading , null , 'groupCollapsed ' ]);
271+ \array_push ($ this ->jsonData ['rows ' ], [[], null , 'groupEnd ' ]);
272+ }
273+
227274 /**
228275 * Attempt to remove log entries to get header length < max
229276 *
0 commit comments