WhatFailureGroupHandler.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  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. /**
  12. * Forwards records to multiple handlers suppressing failures of each handler
  13. * and continuing through to give every handler a chance to succeed.
  14. *
  15. * @author Craig D'Amelio <craig@damelio.ca>
  16. */
  17. class WhatFailureGroupHandler extends GroupHandler
  18. {
  19. /**
  20. * {@inheritdoc}
  21. */
  22. public function handle(array $record)
  23. {
  24. if ($this->processors) {
  25. foreach ($this->processors as $processor) {
  26. $record = call_user_func($processor, $record);
  27. }
  28. }
  29. foreach ($this->handlers as $handler) {
  30. try {
  31. $handler->handle($record);
  32. } catch (\Exception $e) {
  33. // What failure?
  34. } catch (\Throwable $e) {
  35. // What failure?
  36. }
  37. }
  38. return false === $this->bubble;
  39. }
  40. /**
  41. * {@inheritdoc}
  42. */
  43. public function handleBatch(array $records)
  44. {
  45. foreach ($this->handlers as $handler) {
  46. try {
  47. $handler->handleBatch($records);
  48. } catch (\Exception $e) {
  49. // What failure?
  50. } catch (\Throwable $e) {
  51. // What failure?
  52. }
  53. }
  54. }
  55. }