Skip to content

Commit

Permalink
[MonologBridge] Added WebSubscriberProcessor to ease processor config…
Browse files Browse the repository at this point in the history
…uration
  • Loading branch information
lyrixx committed Apr 23, 2018
1 parent a726f05 commit b1287d6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Symfony/Bridge/Monolog/CHANGELOG.md
@@ -1,6 +1,11 @@
CHANGELOG
=========

4.1.0
-----

* `WebProcessor` now implements `EventSubscriberInterface` in order to be easily autoconfigured

4.0.0
-----

Expand Down
11 changes: 10 additions & 1 deletion src/Symfony/Bridge/Monolog/Processor/WebProcessor.php
Expand Up @@ -12,14 +12,16 @@
namespace Symfony\Bridge\Monolog\Processor;

use Monolog\Processor\WebProcessor as BaseWebProcessor;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;

/**
* WebProcessor override to read from the HttpFoundation's Request.
*
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
class WebProcessor extends BaseWebProcessor
class WebProcessor extends BaseWebProcessor implements EventSubscriberInterface
{
public function __construct(array $extraFields = null)
{
Expand All @@ -34,4 +36,11 @@ public function onKernelRequest(GetResponseEvent $event)
$this->serverData['REMOTE_ADDR'] = $event->getRequest()->getClientIp();
}
}

public static function getSubscribedEvents()
{
return array(
KernelEvents::REQUEST => array('onKernelRequest', 4096),
);
}
}

0 comments on commit b1287d6

Please sign in to comment.