@@ -15,6 +15,11 @@ class Profiler
1515 */
1616 private $ formatted ;
1717
18+ /**
19+ * @var array
20+ */
21+ private $ timeline ;
22+
1823 /**
1924 * @var array|TickerAbstract[]
2025 */
@@ -57,10 +62,10 @@ public function setLogLevel($logLevel)
5762 /**
5863 * @return array
5964 */
60- public function getProfilerOutput ($ httpCode )
65+ public function getProfilerOutput ($ httpCode, $ dbProfiler = 0 )
6166 {
6267 return $ this ->hasProfilers () && $ this ->shouldLogProfiler ($ httpCode )
63- ? $ this ->getFormatted ()
68+ ? $ this ->getFormatted ($ dbProfiler )
6469 : [];
6570 }
6671
@@ -83,15 +88,32 @@ private function shouldLogProfiler($httpCode)
8388 /**
8489 * @return array
8590 */
86- private function getFormatted ()
91+ private function getFormatted ($ dbProfiler )
8792 {
8893 if (!$ this ->hasFormatted ()) {
8994 $ this ->formatted = [];
90- foreach ($ this ->profilers as $ profiler ) {
95+ $ this ->timeline = [];
96+ foreach ($ this ->profilers as $ profiler ) {
9197 $ this ->formatted [$ profiler ->getName ()] = $ profiler ->getFormatted ();
98+ $ this ->timeline [] = $ profiler ->getQueries ();
99+ }
100+ }
101+
102+ if ((int ) $ dbProfiler === 1 ) {
103+ return $ this ->formatted ;
104+ }
105+
106+ if ((int ) $ dbProfiler === 2 ) {
107+ $ timelineFormatted = [];
108+ foreach ($ this ->timeline as $ queries ) {
109+ foreach ($ queries as $ key => $ query ) {
110+ $ timelineFormatted [$ key ] = $ query ;
111+ }
92112 }
113+ ksort ($ timelineFormatted , SORT_NUMERIC );
114+ return $ timelineFormatted ;
93115 }
94- return $ this -> formatted ;
116+ return [ ' unsuported request parameter ' ] ;
95117 }
96118
97119 /**
0 commit comments