aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/AppFramework
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-04-16 14:26:43 +0200
committerJoas Schilling <coding@schilljs.com>2021-04-27 14:34:32 +0200
commit56ae87c281d2f54b23f98acf0e138d8e72196a06 (patch)
treed875702c4eb0901bcf6d3e23570a05ba5c397954 /lib/private/AppFramework
parentbf1c875425e7fdf5ffd3c233ddf1f567428b4168 (diff)
downloadnextcloud-server-56ae87c281d2f54b23f98acf0e138d8e72196a06.tar.gz
nextcloud-server-56ae87c281d2f54b23f98acf0e138d8e72196a06.zip
Less ILogger
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/AppFramework')
-rw-r--r--lib/private/AppFramework/Bootstrap/Coordinator.php11
-rw-r--r--lib/private/AppFramework/Bootstrap/RegistrationContext.php46
-rw-r--r--lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php11
3 files changed, 29 insertions, 39 deletions
diff --git a/lib/private/AppFramework/Bootstrap/Coordinator.php b/lib/private/AppFramework/Bootstrap/Coordinator.php
index 06a17e5242b..627618f04fa 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,
]);
}
}
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/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;
}