Commit fbffc2b0 authored by Jerome TAMARELLE's avatar Jerome TAMARELLE

Enable logger and stopwatch for Doctrine queries

parent 81988ead
...@@ -16,6 +16,7 @@ use Silex\ServiceProviderInterface; ...@@ -16,6 +16,7 @@ use Silex\ServiceProviderInterface;
use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Configuration; use Doctrine\DBAL\Configuration;
use Doctrine\Common\EventManager; use Doctrine\Common\EventManager;
use Symfony\Bridge\Doctrine\Logger\DbalLogger;
/** /**
* Doctrine DBAL Provider. * Doctrine DBAL Provider.
...@@ -84,6 +85,10 @@ class DoctrineServiceProvider implements ServiceProviderInterface ...@@ -84,6 +85,10 @@ class DoctrineServiceProvider implements ServiceProviderInterface
$configs = new \Pimple(); $configs = new \Pimple();
foreach ($app['dbs.options'] as $name => $options) { foreach ($app['dbs.options'] as $name => $options) {
$configs[$name] = new Configuration(); $configs[$name] = new Configuration();
if (isset($app['logger']) && class_exists('Symfony\Bridge\Doctrine\Logger\DbalLogger')) {
$configs[$name]->setSQLLogger(new DbalLogger($app['logger'], isset($app['stopwatch']) ? $app['stopwatch'] : null));
}
} }
return $configs; return $configs;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment