Merge remote branch 'Seldaek/monolog_firephp'
* Seldaek/monolog_firephp: [MonologBundle] Added FirePHPHandler support [MonologBundle] Only compile files if any handler is registered
This commit is contained in:
commit
3ab5a51e17
@ -70,20 +70,19 @@ class MonologExtension extends Extension
|
|||||||
$logger->addMethodCall('pushHandler', array(new Reference($handler['id'])));
|
$logger->addMethodCall('pushHandler', array(new Reference($handler['id'])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$this->addClassesToCompile(array(
|
$this->addClassesToCompile(array(
|
||||||
'Monolog\\Formatter\\FormatterInterface',
|
'Monolog\\Formatter\\FormatterInterface',
|
||||||
'Monolog\\Formatter\\LineFormatter',
|
'Monolog\\Formatter\\LineFormatter',
|
||||||
'Monolog\\Handler\\HandlerInterface',
|
'Monolog\\Handler\\HandlerInterface',
|
||||||
'Monolog\\Handler\\AbstractHandler',
|
'Monolog\\Handler\\AbstractHandler',
|
||||||
'Monolog\\Handler\\StreamHandler',
|
'Monolog\\Handler\\StreamHandler',
|
||||||
'Monolog\\Handler\\FingersCrossedHandler',
|
'Monolog\\Handler\\FingersCrossedHandler',
|
||||||
'Monolog\\Handler\\TestHandler',
|
'Monolog\\Logger',
|
||||||
'Monolog\\Logger',
|
'Symfony\\Bundle\\MonologBundle\\Logger\\Logger',
|
||||||
'Symfony\\Bundle\\MonologBundle\\Logger\\Logger',
|
'Symfony\\Bundle\\MonologBundle\\Logger\\DebugHandler',
|
||||||
'Symfony\\Bundle\\MonologBundle\\Logger\\DebugHandler',
|
));
|
||||||
));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -124,6 +123,14 @@ class MonologExtension extends Extension
|
|||||||
));
|
));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'firephp':
|
||||||
|
$definition->setArguments(array(
|
||||||
|
$handler['level'],
|
||||||
|
$handler['bubble'],
|
||||||
|
));
|
||||||
|
$definition->addTag('kernel.listener', array('event' => 'onCoreResponse'));
|
||||||
|
break;
|
||||||
|
|
||||||
case 'rotating_file':
|
case 'rotating_file':
|
||||||
if (!isset($handler['path'])) {
|
if (!isset($handler['path'])) {
|
||||||
$handler['path'] = '%kernel.logs_dir%/%kernel.environment%.log';
|
$handler['path'] = '%kernel.logs_dir%/%kernel.environment%.log';
|
||||||
|
58
src/Symfony/Bundle/MonologBundle/Logger/FirePHPHandler.php
Executable file
58
src/Symfony/Bundle/MonologBundle/Logger/FirePHPHandler.php
Executable file
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Bundle\MonologBundle\Logger;
|
||||||
|
|
||||||
|
use Monolog\Handler\FirePHPHandler as BaseFirePHPHandler;
|
||||||
|
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FirePHPHandler.
|
||||||
|
*
|
||||||
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||||
|
*/
|
||||||
|
class FirePHPHandler extends BaseFirePHPHandler
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $headers = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Response
|
||||||
|
*/
|
||||||
|
private $response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
protected function sendHeader($header, $content)
|
||||||
|
{
|
||||||
|
if ($this->response) {
|
||||||
|
$this->response->headers->set($header, $content);
|
||||||
|
} else {
|
||||||
|
$this->headers[$header] = $content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the headers to the response once it's created
|
||||||
|
*/
|
||||||
|
public function onCoreResponse(FilterResponseEvent $event)
|
||||||
|
{
|
||||||
|
$this->response = $event->getResponse();
|
||||||
|
foreach ($this->headers as $header => $content) {
|
||||||
|
$this->response->headers->set($header, $content);
|
||||||
|
}
|
||||||
|
$this->headers = array();
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,7 @@
|
|||||||
<parameter key="monolog.handler.syslog.class">Monolog\Handler\SyslogHandler</parameter>
|
<parameter key="monolog.handler.syslog.class">Monolog\Handler\SyslogHandler</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.firephp.class">Symfony\Bundle\MonologBundle\Logger\FirePHPHandler</parameter>
|
||||||
<parameter key="monolog.handler.debug.class">Symfony\Bundle\MonologBundle\Logger\DebugHandler</parameter>
|
<parameter key="monolog.handler.debug.class">Symfony\Bundle\MonologBundle\Logger\DebugHandler</parameter>
|
||||||
</parameters>
|
</parameters>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user