No Description

AbstractLogger.php 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. namespace Psr\Log;
  3. /**
  4. * This is a simple Logger implementation that other Loggers can inherit from.
  5. *
  6. * It simply delegates all log-level-specific methods to the `log` method to
  7. * reduce boilerplate code that a simple Logger that does the same thing with
  8. * messages regardless of the error level has to implement.
  9. */
  10. abstract class AbstractLogger implements LoggerInterface
  11. {
  12. /**
  13. * System is unusable.
  14. *
  15. * @param string $message
  16. * @param array $context
  17. *
  18. * @return void
  19. */
  20. public function emergency($message, array $context = array())
  21. {
  22. $this->log(LogLevel::EMERGENCY, $message, $context);
  23. }
  24. /**
  25. * Action must be taken immediately.
  26. *
  27. * Example: Entire website down, database unavailable, etc. This should
  28. * trigger the SMS alerts and wake you up.
  29. *
  30. * @param string $message
  31. * @param array $context
  32. *
  33. * @return void
  34. */
  35. public function alert($message, array $context = array())
  36. {
  37. $this->log(LogLevel::ALERT, $message, $context);
  38. }
  39. /**
  40. * Critical conditions.
  41. *
  42. * Example: Application component unavailable, unexpected exception.
  43. *
  44. * @param string $message
  45. * @param array $context
  46. *
  47. * @return void
  48. */
  49. public function critical($message, array $context = array())
  50. {
  51. $this->log(LogLevel::CRITICAL, $message, $context);
  52. }
  53. /**
  54. * Runtime errors that do not require immediate action but should typically
  55. * be logged and monitored.
  56. *
  57. * @param string $message
  58. * @param array $context
  59. *
  60. * @return void
  61. */
  62. public function error($message, array $context = array())
  63. {
  64. $this->log(LogLevel::ERROR, $message, $context);
  65. }
  66. /**
  67. * Exceptional occurrences that are not errors.
  68. *
  69. * Example: Use of deprecated APIs, poor use of an API, undesirable things
  70. * that are not necessarily wrong.
  71. *
  72. * @param string $message
  73. * @param array $context
  74. *
  75. * @return void
  76. */
  77. public function warning($message, array $context = array())
  78. {
  79. $this->log(LogLevel::WARNING, $message, $context);
  80. }
  81. /**
  82. * Normal but significant events.
  83. *
  84. * @param string $message
  85. * @param array $context
  86. *
  87. * @return void
  88. */
  89. public function notice($message, array $context = array())
  90. {
  91. $this->log(LogLevel::NOTICE, $message, $context);
  92. }
  93. /**
  94. * Interesting events.
  95. *
  96. * Example: User logs in, SQL logs.
  97. *
  98. * @param string $message
  99. * @param array $context
  100. *
  101. * @return void
  102. */
  103. public function info($message, array $context = array())
  104. {
  105. $this->log(LogLevel::INFO, $message, $context);
  106. }
  107. /**
  108. * Detailed debug information.
  109. *
  110. * @param string $message
  111. * @param array $context
  112. *
  113. * @return void
  114. */
  115. public function debug($message, array $context = array())
  116. {
  117. $this->log(LogLevel::DEBUG, $message, $context);
  118. }
  119. }