ILogger.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016, ownCloud, Inc.
  5. *
  6. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  7. * @author Bernhard Posselt <dev@bernhard-posselt.com>
  8. * @author Jan-Christoph Borchardt <hey@jancborchardt.net>
  9. * @author Lukas Reschke <lukas@statuscode.ch>
  10. * @author Morris Jobke <hey@morrisjobke.de>
  11. * @author Roeland Jago Douma <roeland@famdouma.nl>
  12. * @author Thomas Müller <thomas.mueller@tmit.eu>
  13. *
  14. * @license AGPL-3.0
  15. *
  16. * This code is free software: you can redistribute it and/or modify
  17. * it under the terms of the GNU Affero General Public License, version 3,
  18. * as published by the Free Software Foundation.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU Affero General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU Affero General Public License, version 3,
  26. * along with this program. If not, see <http://www.gnu.org/licenses/>
  27. *
  28. */
  29. namespace OCP;
  30. /**
  31. * Interface ILogger
  32. * @package OCP
  33. * @since 7.0.0
  34. *
  35. * This logger interface follows the design guidelines of PSR-3
  36. * https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md#3-psrlogloggerinterface
  37. */
  38. interface ILogger {
  39. /**
  40. * @since 14.0.0
  41. */
  42. const DEBUG=0;
  43. /**
  44. * @since 14.0.0
  45. */
  46. const INFO=1;
  47. /**
  48. * @since 14.0.0
  49. */
  50. const WARN=2;
  51. /**
  52. * @since 14.0.0
  53. */
  54. const ERROR=3;
  55. /**
  56. * @since 14.0.0
  57. */
  58. const FATAL=4;
  59. /**
  60. * System is unusable.
  61. *
  62. * @param string $message
  63. * @param array $context
  64. * @return null
  65. * @since 7.0.0
  66. */
  67. public function emergency(string $message, array $context = []);
  68. /**
  69. * Action must be taken immediately.
  70. *
  71. * @param string $message
  72. * @param array $context
  73. * @return null
  74. * @since 7.0.0
  75. */
  76. public function alert(string $message, array $context = []);
  77. /**
  78. * Critical conditions.
  79. *
  80. * @param string $message
  81. * @param array $context
  82. * @return null
  83. * @since 7.0.0
  84. */
  85. public function critical(string $message, array $context = []);
  86. /**
  87. * Runtime errors that do not require immediate action but should typically
  88. * be logged and monitored.
  89. *
  90. * @param string $message
  91. * @param array $context
  92. * @return null
  93. * @since 7.0.0
  94. */
  95. public function error(string $message, array $context = []);
  96. /**
  97. * Exceptional occurrences that are not errors.
  98. *
  99. * @param string $message
  100. * @param array $context
  101. * @return null
  102. * @since 7.0.0
  103. */
  104. public function warning(string $message, array $context = []);
  105. /**
  106. * Normal but significant events.
  107. *
  108. * @param string $message
  109. * @param array $context
  110. * @return null
  111. * @since 7.0.0
  112. */
  113. public function notice(string $message, array $context = []);
  114. /**
  115. * Interesting events.
  116. *
  117. * @param string $message
  118. * @param array $context
  119. * @return null
  120. * @since 7.0.0
  121. */
  122. public function info(string $message, array $context = []);
  123. /**
  124. * Detailed debug information.
  125. *
  126. * @param string $message
  127. * @param array $context
  128. * @return null
  129. * @since 7.0.0
  130. */
  131. public function debug(string $message, array $context = []);
  132. /**
  133. * Logs with an arbitrary level.
  134. *
  135. * @param int $level
  136. * @param string $message
  137. * @param array $context
  138. * @return mixed
  139. * @since 7.0.0
  140. */
  141. public function log(int $level, string $message, array $context = []);
  142. /**
  143. * Logs an exception very detailed
  144. * An additional message can we written to the log by adding it to the
  145. * context.
  146. *
  147. * <code>
  148. * $logger->logException($ex, [
  149. * 'message' => 'Exception during background job execution'
  150. * ]);
  151. * </code>
  152. *
  153. * @param \Exception|\Throwable $exception
  154. * @param array $context
  155. * @return void
  156. * @since 8.2.0
  157. */
  158. public function logException(\Throwable $exception, array $context = []);
  159. }