Skip to content

Use callable classes for custom Monolog processors #10125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions logging/processors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ using a processor::
$this->session = $session;
}

public function processRecord(array $record)
public function __invoke(array $record)
{
if (!$this->session->isStarted()) {
return $record;
Expand Down Expand Up @@ -61,7 +61,7 @@ using a processor::
class: AppBundle\Logger\SessionRequestProcessor
arguments: ['@session']
tags:
- { name: monolog.processor, method: processRecord }
- { name: monolog.processor }

monolog:
handlers:
Expand Down Expand Up @@ -94,7 +94,7 @@ using a processor::
class="AppBundle\Logger\SessionRequestProcessor">

<argument type="service" id="session" />
<tag name="monolog.processor" method="processRecord" />
<tag name="monolog.processor" />
</service>
</services>

Expand Down Expand Up @@ -122,7 +122,7 @@ using a processor::
$container
->register('app.logger.session_request_processor', SessionRequestProcessor::class)
->addArgument(new Reference('session'))
->addTag('monolog.processor', array('method' => 'processRecord'));
->addTag('monolog.processor');

$container->loadFromExtension('monolog', array(
'handlers' => array(
Expand Down Expand Up @@ -157,7 +157,7 @@ the ``monolog.processor`` tag:
class: AppBundle\Logger\SessionRequestProcessor
arguments: ['@session']
tags:
- { name: monolog.processor, method: processRecord, handler: main }
- { name: monolog.processor, handler: main }

.. code-block:: xml

Expand All @@ -176,7 +176,7 @@ the ``monolog.processor`` tag:
class="AppBundle\Logger\SessionRequestProcessor">

<argument type="service" id="session" />
<tag name="monolog.processor" method="processRecord" handler="main" />
<tag name="monolog.processor" handler="main" />
</service>
</services>
</container>
Expand All @@ -192,7 +192,7 @@ the ``monolog.processor`` tag:
SessionRequestProcessor::class
)
->addArgument(new Reference('session'))
->addTag('monolog.processor', array('method' => 'processRecord', 'handler' => 'main'));
->addTag('monolog.processor', array('handler' => 'main'));

Registering Processors per Channel
----------------------------------
Expand All @@ -210,7 +210,7 @@ the ``monolog.processor`` tag:
class: AppBundle\Logger\SessionRequestProcessor
arguments: ['@session']
tags:
- { name: monolog.processor, method: processRecord, channel: main }
- { name: monolog.processor, channel: main }

.. code-block:: xml

Expand All @@ -229,7 +229,7 @@ the ``monolog.processor`` tag:
class="AppBundle\Logger\SessionRequestProcessor">

<argument type="service" id="session" />
<tag name="monolog.processor" method="processRecord" channel="main" />
<tag name="monolog.processor" channel="main" />
</service>
</services>
</container>
Expand All @@ -242,4 +242,4 @@ the ``monolog.processor`` tag:
$container
->register('app.logger.session_request_processor', SessionRequestProcessor::class)
->addArgument(new Reference('session'))
->addTag('monolog.processor', array('method' => 'processRecord', 'channel' => 'main'));
->addTag('monolog.processor', array('channel' => 'main'));