From 38f5ed7be1e5d5a086c766d09070e6cee29acbd5 Mon Sep 17 00:00:00 2001 From: Antoine Makdessi Date: Tue, 25 Jun 2019 17:13:53 +0200 Subject: [PATCH 1/2] [Logger] [Processor] additional info on processor --- logging/processors.rst | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/logging/processors.rst b/logging/processors.rst index 64ac4893ff4..44c297880f1 100644 --- a/logging/processors.rst +++ b/logging/processors.rst @@ -1,9 +1,9 @@ How to Add extra Data to Log Messages via a Processor ===================================================== -Monolog allows you to process the record before logging it to add some -extra data. A processor can be applied for the whole handler stack or -only for a specific handler. +Monolog allows you to process every record before logging it by adding some +extra data. This is the role of a processor, which can be applied for the whole +handler stack or only for a specific handler or channel. A processor is a callable receiving the record as its first argument. Processors are configured using the ``monolog.processor`` DIC tag. See the @@ -30,6 +30,8 @@ using a processor:: $this->session = $session; } + // This method is called for each log record and process it. + // Keep it optimized process, to not introduce any overhead. public function __invoke(array $record) { if (!$this->session->isStarted()) { @@ -184,6 +186,9 @@ Symfony's MonologBridge provides processors that can be registered inside your a The ``RouteProcessor`` and the ``ConsoleCommandProcessor`` were introduced in Symfony 4.3. +Monolog_ also have built in processors ready to use inside your application. +Read the librairy documentation to learn more. + Registering Processors per Handler ---------------------------------- @@ -271,3 +276,5 @@ the ``monolog.processor`` tag: $container ->register(SessionRequestProcessor::class) ->addTag('monolog.processor', ['channel' => 'main']); + +.. _Monolog: https://github.com/Seldaek/monolog From ebab375bdb8fba068be9a487df2b72985b3b7baa Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 26 Sep 2019 13:35:44 +0200 Subject: [PATCH 2/2] Minor reword --- logging/processors.rst | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/logging/processors.rst b/logging/processors.rst index 44c297880f1..f2b889461ec 100644 --- a/logging/processors.rst +++ b/logging/processors.rst @@ -1,7 +1,7 @@ How to Add extra Data to Log Messages via a Processor ===================================================== -Monolog allows you to process every record before logging it by adding some +`Monolog`_ allows you to process every record before logging it by adding some extra data. This is the role of a processor, which can be applied for the whole handler stack or only for a specific handler or channel. @@ -30,8 +30,7 @@ using a processor:: $this->session = $session; } - // This method is called for each log record and process it. - // Keep it optimized process, to not introduce any overhead. + // this method is called for each log record; optimize it to not hurt performance public function __invoke(array $record) { if (!$this->session->isStarted()) { @@ -186,8 +185,10 @@ Symfony's MonologBridge provides processors that can be registered inside your a The ``RouteProcessor`` and the ``ConsoleCommandProcessor`` were introduced in Symfony 4.3. -Monolog_ also have built in processors ready to use inside your application. -Read the librairy documentation to learn more. +.. seealso:: + + Check out the `built-in Monolog processors`_ to learn more about how to + create these processors. Registering Processors per Handler ---------------------------------- @@ -277,4 +278,5 @@ the ``monolog.processor`` tag: ->register(SessionRequestProcessor::class) ->addTag('monolog.processor', ['channel' => 'main']); -.. _Monolog: https://github.com/Seldaek/monolog +.. _`Monolog`: https://github.com/Seldaek/monolog +.. _`built-in Monolog processors`: https://github.com/Seldaek/monolog/tree/master/src/Monolog/Processor