WhatFailureGroupHandler.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace Monolog\Handler;
  3. /**
  4. * Forwards records to multiple handlers suppressing failures of each handler
  5. * and continuing through to give every handler a chance to succeed.
  6. *
  7. * @author Craig D'Amelio <craig@damelio.ca>
  8. */
  9. class WhatFailureGroupHandler extends GroupHandler
  10. {
  11. /**
  12. * {@inheritdoc}
  13. */
  14. public function handle(array $record)
  15. {
  16. if ($this->processors) {
  17. foreach ($this->processors as $processor) {
  18. $record = call_user_func($processor, $record);
  19. }
  20. }
  21. foreach ($this->handlers as $handler) {
  22. try {
  23. $handler->handle($record);
  24. } catch (\Exception $e) {
  25. // What failure?
  26. }
  27. }
  28. return false === $this->bubble;
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function handleBatch(array $records)
  34. {
  35. foreach ($this->handlers as $handler) {
  36. try {
  37. $handler->handleBatch($records);
  38. } catch (\Exception $e) {
  39. // What failure?
  40. }
  41. }
  42. }
  43. }