AbstractLogger.php 3.1 KB

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