HandlerInterface.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. * @return Boolean
  25. */
  26. function isHandling(array $record);
  27. /**
  28. * Handles a record.
  29. *
  30. * The return value of this function controls the bubbling process of the handler stack.
  31. *
  32. * @param array $record The record to handle
  33. * @return Boolean True means that this handler handled the record, and that bubbling is not permitted.
  34. * False means the record was either not processed or that this handler allows bubbling.
  35. */
  36. function handle(array $record);
  37. /**
  38. * Handles a set of records at once.
  39. *
  40. * @param array $records The records to handle (an array of record arrays)
  41. */
  42. function handleBatch(array $records);
  43. /**
  44. * Adds a processor in the stack.
  45. *
  46. * @param callable $callback
  47. */
  48. function pushProcessor($callback);
  49. /**
  50. * Removes the processor on top of the stack and returns it.
  51. *
  52. * @return callable
  53. */
  54. function popProcessor();
  55. /**
  56. * Sets the formatter.
  57. *
  58. * @param FormatterInterface $formatter
  59. */
  60. function setFormatter(FormatterInterface $formatter);
  61. /**
  62. * Gets the formatter.
  63. *
  64. * @return FormatterInterface
  65. */
  66. function getFormatter();
  67. }