LoggerInterface.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace Psr\Log;
  3. /**
  4. * Describes a logger instance.
  5. *
  6. * The message MUST be a string or object implementing __toString().
  7. *
  8. * The message MAY contain placeholders in the form: {foo} where foo
  9. * will be replaced by the context data in key "foo".
  10. *
  11. * The context array can contain arbitrary data. The only assumption that
  12. * can be made by implementors is that if an Exception instance is given
  13. * to produce a stack trace, it MUST be in a key named "exception".
  14. *
  15. * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md
  16. * for the full interface specification.
  17. */
  18. interface LoggerInterface
  19. {
  20. /**
  21. * System is unusable.
  22. *
  23. * @param mixed[] $context
  24. */
  25. public function emergency(string|\Stringable $message, array $context = []): void;
  26. /**
  27. * Action must be taken immediately.
  28. *
  29. * Example: Entire website down, database unavailable, etc. This should
  30. * trigger the SMS alerts and wake you up.
  31. *
  32. * @param mixed[] $context
  33. */
  34. public function alert(string|\Stringable $message, array $context = []): void;
  35. /**
  36. * Critical conditions.
  37. *
  38. * Example: Application component unavailable, unexpected exception.
  39. *
  40. * @param mixed[] $context
  41. */
  42. public function critical(string|\Stringable $message, array $context = []): void;
  43. /**
  44. * Runtime errors that do not require immediate action but should typically
  45. * be logged and monitored.
  46. *
  47. * @param mixed[] $context
  48. */
  49. public function error(string|\Stringable $message, array $context = []): void;
  50. /**
  51. * Exceptional occurrences that are not errors.
  52. *
  53. * Example: Use of deprecated APIs, poor use of an API, undesirable things
  54. * that are not necessarily wrong.
  55. *
  56. * @param mixed[] $context
  57. */
  58. public function warning(string|\Stringable $message, array $context = []): void;
  59. /**
  60. * Normal but significant events.
  61. *
  62. * @param mixed[] $context
  63. */
  64. public function notice(string|\Stringable $message, array $context = []): void;
  65. /**
  66. * Interesting events.
  67. *
  68. * Example: User logs in, SQL logs.
  69. *
  70. * @param mixed[] $context
  71. */
  72. public function info(string|\Stringable $message, array $context = []): void;
  73. /**
  74. * Detailed debug information.
  75. *
  76. * @param mixed[] $context
  77. */
  78. public function debug(string|\Stringable $message, array $context = []): void;
  79. /**
  80. * Logs with an arbitrary level.
  81. *
  82. * @param mixed[] $context
  83. *
  84. * @throws \Psr\Log\InvalidArgumentException
  85. */
  86. public function log($level, string|\Stringable $message, array $context = []): void;
  87. }