diff options
author | Christoph Wurst <ChristophWurst@users.noreply.github.com> | 2021-04-27 15:38:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-27 15:38:12 +0200 |
commit | 99f0b104216618625114d6dc314598dc294f080d (patch) | |
tree | 5f788797751a39248cdf07a3803898ccbdb9c22c /lib/private/AppFramework | |
parent | 48c50277a92b3b37fb4a9a9e7e20a487649b99db (diff) | |
parent | 2d75868935c7eedc5f94e63a45a27875e19053dc (diff) | |
download | nextcloud-server-99f0b104216618625114d6dc314598dc294f080d.tar.gz nextcloud-server-99f0b104216618625114d6dc314598dc294f080d.zip |
Merge pull request #26591 from nextcloud/techdebt/noid/less-ilogger
Less ILogger
Diffstat (limited to 'lib/private/AppFramework')
4 files changed, 34 insertions, 45 deletions
diff --git a/lib/private/AppFramework/Bootstrap/Coordinator.php b/lib/private/AppFramework/Bootstrap/Coordinator.php index 06a17e5242b..33b02c0291f 100644 --- a/lib/private/AppFramework/Bootstrap/Coordinator.php +++ b/lib/private/AppFramework/Bootstrap/Coordinator.php @@ -36,8 +36,8 @@ use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\QueryException; use OCP\Dashboard\IManager; use OCP\EventDispatcher\IEventDispatcher; -use OCP\ILogger; use OCP\IServerContainer; +use Psr\Log\LoggerInterface; use Throwable; use function class_exists; use function class_implements; @@ -57,7 +57,7 @@ class Coordinator { /** @var IEventDispatcher */ private $eventDispatcher; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; /** @var RegistrationContext|null */ @@ -70,7 +70,7 @@ class Coordinator { Registry $registry, IManager $dashboardManager, IEventDispatcher $eventListener, - ILogger $logger) { + LoggerInterface $logger) { $this->serverContainer = $container; $this->registry = $registry; $this->dashboardManager = $dashboardManager; @@ -124,9 +124,8 @@ class Coordinator { try { $application->register($this->registrationContext->for($appId)); } catch (Throwable $e) { - $this->logger->logException($e, [ - 'message' => 'Error during app service registration: ' . $e->getMessage(), - 'level' => ILogger::FATAL, + $this->logger->emergency('Error during app service registration: ' . $e->getMessage(), [ + 'exception' => $e, ]); } } @@ -176,13 +175,12 @@ class Coordinator { $application->boot($context); } } catch (QueryException $e) { - $this->logger->logException($e, [ - 'message' => "Could not boot $appId" . $e->getMessage(), + $this->logger->error("Could not boot $appId" . $e->getMessage(), [ + 'exception' => $e, ]); } catch (Throwable $e) { - $this->logger->logException($e, [ - 'message' => "Could not boot $appId" . $e->getMessage(), - 'level' => ILogger::FATAL, + $this->logger->emergency("Could not boot $appId" . $e->getMessage(), [ + 'exception' => $e, ]); } } diff --git a/lib/private/AppFramework/Bootstrap/RegistrationContext.php b/lib/private/AppFramework/Bootstrap/RegistrationContext.php index d056c088a9f..0859e606b7e 100644 --- a/lib/private/AppFramework/Bootstrap/RegistrationContext.php +++ b/lib/private/AppFramework/Bootstrap/RegistrationContext.php @@ -43,10 +43,10 @@ use OCP\Dashboard\IWidget; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Template\ICustomTemplateProvider; use OCP\Http\WellKnown\IHandler; -use OCP\ILogger; use OCP\Notification\INotifier; use OCP\Search\IProvider; use OCP\Support\CrashReport\IReporter; +use Psr\Log\LoggerInterface; use Throwable; use function array_shift; @@ -97,10 +97,10 @@ class RegistrationContext { /** @var ServiceRegistration<\OCP\Authentication\TwoFactorAuth\IProvider>[] */ private $twoFactorProviders = []; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; - public function __construct(ILogger $logger) { + public function __construct(LoggerInterface $logger) { $this->logger = $logger; } @@ -313,9 +313,8 @@ class RegistrationContext { ->registerCapability($registration->getService()); } catch (Throwable $e) { $appId = $registration->getAppId(); - $this->logger->logException($e, [ - 'message' => "Error during capability registration of $appId: " . $e->getMessage(), - 'level' => ILogger::ERROR, + $this->logger->error("Error during capability registration of $appId: " . $e->getMessage(), [ + 'exception' => $e, ]); } } @@ -330,9 +329,8 @@ class RegistrationContext { $registry->registerLazy($registration->getService()); } catch (Throwable $e) { $appId = $registration->getAppId(); - $this->logger->logException($e, [ - 'message' => "Error during crash reporter registration of $appId: " . $e->getMessage(), - 'level' => ILogger::ERROR, + $this->logger->error("Error during crash reporter registration of $appId: " . $e->getMessage(), [ + 'exception' => $e, ]); } } @@ -347,9 +345,8 @@ class RegistrationContext { $dashboardManager->lazyRegisterWidget($panel->getService()); } catch (Throwable $e) { $appId = $panel->getAppId(); - $this->logger->logException($e, [ - 'message' => "Error during dashboard registration of $appId: " . $e->getMessage(), - 'level' => ILogger::ERROR, + $this->logger->error("Error during dashboard registration of $appId: " . $e->getMessage(), [ + 'exception' => $e, ]); } } @@ -365,9 +362,8 @@ class RegistrationContext { ); } catch (Throwable $e) { $appId = $registration->getAppId(); - $this->logger->logException($e, [ - 'message' => "Error during event listener registration of $appId: " . $e->getMessage(), - 'level' => ILogger::ERROR, + $this->logger->error("Error during event listener registration of $appId: " . $e->getMessage(), [ + 'exception' => $e, ]); } } @@ -391,9 +387,8 @@ class RegistrationContext { ); } catch (Throwable $e) { $appId = $registration->getAppId(); - $this->logger->logException($e, [ - 'message' => "Error during service registration of $appId: " . $e->getMessage(), - 'level' => ILogger::ERROR, + $this->logger->error("Error during service registration of $appId: " . $e->getMessage(), [ + 'exception' => $e, ]); } } @@ -408,9 +403,8 @@ class RegistrationContext { ); } catch (Throwable $e) { $appId = $registration->getAppId(); - $this->logger->logException($e, [ - 'message' => "Error during service alias registration of $appId: " . $e->getMessage(), - 'level' => ILogger::ERROR, + $this->logger->error("Error during service alias registration of $appId: " . $e->getMessage(), [ + 'exception' => $e, ]); } } @@ -425,9 +419,8 @@ class RegistrationContext { ); } catch (Throwable $e) { $appId = $registration->getAppId(); - $this->logger->logException($e, [ - 'message' => "Error during service alias registration of $appId: " . $e->getMessage(), - 'level' => ILogger::ERROR, + $this->logger->error("Error during service alias registration of $appId: " . $e->getMessage(), [ + 'exception' => $e, ]); } } @@ -444,9 +437,8 @@ class RegistrationContext { ->registerMiddleWare($middleware->getService()); } catch (Throwable $e) { $appId = $middleware->getAppId(); - $this->logger->logException($e, [ - 'message' => "Error during capability registration of $appId: " . $e->getMessage(), - 'level' => ILogger::ERROR, + $this->logger->error("Error during capability registration of $appId: " . $e->getMessage(), [ + 'exception' => $e, ]); } } diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php index 7395be703d3..db4f3d2c075 100644 --- a/lib/private/AppFramework/DependencyInjection/DIContainer.php +++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php @@ -241,7 +241,7 @@ class DIContainer extends SimpleContainer implements IAppContainer { $c->get(IControllerMethodReflector::class), $c->get(INavigationManager::class), $c->get(IURLGenerator::class), - $server->query(ILogger::class), + $server->get(LoggerInterface::class), $c->get('AppName'), $server->getUserSession()->isLoggedIn(), $this->getUserId() !== null && $server->getGroupManager()->isAdmin($this->getUserId()), diff --git a/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php b/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php index 76665f8998f..9fa696154ff 100644 --- a/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php +++ b/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php @@ -55,11 +55,11 @@ use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Middleware; use OCP\AppFramework\OCSController; use OCP\IL10N; -use OCP\ILogger; use OCP\INavigationManager; use OCP\IRequest; use OCP\IURLGenerator; use OCP\Util; +use Psr\Log\LoggerInterface; /** * Used to do all the authentication and checking stuff for a controller method @@ -78,7 +78,7 @@ class SecurityMiddleware extends Middleware { private $appName; /** @var IURLGenerator */ private $urlGenerator; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; /** @var bool */ private $isLoggedIn; @@ -95,7 +95,7 @@ class SecurityMiddleware extends Middleware { ControllerMethodReflector $reflector, INavigationManager $navigationManager, IURLGenerator $urlGenerator, - ILogger $logger, + LoggerInterface $logger, string $appName, bool $isLoggedIn, bool $isAdminUser, @@ -233,9 +233,8 @@ class SecurityMiddleware extends Middleware { } } - $this->logger->logException($exception, [ - 'level' => ILogger::DEBUG, - 'app' => 'core', + $this->logger->debug($exception->getMessage(), [ + 'exception' => $exception, ]); return $response; } |