1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-06 13:16:39 +02:00

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.
This commit is contained in:
Craig D'Amelio
2014-09-24 12:54:46 -04:00
parent b3f039339d
commit 58d16ba358

View File

@@ -0,0 +1,48 @@
<?php
namespace Monolog\Handler;
/**
* Forwards records to multiple handlers suppressing failures of each handler
* and continuing through to give every handler a chance to succeed.
*
* @author Craig D'Amelio <craig@damelio.ca>
*/
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?
}
}
}
}