Commit c421eab3 authored by Fabien Potencier's avatar Fabien Potencier

merged branch GromNaN/dbal-logger (PR #632)

This PR was merged into the master branch.

Commits
-------

fbffc2b0 Enable logger and stopwatch for Doctrine queries

Discussion
----------

Add logger and stopwatch for Doctrine queries

Add SQL queries to the logs using the DbalLogger of the DoctrineBridge.

In addition, if the WebprofilerServiceProvider is registered (stopwatch service set), the timeline show doctrine queries.

![Profiler](https://f.cloud.github.com/assets/400034/152414/877dc396-75c4-11e2-96df-6dde93c7d86e.png)

---------------------------------------------------------------------------

by DerManoMann at 2013-02-13T10:37:42Z

👍

---------------------------------------------------------------------------

by fabpot at 2013-02-13T10:39:34Z

I'm wondering if the stopwatch service should be moved to Silex core.

---------------------------------------------------------------------------

by lyrixx at 2013-02-13T11:05:00Z

Totally 👍 for moving it to silex.

---------------------------------------------------------------------------

by GromNaN at 2013-02-13T11:16:20Z

Is there a use case for the "stopwatch" outside of the webprofiler ?

---------------------------------------------------------------------------

by lyrixx at 2013-02-13T11:23:44Z

@GromNaN Yes, it you want to bench some code.

---------------------------------------------------------------------------

by henrikbjorn at 2013-02-13T11:35:28Z

@fabpot please not it will only add cruft. i think it is a niche thing to use the Stopwatch component.
parents 81988ead fbffc2b0
......@@ -16,6 +16,7 @@ use Silex\ServiceProviderInterface;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Configuration;
use Doctrine\Common\EventManager;
use Symfony\Bridge\Doctrine\Logger\DbalLogger;
/**
* Doctrine DBAL Provider.
......@@ -84,6 +85,10 @@ class DoctrineServiceProvider implements ServiceProviderInterface
$configs = new \Pimple();
foreach ($app['dbs.options'] as $name => $options) {
$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;
......
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