Просмотр файла vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php

Размер файла: 2.71Kb
  1. <?php declare(strict_types=1);
  2.  
  3. /*
  4. * This file is part of the Monolog package.
  5. *
  6. * (c) Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11.  
  12. namespace Monolog\Handler;
  13.  
  14. /**
  15. * Interface that all Monolog Handlers must implement
  16. *
  17. * @author Jordi Boggiano <j.boggiano@seld.be>
  18. */
  19. interface HandlerInterface
  20. {
  21. /**
  22. * Checks whether the given record will be handled by this handler.
  23. *
  24. * This is mostly done for performance reasons, to avoid calling processors for nothing.
  25. *
  26. * Handlers should still check the record levels within handle(), returning false in isHandling()
  27. * is no guarantee that handle() will not be called, and isHandling() might not be called
  28. * for a given record.
  29. *
  30. * @param array $record Partial log record containing only a level key
  31. *
  32. * @return bool
  33. */
  34. public function isHandling(array $record): bool;
  35.  
  36. /**
  37. * Handles a record.
  38. *
  39. * All records may be passed to this method, and the handler should discard
  40. * those that it does not want to handle.
  41. *
  42. * The return value of this function controls the bubbling process of the handler stack.
  43. * Unless the bubbling is interrupted (by returning true), the Logger class will keep on
  44. * calling further handlers in the stack with a given log record.
  45. *
  46. * @param array $record The record to handle
  47. * @return bool true means that this handler handled the record, and that bubbling is not permitted.
  48. * false means the record was either not processed or that this handler allows bubbling.
  49. */
  50. public function handle(array $record): bool;
  51.  
  52. /**
  53. * Handles a set of records at once.
  54. *
  55. * @param array $records The records to handle (an array of record arrays)
  56. */
  57. public function handleBatch(array $records): void;
  58.  
  59. /**
  60. * Closes the handler.
  61. *
  62. * Ends a log cycle and frees all resources used by the handler.
  63. *
  64. * Closing a Handler means flushing all buffers and freeing any open resources/handles.
  65. *
  66. * Implementations have to be idempotent (i.e. it should be possible to call close several times without breakage)
  67. * and ideally handlers should be able to reopen themselves on handle() after they have been closed.
  68. *
  69. * This is useful at the end of a request and will be called automatically when the object
  70. * is destroyed if you extend Monolog\Handler\Handler.
  71. *
  72. * If you are thinking of calling this method yourself, most likely you should be
  73. * calling ResettableInterface::reset instead. Have a look.
  74. */
  75. public function close(): void;
  76. }