Seldaek / monolog

Sends your logs to files, sockets, inboxes, databases and various web services
https://seldaek.github.io/monolog/
MIT License
21.05k stars 1.9k forks source link

How should we catch exceptions with the SlackWebhookHandler cURL requests? #1836

Closed toby-griffiths closed 1 year ago

toby-griffiths commented 1 year ago

Monolog version 3

We have the SlackWebhookHandler implemented in a Symfony project, but have realised that it does not catch exceptions thrown if the cURL request to Slack fails.

We would like to protect our application from completely falling over in the event of comms with Slack failing.

What do people think about adding some error handling around the cURL request in the SlackWebhookHandler. I appreciate that we could decorate the handler to add this ourselves, but this is one of the few things that doesn't seem to be well documented in the Symfony docs, as to how to implement, and I've spend over an hour trying to work it out.

Keen to know whether this is something people thing we should implement here, or in Symfony?

I've also raised https://github.com/symfony/monolog-bundle/issues/465 to gether thoughts on handling this in Symfony.

stof commented 1 year ago

There is a WhatFailureGroupHandler that can be used to wrap other handlers and catch their error.

Seldaek commented 1 year ago

Right, the idea is that either you suppress errors with WhatFailureGroupHandler or by default we let errors fail so that you notice the problem, otherwise misconfigured logging would simply fail to log silently and that gives a false sense that everything is fine.