FallbackGroupHandler.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php declare(strict_types=1);
  2. /*
  3. * This file is part of the Monolog package.
  4. *
  5. * (c) Jordi Boggiano <j.boggiano@seld.be>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Monolog\Handler;
  11. use Throwable;
  12. class FallbackGroupHandler extends GroupHandler
  13. {
  14. /**
  15. * {@inheritdoc}
  16. */
  17. public function handle(array $record): bool
  18. {
  19. if ($this->processors) {
  20. $record = $this->processRecord($record);
  21. }
  22. foreach ($this->handlers as $handler) {
  23. try {
  24. $handler->handle($record);
  25. break;
  26. } catch (Throwable $e) {
  27. // What throwable?
  28. }
  29. }
  30. return false === $this->bubble;
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function handleBatch(array $records): void
  36. {
  37. if ($this->processors) {
  38. $processed = [];
  39. foreach ($records as $record) {
  40. $processed[] = $this->processRecord($record);
  41. }
  42. $records = $processed;
  43. }
  44. foreach ($this->handlers as $handler) {
  45. try {
  46. $handler->handleBatch($records);
  47. break;
  48. } catch (Throwable $e) {
  49. // What throwable?
  50. }
  51. }
  52. }
  53. }