feature #26832 [MonologBridge] Added WebSubscriberProcessor to ease processor configuration (lyrixx)
This PR was merged into the 4.1-dev branch.
Discussion
----------
[MonologBridge] Added WebSubscriberProcessor to ease processor configuration
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR |
---
Side note: I could be nice to have an interface to act as the marker to AutoConfigure processors
Commits
-------
b1287d65d3
[MonologBridge] Added WebSubscriberProcessor to ease processor configuration
This commit is contained in:
commit
9ae116f9e5
@ -1,6 +1,11 @@
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
4.1.0
|
||||||
|
-----
|
||||||
|
|
||||||
|
* `WebProcessor` now implements `EventSubscriberInterface` in order to be easily autoconfigured
|
||||||
|
|
||||||
4.0.0
|
4.0.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@ -12,14 +12,16 @@
|
|||||||
namespace Symfony\Bridge\Monolog\Processor;
|
namespace Symfony\Bridge\Monolog\Processor;
|
||||||
|
|
||||||
use Monolog\Processor\WebProcessor as BaseWebProcessor;
|
use Monolog\Processor\WebProcessor as BaseWebProcessor;
|
||||||
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||||
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WebProcessor override to read from the HttpFoundation's Request.
|
* WebProcessor override to read from the HttpFoundation's Request.
|
||||||
*
|
*
|
||||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||||
*/
|
*/
|
||||||
class WebProcessor extends BaseWebProcessor
|
class WebProcessor extends BaseWebProcessor implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
public function __construct(array $extraFields = null)
|
public function __construct(array $extraFields = null)
|
||||||
{
|
{
|
||||||
@ -34,4 +36,11 @@ class WebProcessor extends BaseWebProcessor
|
|||||||
$this->serverData['REMOTE_ADDR'] = $event->getRequest()->getClientIp();
|
$this->serverData['REMOTE_ADDR'] = $event->getRequest()->getClientIp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getSubscribedEvents()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
KernelEvents::REQUEST => array('onKernelRequest', 4096),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user