symfony / monolog-bundle

Symfony Monolog Bundle
symfony.com
MIT License
2.9k stars 232 forks source link

How to catch SlackWebhookHandler exceptions? #465

Closed toby-griffiths closed 1 year ago

toby-griffiths commented 1 year ago

We have the SlackWebhookHandler set up on our produciton environment, but we've just realised that if the cURL requests to the Slack webhook fail, the whole application chokes with an uncaught exception.

I've tried to work out how we can configure a custom handler to wrap the slack webhook one but I've spent over an hour on this and still can't work out how.

So I have a few questions in my attempt to address this…

  1. Is it possible to wrap a core handler with your own, custom one? If I define the wrapper as a service, it wants the decorated service, which I've had issues with it telling me it doesn't exist!? Or is there another way to define it in config?
  2. What are people's thoughts on whether the cURL call to slack should be wrapped in a try/catch to prevent this bringing everythig down (probably one for the Monolog project)?
  3. Could we enhance this bundle to allow people to define custom handlers that decorate others (like the fingers crossed one does) purely in config? How easy would that be? It took me ages trying to wrap my head around how all these handler services are configured, and I still haven't understood it fully.

I'd be happy to pair with someone on this to come up with a good solution, if anyone knowledgable is willing, and we can find time.

I've raised https://github.com/Seldaek/monolog/issues/1836 to also discuss with the Monolog team.

derrabus commented 1 year ago

Thank you for bringing up this topic, but this is not an issue of Monolog's Symfony integration. I don't think that we need to threads to discuss this problem, so I'm closing this issue as a duplicate of Seldaek/monolog#1836.