NullHandler.php 953 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. * Blackhole
  14. *
  15. * Any record it can handle will be thrown away. This can be used
  16. * to put on top of an existing stack to override it temporarily.
  17. *
  18. * @author Jordi Boggiano <j.boggiano@seld.be>
  19. */
  20. class NullHandler extends AbstractHandler
  21. {
  22. /**
  23. * @param int $level The minimum logging level at which this handler will be triggered
  24. */
  25. public function __construct($level = Logger::DEBUG)
  26. {
  27. parent::__construct($level, false);
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function handle(array $record)
  33. {
  34. if ($record['level'] < $this->level) {
  35. return false;
  36. }
  37. return true;
  38. }
  39. }