[Propel] Added Propel to Stopwatch
This commit is contained in:
parent
b80951c21c
commit
b3fd2fad9f
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Bridge\Propel1\Logger;
|
namespace Symfony\Bridge\Propel1\Logger;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpKernel\Debug\Stopwatch;
|
||||||
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,15 +32,25 @@ class PropelLogger
|
|||||||
*/
|
*/
|
||||||
protected $queries;
|
protected $queries;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \Symfony\Component\HttpKernel\Debug\Stopwatch
|
||||||
|
*/
|
||||||
|
protected $stopwatch;
|
||||||
|
|
||||||
|
private $isPrepare;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param LoggerInterface $logger A LoggerInterface instance
|
* @param LoggerInterface $logger A LoggerInterface instance
|
||||||
|
* @param Stopwatch $stopwatch A Stopwatch instance
|
||||||
*/
|
*/
|
||||||
public function __construct(LoggerInterface $logger = null)
|
public function __construct(LoggerInterface $logger = null, Stopwatch $stopwatch = null)
|
||||||
{
|
{
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->queries = array();
|
$this->queries = array();
|
||||||
|
$this->stopwatch = $stopwatch;
|
||||||
|
$this->isPrepare = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -121,9 +132,25 @@ class PropelLogger
|
|||||||
*/
|
*/
|
||||||
public function debug($message)
|
public function debug($message)
|
||||||
{
|
{
|
||||||
$this->queries[] = $message;
|
$add = true;
|
||||||
if (null !== $this->logger) {
|
|
||||||
$this->logger->debug($message);
|
if (null !== $this->stopwatch) {
|
||||||
|
if ($this->isPrepare) {
|
||||||
|
$this->stopwatch->start('propel', 'propel');
|
||||||
|
$this->isPrepare = false;
|
||||||
|
|
||||||
|
$add = false;
|
||||||
|
} else {
|
||||||
|
$this->stopwatch->stop('propel');
|
||||||
|
$this->isPrepare = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($add) {
|
||||||
|
$this->queries[] = $message;
|
||||||
|
if (null !== $this->logger) {
|
||||||
|
$this->logger->debug($message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
'event_listener_loading': '#add',
|
'event_listener_loading': '#add',
|
||||||
'template': '#dd3',
|
'template': '#dd3',
|
||||||
'doctrine': '#d3d',
|
'doctrine': '#d3d',
|
||||||
|
'propel': '#f4d',
|
||||||
'child_sections': '#eed',
|
'child_sections': '#eed',
|
||||||
} %}
|
} %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Reference in New Issue
Block a user