mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-26 08:05:53 +03:00
[GH-ISSUE #1275] Add feature - Avoid monolog sending email programatically #526
Labels
No labels
Bug
Documentation
Feature
Needs Work
Support
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/monolog#526
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @LaurentMarquet on GitHub (Jan 7, 2019).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1275
As stated in https://stackoverflow.com/questions/53923774/how-to-avoid-monolog-sending-email-programatically, it seems that is NOT possible to stop Monolog sending email programmatically. We can setup the error level for which we want to send emails, we can update the Response but I haven't found any way to make Monolog to stop sending an email for specific reasons.
What I am looking for is a kind of
stopPropagation(this can be done on the event but then it stops the Exception) just for the email.I have a set of urls that I know they are called and throw an Exception, but I don't want to receive an email. This set of urls is stored in bdd so I cannot set them in a kind of
config.yml.Don't know where to begin to make an eventual PR.
@Seldaek commented on GitHub (Jul 1, 2019):
This is IMO about composing the handler chain correctly. You can wrap the mailer handler with a FingersCrossedHandler for example that has a custom activation strategy set which will look at the request and not trigger for those routes.. Or you could write a custom handler that filters the messages based on whatever. Endless possibilities, but for custom needs you need a little bit of custom code.
@LaurentMarquet commented on GitHub (Jul 2, 2019):
Thanks about your answer. I'm not against custom code as I did a bundle, but I have to understand how and what to do, and here I don't...
The thing is that the routes are unknown as stored in a database, when they are found in the database the process in monolog has already started and it seems that I can't stop it. I haven't found any way to say to monolog (event or whatever), don't go further. Moreover, I would like to integrate it in the bundle and not in the configuration of the app, as the goal is to work as is, not to add configuration.
But thanks again for your answer, and the work you provide to OSS.
@Seldaek commented on GitHub (Jul 2, 2019):
Well I don't know enough about your project to really say, but it sounds to me like you could tell your custom handler to not go further whenever you have your route information. Or to wait/buffer until you have the route info and then tell it to start forwarding log records to the handlers below. Still probably requires some config changes to the app though that's for sure..
@LaurentMarquet commented on GitHub (Jul 4, 2019):
Thanks again for your time.
It looks too complicated for me, what I was looking for is a kind of method
stopPropagationonGetResponseForExceptionEventbecause I use a listener onkernel.exception.As a solution I finally ended in throwing a
BadRequestHttpExceptionfor the ignored case. If you want to have a look the bundle is at https://github.com/975L/ExceptionCheckerBundle and the exact line is atgithub.com/975L/ExceptionCheckerBundle@dcbc169c89/Listener/ExceptionListener.php (L169).It's not really as I want it to be, but it works...