HandlerInterface.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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\Formatter\FormatterInterface;
  12. /**
  13. * Interface that all Monolog Handlers must implement
  14. *
  15. * @author Jordi Boggiano <j.boggiano@seld.be>
  16. */
  17. interface HandlerInterface
  18. {
  19. /**
  20. * Checks whether the given record will be handled by this handler.
  21. *
  22. * This is mostly done for performance reasons, to avoid calling processors for nothing.
  23. *
  24. * Handlers should still check the record levels within handle(), returning false in isHandling()
  25. * is no guarantee that handle() will not be called, and isHandling() might not be called
  26. * for a given record.
  27. *
  28. * @param array $record Partial log record containing only a level key
  29. *
  30. * @return Boolean
  31. */
  32. public function isHandling(array $record);
  33. /**
  34. * Handles a record.
  35. *
  36. * All records may be passed to this method, and the handler should discard
  37. * those that it does not want to handle.
  38. *
  39. * The return value of this function controls the bubbling process of the handler stack.
  40. * Unless the bubbling is interrupted (by returning true), the Logger class will keep on
  41. * calling further handlers in the stack with a given log record.
  42. *
  43. * @param array $record The record to handle
  44. * @return Boolean true means that this handler handled the record, and that bubbling is not permitted.
  45. * false means the record was either not processed or that this handler allows bubbling.
  46. */
  47. public function handle(array $record);
  48. /**
  49. * Handles a set of records at once.
  50. *
  51. * @param array $records The records to handle (an array of record arrays)
  52. */
  53. public function handleBatch(array $records);
  54. /**
  55. * Adds a processor in the stack.
  56. *
  57. * @param callable $callback
  58. * @return self
  59. */
  60. public function pushProcessor($callback);
  61. /**
  62. * Removes the processor on top of the stack and returns it.
  63. *
  64. * @return callable
  65. */
  66. public function popProcessor();
  67. /**
  68. * Sets the formatter.
  69. *
  70. * @param FormatterInterface $formatter
  71. * @return self
  72. */
  73. public function setFormatter(FormatterInterface $formatter);
  74. /**
  75. * Gets the formatter.
  76. *
  77. * @return FormatterInterface
  78. */
  79. public function getFormatter();
  80. }