Skip to content

Commit b9fb819

Browse files
committed
Merge branch '6.0' into 6.1
* 6.0: [Logging] Mention `#[AsMonologProcessor]`
2 parents 6ae741f + 9af6b31 commit b9fb819

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

logging/processors.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,32 @@ If you use several handlers, you can also register a processor at the
164164
handler level or at the channel level instead of registering it globally
165165
(see the following sections).
166166

167+
When registering a new processor, instead of adding the tag manually in your
168+
configuration files, you can use the ``#[AsMonologProcessor]`` attribute to
169+
apply it on the processor class::
170+
171+
// src/Logger/SessionRequestProcessor.php
172+
namespace App\Logger;
173+
174+
use Monolog\Attribute\AsMonologProcessor;
175+
176+
#[AsMonologProcessor]
177+
class SessionRequestProcessor
178+
{
179+
// ...
180+
}
181+
182+
The ``#[AsMonologProcessor]`` attribute takes these optional arguments:
183+
184+
* ``channel``: the logging channel the processor should be pushed to;
185+
* ``handler``: the handler the processor should be pushed to;
186+
* ``method``: the method that processes the records (useful when applying
187+
the attribute to the entire class instead of a single method).
188+
189+
.. versionadded:: 3.8
190+
191+
The ``#[AsMonologProcessor]`` attribute was introduced in MonologBundle 3.8.
192+
167193
Symfony's MonologBridge provides processors that can be registered inside your application.
168194

169195
:class:`Symfony\\Bridge\\Monolog\\Processor\\DebugProcessor`

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy