From 0c9c90fdf4988971ae3bd1aad58747390f94f343 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 3 Jul 2018 10:06:18 +0200 Subject: [PATCH 1/2] Tell about ProcessorInterface in logging/processors --- logging/processors.rst | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/logging/processors.rst b/logging/processors.rst index d78bd00457f..2305fcc25ad 100644 --- a/logging/processors.rst +++ b/logging/processors.rst @@ -159,6 +159,28 @@ If you use several handlers, you can also register a processor at the handler level or at the channel level instead of registering it globally (see the following sections). +.. tip:: + + .. versionadded:: 4.2 + Processors can be autoconfigured since Symfony 4.2. + + Processors implementing :class:`Symfony\\Bridge\\Monolog\\Processor\\ProcessorInterface` + can have their ``monolog.processor`` tag added for you by Symfony when autoconfiguration + is enabled. In this situation, this means creating a processor class might be all you + need do to to have it up and running. It also means enabling the + :class:`Symfony\\Bridge\\Monolog\\Processor\\TokenProcessor` or the + :class:`Symfony\\Bridge\\Monolog\\Processor\\WebProcessor` in your Flex-enabled app is a + one-liner: + + .. code-block:: yaml + + # config/services.yaml + services: + # Adds the current security token to log entries + Symfony\Bridge\Monolog\Processor\TokenProcessor: ~ + # Adds the real client IP to log entries + Symfony\Bridge\Monolog\Processor\WebProcessor: ~ + Registering Processors per Handler ---------------------------------- From ad2bad9147cfee8eeb0a87fa533b9ffe29b2229d Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 6 Jul 2018 09:50:56 +0200 Subject: [PATCH 2/2] Minor reword --- logging/processors.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/logging/processors.rst b/logging/processors.rst index 2305fcc25ad..e9199417e5f 100644 --- a/logging/processors.rst +++ b/logging/processors.rst @@ -162,15 +162,15 @@ handler level or at the channel level instead of registering it globally .. tip:: .. versionadded:: 4.2 - Processors can be autoconfigured since Symfony 4.2. - - Processors implementing :class:`Symfony\\Bridge\\Monolog\\Processor\\ProcessorInterface` - can have their ``monolog.processor`` tag added for you by Symfony when autoconfiguration - is enabled. In this situation, this means creating a processor class might be all you - need do to to have it up and running. It also means enabling the - :class:`Symfony\\Bridge\\Monolog\\Processor\\TokenProcessor` or the - :class:`Symfony\\Bridge\\Monolog\\Processor\\WebProcessor` in your Flex-enabled app is a - one-liner: + The autoconfiguration of Monolog processors was introduced in Symfony 4.2. + + If you're using the :ref:`default services.yaml configuration `, + processors implementing :class:`Symfony\\Bridge\\Monolog\\Processor\\ProcessorInterface` + are automatically registered as services and tagged with ``monolog.processor``, + so you can use them without adding any configuration. The same applies to the + built-in :class:`Symfony\\Bridge\\Monolog\\Processor\\TokenProcessor` and + :class:`Symfony\\Bridge\\Monolog\\Processor\\WebProcessor` processors, which + can be enabled as follows: .. code-block:: yaml