ILogger.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. * System is unusable.
  39. *
  40. * @param string $message
  41. * @param array $context
  42. * @return null
  43. * @since 7.0.0
  44. */
  45. public function emergency(string $message, array $context = []);
  46. /**
  47. * Action must be taken immediately.
  48. *
  49. * @param string $message
  50. * @param array $context
  51. * @return null
  52. * @since 7.0.0
  53. */
  54. public function alert(string $message, array $context = []);
  55. /**
  56. * Critical conditions.
  57. *
  58. * @param string $message
  59. * @param array $context
  60. * @return null
  61. * @since 7.0.0
  62. */
  63. public function critical(string $message, array $context = []);
  64. /**
  65. * Runtime errors that do not require immediate action but should typically
  66. * be logged and monitored.
  67. *
  68. * @param string $message
  69. * @param array $context
  70. * @return null
  71. * @since 7.0.0
  72. */
  73. public function error(string $message, array $context = []);
  74. /**
  75. * Exceptional occurrences that are not errors.
  76. *
  77. * @param string $message
  78. * @param array $context
  79. * @return null
  80. * @since 7.0.0
  81. */
  82. public function warning(string $message, array $context = []);
  83. /**
  84. * Normal but significant events.
  85. *
  86. * @param string $message
  87. * @param array $context
  88. * @return null
  89. * @since 7.0.0
  90. */
  91. public function notice(string $message, array $context = []);
  92. /**
  93. * Interesting events.
  94. *
  95. * @param string $message
  96. * @param array $context
  97. * @return null
  98. * @since 7.0.0
  99. */
  100. public function info(string $message, array $context = []);
  101. /**
  102. * Detailed debug information.
  103. *
  104. * @param string $message
  105. * @param array $context
  106. * @return null
  107. * @since 7.0.0
  108. */
  109. public function debug(string $message, array $context = []);
  110. /**
  111. * Logs with an arbitrary level.
  112. *
  113. * @param int $level
  114. * @param string $message
  115. * @param array $context
  116. * @return mixed
  117. * @since 7.0.0
  118. */
  119. public function log(int $level, string $message, array $context = []);
  120. /**
  121. * Logs an exception very detailed
  122. * An additional message can we written to the log by adding it to the
  123. * context.
  124. *
  125. * <code>
  126. * $logger->logException($ex, [
  127. * 'message' => 'Exception during background job execution'
  128. * ]);
  129. * </code>
  130. *
  131. * @param \Exception|\Throwable $exception
  132. * @param array $context
  133. * @return void
  134. * @since 8.2.0
  135. */
  136. public function logException(\Throwable $exception, array $context = []);
  137. }