Added the DebugHandler when the profiler is activated
This commit is contained in:
parent
342e14ac29
commit
9a5cf2a75c
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Bundle\MonologBundle\DependencyInjection\Compiler;
|
||||||
|
|
||||||
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||||
|
use Symfony\Component\DependencyInjection\Definition;
|
||||||
|
use Monolog\Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces the default logger by another one with its own channel for tagged services.
|
||||||
|
*
|
||||||
|
* @author Christophe Coevoet <stof@notk.org>
|
||||||
|
*/
|
||||||
|
class DebugHandlerPass implements CompilerPassInterface
|
||||||
|
{
|
||||||
|
protected $channels = array();
|
||||||
|
|
||||||
|
public function process(ContainerBuilder $container)
|
||||||
|
{
|
||||||
|
if (!$container->hasDefinition('monolog.logger_prototype') || !$container->hasDefinition('profiler')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$debugHandler = new Definition('%monolog.handler.debug.class%', array(Logger::DEBUG, true));
|
||||||
|
$container->setDefinition('monolog.handler.debug', $debugHandler);
|
||||||
|
$container->getDefinition('monolog.logger_prototype')->addMethodCall('pushHandler', array (new Reference('monolog.handler.debug')));
|
||||||
|
}
|
||||||
|
}
|
@ -20,7 +20,7 @@ use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
|
|||||||
*
|
*
|
||||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||||
*/
|
*/
|
||||||
class DebugLogger extends TestHandler implements DebugLoggerInterface
|
class DebugHandler extends TestHandler implements DebugLoggerInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
@ -14,6 +14,7 @@ namespace Symfony\Bundle\MonologBundle;
|
|||||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\LoggerChannelPass;
|
use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\LoggerChannelPass;
|
||||||
|
use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\DebugHandlerPass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bundle.
|
* Bundle.
|
||||||
@ -27,5 +28,6 @@ class MonologBundle extends Bundle
|
|||||||
parent::build($container);
|
parent::build($container);
|
||||||
|
|
||||||
$container->addCompilerPass(new LoggerChannelPass());
|
$container->addCompilerPass(new LoggerChannelPass());
|
||||||
|
$container->addCompilerPass(new DebugHandlerPass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
<parameter key="monolog.handler.fingerscrossed.class">Monolog\Handler\FingersCrossedHandler</parameter>
|
<parameter key="monolog.handler.fingerscrossed.class">Monolog\Handler\FingersCrossedHandler</parameter>
|
||||||
<parameter key="monolog.handler.null.class">Monolog\Handler\NullHandler</parameter>
|
<parameter key="monolog.handler.null.class">Monolog\Handler\NullHandler</parameter>
|
||||||
<parameter key="monolog.handler.test.class">Monolog\Handler\TestHandler</parameter>
|
<parameter key="monolog.handler.test.class">Monolog\Handler\TestHandler</parameter>
|
||||||
|
<parameter key="monolog.handler.debug.class">Symfony\Bundle\MonologBundle\Logger\DebugHandler</parameter>
|
||||||
</parameters>
|
</parameters>
|
||||||
|
|
||||||
<services>
|
<services>
|
||||||
|
Reference in New Issue
Block a user