Skip to content

Commit

Permalink
feature #27801 [MonologBridge] Add ProcessorInterface, enabling autoc…
Browse files Browse the repository at this point in the history
…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 f27c3a8
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/Symfony/Bridge/Monolog/CHANGELOG.md
@@ -1,6 +1,11 @@
CHANGELOG
=========

4.2.0
-----

* added `ProcessorInterface`: an optional interface to allow autoconfiguration of Monolog processors

4.1.0
-----

Expand Down
25 changes: 25 additions & 0 deletions src/Symfony/Bridge/Monolog/Processor/ProcessorInterface.php
@@ -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);
}
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Monolog/Processor/TokenProcessor.php
Expand Up @@ -18,7 +18,7 @@
*
* @author Dany Maillard <danymaillard93b@gmail.com>
*/
class TokenProcessor
class TokenProcessor implements ProcessorInterface
{
private $tokenStorage;

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Monolog/Processor/WebProcessor.php
Expand Up @@ -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)
{
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f27c3a8

Please sign in to comment.