Logger.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\AppFramework;
  8. use OCP\ILogger;
  9. /**
  10. * @deprecated
  11. */
  12. class Logger implements ILogger {
  13. /** @var ILogger */
  14. private $logger;
  15. /** @var string */
  16. private $appName;
  17. /**
  18. * @deprecated
  19. */
  20. public function __construct(ILogger $logger, string $appName) {
  21. $this->logger = $logger;
  22. $this->appName = $appName;
  23. }
  24. private function extendContext(array $context): array {
  25. if (!isset($context['app'])) {
  26. $context['app'] = $this->appName;
  27. }
  28. return $context;
  29. }
  30. /**
  31. * @deprecated
  32. */
  33. public function emergency(string $message, array $context = []) {
  34. $this->logger->emergency($message, $this->extendContext($context));
  35. }
  36. /**
  37. * @deprecated
  38. */
  39. public function alert(string $message, array $context = []) {
  40. $this->logger->alert($message, $this->extendContext($context));
  41. }
  42. /**
  43. * @deprecated
  44. */
  45. public function critical(string $message, array $context = []) {
  46. $this->logger->critical($message, $this->extendContext($context));
  47. }
  48. /**
  49. * @deprecated
  50. */
  51. public function error(string $message, array $context = []) {
  52. $this->logger->emergency($message, $this->extendContext($context));
  53. }
  54. /**
  55. * @deprecated
  56. */
  57. public function warning(string $message, array $context = []) {
  58. $this->logger->warning($message, $this->extendContext($context));
  59. }
  60. /**
  61. * @deprecated
  62. */
  63. public function notice(string $message, array $context = []) {
  64. $this->logger->notice($message, $this->extendContext($context));
  65. }
  66. /**
  67. * @deprecated
  68. */
  69. public function info(string $message, array $context = []) {
  70. $this->logger->info($message, $this->extendContext($context));
  71. }
  72. /**
  73. * @deprecated
  74. */
  75. public function debug(string $message, array $context = []) {
  76. $this->logger->debug($message, $this->extendContext($context));
  77. }
  78. /**
  79. * @deprecated
  80. */
  81. public function log(int $level, string $message, array $context = []) {
  82. $this->logger->log($level, $message, $this->extendContext($context));
  83. }
  84. /**
  85. * @deprecated
  86. */
  87. public function logException(\Throwable $exception, array $context = []) {
  88. $this->logger->logException($exception, $this->extendContext($context));
  89. }
  90. }