Permalink
Browse files

feature #27801 [MonologBridge] Add ProcessorInterface, enabling autoc…

…onfiguration of monolog processors (nicolas-grekas)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[MonologBridge] Add ProcessorInterface, enabling autoconfiguration of monolog processors

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | symfony/symfony-docs#9996

Using this, enabling e.g. TokenProcessor or WebProcessor just needs one line in `services.yaml`:
```yaml
services:
    Symfony\Bridge\Monolog\Processor\TokenProcessor: ~
    Symfony\Bridge\Monolog\Processor\WebProcessor: ~
```

Commits
-------

28a4912 [MonologBridge] Add ProcessorInterface, enabling autoconfiguration of monolog processors
  • Loading branch information...
fabpot committed Jul 3, 2018
2 parents 9da0454 + 28a4912 commit f27c3a85843f7bfbd08ebb6793b207a4f28c33f1
@@ -1,6 +1,11 @@
CHANGELOG
=========
4.2.0
-----
* added `ProcessorInterface`: an optional interface to allow autoconfiguration of Monolog processors
4.1.0
-----
@@ -0,0 +1,25 @@
<?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\Bridge\Monolog\Processor;
/**
* An optional interface to allow autoconfiguration of Monolog processors.
*
* @author Nicolas Grekas <p@tchwork.com>
*/
interface ProcessorInterface
{
/**
* @return array The processed records
*/
public function __invoke(array $records);
}
@@ -18,7 +18,7 @@
*
* @author Dany Maillard <danymaillard93b@gmail.com>
*/
class TokenProcessor
class TokenProcessor implements ProcessorInterface
{
private $tokenStorage;
@@ -21,7 +21,7 @@
*
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
class WebProcessor extends BaseWebProcessor implements EventSubscriberInterface
class WebProcessor extends BaseWebProcessor implements EventSubscriberInterface, ProcessorInterface
{
public function __construct(array $extraFields = null)
{
@@ -14,6 +14,7 @@
use Doctrine\Common\Annotations\Reader;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Symfony\Bridge\Monolog\Processor\DebugProcessor;
use Symfony\Bridge\Monolog\Processor\ProcessorInterface;
use Symfony\Bridge\Twig\Extension\CsrfExtension;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
@@ -324,6 +325,8 @@ public function load(array $configs, ContainerBuilder $container)
->addTag('kernel.event_subscriber');
$container->registerForAutoconfiguration(ResettableInterface::class)
->addTag('kernel.reset', array('method' => 'reset'));
$container->registerForAutoconfiguration(ProcessorInterface::class)
->addTag('monolog.processor');
$container->registerForAutoconfiguration(PropertyListExtractorInterface::class)
->addTag('property_info.list_extractor');
$container->registerForAutoconfiguration(PropertyTypeExtractorInterface::class)

0 comments on commit f27c3a8

Please sign in to comment.