1<?php declare(strict_types=1); 2 3/* 4 * This file is part of the Monolog package. 5 * 6 * (c) Jordi Boggiano <j.boggiano@seld.be> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12namespace Monolog\Handler; 13 14/** 15 * Forwards records to multiple handlers suppressing failures of each handler 16 * and continuing through to give every handler a chance to succeed. 17 * 18 * @author Craig D'Amelio <craig@damelio.ca> 19 * 20 * @phpstan-import-type Record from \Monolog\Logger 21 */ 22class WhatFailureGroupHandler extends GroupHandler 23{ 24 /** 25 * {@inheritDoc} 26 */ 27 public function handle(array $record): bool 28 { 29 if ($this->processors) { 30 /** @var Record $record */ 31 $record = $this->processRecord($record); 32 } 33 34 foreach ($this->handlers as $handler) { 35 try { 36 $handler->handle($record); 37 } catch (\Throwable $e) { 38 // What failure? 39 } 40 } 41 42 return false === $this->bubble; 43 } 44 45 /** 46 * {@inheritDoc} 47 */ 48 public function handleBatch(array $records): void 49 { 50 if ($this->processors) { 51 $processed = array(); 52 foreach ($records as $record) { 53 $processed[] = $this->processRecord($record); 54 } 55 /** @var Record[] $records */ 56 $records = $processed; 57 } 58 59 foreach ($this->handlers as $handler) { 60 try { 61 $handler->handleBatch($records); 62 } catch (\Throwable $e) { 63 // What failure? 64 } 65 } 66 } 67} 68