From 58d16ba358f9c4c3612947ad59b0ef9a364e4acd Mon Sep 17 00:00:00 2001 From: Craig D'Amelio Date: Wed, 24 Sep 2014 12:54:46 -0400 Subject: [PATCH] Group handler that ignores failures This allows a group handler which on a single handler failing will continue and allow subsequent handlers to record the event. --- .../Handler/WhatFailureGroupHandler.php | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/Monolog/Handler/WhatFailureGroupHandler.php diff --git a/src/Monolog/Handler/WhatFailureGroupHandler.php b/src/Monolog/Handler/WhatFailureGroupHandler.php new file mode 100644 index 00000000..e873f673 --- /dev/null +++ b/src/Monolog/Handler/WhatFailureGroupHandler.php @@ -0,0 +1,48 @@ + + */ +class WhatFailureGroupHandler extends GroupHandler +{ + /** + * {@inheritdoc} + */ + public function handle(array $record) + { + if ($this->processors) { + foreach ($this->processors as $processor) { + $record = call_user_func($processor, $record); + } + } + + foreach ($this->handlers as $handler) { + try { + $handler->handle($record); + } catch (\Exception $e) { + // What failure? + } + } + + return false === $this->bubble; + } + + /** + * {@inheritdoc} + */ + public function handleBatch(array $records) + { + foreach ($this->handlers as $handler) { + try { + $handler->handleBatch($records); + } catch (\Exception $e) { + // What failure? + } + } + } +}