Skip to content

Commit 8e23c66

Browse files
authored
Merge pull request #14 from UrosPurtic/master
Log formatted response from profiler when request takes more then x m…
2 parents d58acb3 + 6e9b4af commit 8e23c66

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/Profiler.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function setThreshold($threshold)
7676
public function getProfilerOutput($httpCode, $dbProfiler = 0, $responseElapsedTime = 0)
7777
{
7878
return $this->hasProfilers() && $this->shouldLogProfiler($httpCode, $responseElapsedTime)
79-
? $this->getFormatted($dbProfiler)
79+
? $this->getFormatted($dbProfiler, $responseElapsedTime)
8080
: [];
8181
}
8282

@@ -94,22 +94,22 @@ private function shouldLogProfiler($httpCode, $responseElapsedTime)
9494
return true;
9595
}
9696

97-
if($this->threshold && $responseElapsedTime > $this->threshold){
97+
if($this->isRequestTresholdExceded($responseElapsedTime)){
9898
return true;
9999
}
100100

101101
return self::LOG_ERRORS_ONLY && substr($httpCode, 0, 1) != 2;
102102
}
103103

104-
public function shouldLogProfilerOutput($responseElapsedTimeInMs)
104+
public function isRequestTresholdExceded($responseElapsedTime)
105105
{
106-
return $responseElapsedTimeInMs > $this->threshold;
106+
return $this->threshold && $responseElapsedTime > $this->threshold;
107107
}
108108

109109
/**
110110
* @return array
111111
*/
112-
private function getFormatted($dbProfiler)
112+
private function getFormatted($dbProfiler, $responseElapsedTime)
113113
{
114114
if (!$this->hasFormatted()) {
115115
$this->formatted = [];
@@ -124,7 +124,7 @@ private function getFormatted($dbProfiler)
124124
return $this->formatted;
125125
}
126126

127-
if ((int) $dbProfiler === 2) {
127+
if ((int) $dbProfiler === 2 || $this->isRequestTresholdExceded($responseElapsedTime)) {
128128
$timelineFormatted = [];
129129
foreach ($this->timeline as $queries) {
130130
foreach ($queries as $key => $query) {

0 commit comments

Comments
 (0)