Skip to content

Commit

Permalink
Disable DebugHandler when the profiler is disabled, fixes #37
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Apr 22, 2013
1 parent d401cab commit 1fc0864
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions DependencyInjection/Compiler/DebugHandlerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* Adds the DebugHandler when the profiler is enabled.
*
* @author Christophe Coevoet <stof@notk.org>
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
class DebugHandlerPass implements CompilerPassInterface
{
Expand All @@ -37,6 +38,19 @@ public function process(ContainerBuilder $container)
return;
}

// detect if the profiler is present but will be disabled
$enabled = true;
foreach ($container->getDefinition('profiler')->getMethodCalls() as $call) {
if ($call[0] === 'disable') {
$enabled = false;
} elseif ($call[0] === 'enable') {
$enabled = true;
}
}
if (!$enabled) {
return;
}

$debugHandler = new Definition('%monolog.handler.debug.class%', array(Logger::DEBUG, true));
$container->setDefinition('monolog.handler.debug', $debugHandler);

Expand Down

0 comments on commit 1fc0864

Please sign in to comment.