fix PropelLogger stopwatch events
* add queries like "SET NAMES 'UTF8';" * track only prepared statements * add named labels to the StopwatchEvents corresponding to the query counter
This commit is contained in:
parent
7b8acbccf4
commit
13f0e4a01a
@ -37,7 +37,7 @@ class PropelLogger
|
|||||||
*/
|
*/
|
||||||
protected $stopwatch;
|
protected $stopwatch;
|
||||||
|
|
||||||
private $isPrepare;
|
private $isPrepared;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@ -50,7 +50,7 @@ class PropelLogger
|
|||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->queries = array();
|
$this->queries = array();
|
||||||
$this->stopwatch = $stopwatch;
|
$this->stopwatch = $stopwatch;
|
||||||
$this->isPrepare = true;
|
$this->isPrepared = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -135,14 +135,17 @@ class PropelLogger
|
|||||||
$add = true;
|
$add = true;
|
||||||
|
|
||||||
if (null !== $this->stopwatch) {
|
if (null !== $this->stopwatch) {
|
||||||
if ($this->isPrepare) {
|
$trace = debug_backtrace();
|
||||||
$this->stopwatch->start('propel', 'propel');
|
$method = $trace[2]['args'][2];
|
||||||
$this->isPrepare = false;
|
|
||||||
|
$watch = 'Propel Query '.(count($this->queries)+1);
|
||||||
|
if ('PropelPDO::prepare' === $method) {
|
||||||
|
$this->isPrepared = true;
|
||||||
|
$this->stopwatch->start($watch, 'propel');
|
||||||
|
|
||||||
$add = false;
|
$add = false;
|
||||||
} else {
|
} elseif ($this->isPrepared) {
|
||||||
$this->stopwatch->stop('propel');
|
$this->stopwatch->stop($watch);
|
||||||
$this->isPrepare = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user