Handler.php 894 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. use Monolog\Logger;
  12. /**
  13. * Base Handler class providing basic close() support as well as handleBatch
  14. *
  15. * @author Jordi Boggiano <j.boggiano@seld.be>
  16. */
  17. abstract class Handler implements HandlerInterface
  18. {
  19. /**
  20. * {@inheritdoc}
  21. */
  22. public function handleBatch(array $records)
  23. {
  24. foreach ($records as $record) {
  25. $this->handle($record);
  26. }
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function close()
  32. {
  33. }
  34. public function __destruct()
  35. {
  36. try {
  37. $this->close();
  38. } catch (\Exception $e) {
  39. // do nothing
  40. }
  41. }
  42. }