Skip to content

Commit

Permalink
DebugBarManager: Append logger if existing logger is LoggerChain
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Aug 2, 2020
1 parent a04aa26 commit 77137a0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/DebugBarManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use DebugBar\JavascriptRenderer;
use DebugBar\StandardDebugBar;
use Doctrine\DBAL\Logging\DebugStack;
use Doctrine\DBAL\Logging\LoggerChain;
use Doctrine\ORM\EntityManager;
use Eventum\Logger\LoggerTrait;
use Monolog\Logger as MonologLogger;
Expand Down Expand Up @@ -77,7 +78,13 @@ public function registerDoctrine(EntityManager $entityManager): void

$debugBar = $this->debugBar;
$debugStack = new DebugStack();
$entityManager->getConnection()->getConfiguration()->setSQLLogger($debugStack);
$configuration = $entityManager->getConnection()->getConfiguration();
$logger = $configuration->getSQLLogger();
if ($logger instanceof LoggerChain) {
$logger->addLogger($debugStack);
} else {
$configuration->setSQLLogger($debugStack);
}

$debugBar->addCollector(new AggregatedCollector('doctrine'));
$debugBar['doctrine']->addCollector(new DoctrineCollector($debugStack));
Expand Down

0 comments on commit 77137a0

Please sign in to comment.