1
0

Logger.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2018, Roeland Jago Douma <roeland@famdouma.nl>
  5. *
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Roeland Jago Douma <roeland@famdouma.nl>
  8. *
  9. * @license GNU AGPL version 3 or any later version
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as
  13. * published by the Free Software Foundation, either version 3 of the
  14. * License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. namespace OC\AppFramework;
  26. use OCP\ILogger;
  27. /**
  28. * @deprecated
  29. */
  30. class Logger implements ILogger {
  31. /** @var ILogger */
  32. private $logger;
  33. /** @var string */
  34. private $appName;
  35. /**
  36. * @deprecated
  37. */
  38. public function __construct(ILogger $logger, string $appName) {
  39. $this->logger = $logger;
  40. $this->appName = $appName;
  41. }
  42. private function extendContext(array $context): array {
  43. if (!isset($context['app'])) {
  44. $context['app'] = $this->appName;
  45. }
  46. return $context;
  47. }
  48. /**
  49. * @deprecated
  50. */
  51. public function emergency(string $message, array $context = []) {
  52. $this->logger->emergency($message, $this->extendContext($context));
  53. }
  54. /**
  55. * @deprecated
  56. */
  57. public function alert(string $message, array $context = []) {
  58. $this->logger->alert($message, $this->extendContext($context));
  59. }
  60. /**
  61. * @deprecated
  62. */
  63. public function critical(string $message, array $context = []) {
  64. $this->logger->critical($message, $this->extendContext($context));
  65. }
  66. /**
  67. * @deprecated
  68. */
  69. public function error(string $message, array $context = []) {
  70. $this->logger->emergency($message, $this->extendContext($context));
  71. }
  72. /**
  73. * @deprecated
  74. */
  75. public function warning(string $message, array $context = []) {
  76. $this->logger->warning($message, $this->extendContext($context));
  77. }
  78. /**
  79. * @deprecated
  80. */
  81. public function notice(string $message, array $context = []) {
  82. $this->logger->notice($message, $this->extendContext($context));
  83. }
  84. /**
  85. * @deprecated
  86. */
  87. public function info(string $message, array $context = []) {
  88. $this->logger->info($message, $this->extendContext($context));
  89. }
  90. /**
  91. * @deprecated
  92. */
  93. public function debug(string $message, array $context = []) {
  94. $this->logger->debug($message, $this->extendContext($context));
  95. }
  96. /**
  97. * @deprecated
  98. */
  99. public function log(int $level, string $message, array $context = []) {
  100. $this->logger->log($level, $message, $this->extendContext($context));
  101. }
  102. /**
  103. * @deprecated
  104. */
  105. public function logException(\Throwable $exception, array $context = []) {
  106. $this->logger->logException($exception, $this->extendContext($context));
  107. }
  108. }