1
0

ILogger.php 3.7 KB

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