1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-23 09:36:11 +02:00

Merge pull request #426 from acdameli/master

New Handler: WhatFailureGroupHandler
This commit is contained in:
Jordi Boggiano
2014-09-30 11:56:29 +01:00
4 changed files with 175 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
<?php
namespace Monolog\Handler;
use Monolog\Logger;
/**
* Used for testing purposes.
*
* It records all records and gives you access to them for verification. It
* throws an exception from handle and handleBatch to test the
* WhatFailureGroupHandler Class.
*
* @author Craig D'Amelio <craig@damelio.ca>
*/
class ExceptionTestHandler extends TestHandler
{
/**
* {@inheritdoc}
*/
public function handle(array $record) {
$return = parent::handle($record);
throw new \Exception("ExceptionTestHandler::handle");
}
}

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?
}
}
}
}