summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2022-02-11 09:08:02 +0100
committerJulius Härtl <jus@bitgrid.net>2022-02-28 11:24:41 +0100
commiteede608c0e9cd313bc672df1f0e37aca2a0ef2ad (patch)
tree2a61d39c2c379416cfa4dde85e51be949538d242 /lib/private
parent0f33453610c46ef730192820017f8c1270b3096f (diff)
downloadnextcloud-server-eede608c0e9cd313bc672df1f0e37aca2a0ef2ad.tar.gz
nextcloud-server-eede608c0e9cd313bc672df1f0e37aca2a0ef2ad.zip
Add event logging to app loading
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/AppFramework/Bootstrap/Coordinator.php10
-rw-r--r--lib/private/Diagnostics/EventLogger.php2
-rw-r--r--lib/private/legacy/OC_App.php5
3 files changed, 14 insertions, 3 deletions
diff --git a/lib/private/AppFramework/Bootstrap/Coordinator.php b/lib/private/AppFramework/Bootstrap/Coordinator.php
index 6e05b7fdc88..b6378830732 100644
--- a/lib/private/AppFramework/Bootstrap/Coordinator.php
+++ b/lib/private/AppFramework/Bootstrap/Coordinator.php
@@ -30,6 +30,7 @@ declare(strict_types=1);
namespace OC\AppFramework\Bootstrap;
+use OCP\Diagnostics\IEventLogger;
use function class_exists;
use function class_implements;
use function in_array;
@@ -58,6 +59,9 @@ class Coordinator {
/** @var IEventDispatcher */
private $eventDispatcher;
+ /** @var IEventLogger */
+ private $eventLogger;
+
/** @var LoggerInterface */
private $logger;
@@ -72,12 +76,14 @@ class Coordinator {
Registry $registry,
IManager $dashboardManager,
IEventDispatcher $eventListener,
+ IEventLogger $eventLogger,
LoggerInterface $logger
) {
$this->serverContainer = $container;
$this->registry = $registry;
$this->dashboardManager = $dashboardManager;
$this->eventDispatcher = $eventListener;
+ $this->eventLogger = $eventLogger;
$this->logger = $logger;
}
@@ -126,7 +132,9 @@ class Coordinator {
continue;
}
+ $this->eventLogger->start('bootstrap:register_app_' . $appId, '');
$application->register($this->registrationContext->for($appId));
+ $this->eventLogger->end('bootstrap:register_app_' . $appId);
}
} catch (Throwable $e) {
$this->logger->emergency('Error during app service registration: ' . $e->getMessage(), [
@@ -172,6 +180,7 @@ class Coordinator {
* the instance was already created for register, but any other
* (legacy) code will now do their magic via the constructor.
*/
+ $this->eventLogger->start('bootstrap:boot_app_' . $appId, '');
try {
/** @var App $application */
$application = $this->serverContainer->query($applicationClassName);
@@ -189,6 +198,7 @@ class Coordinator {
'exception' => $e,
]);
}
+ $this->eventLogger->end('bootstrap:boot_app_' . $appId);
}
public function isBootable(string $appId) {
diff --git a/lib/private/Diagnostics/EventLogger.php b/lib/private/Diagnostics/EventLogger.php
index edaa4bc0d50..02867b3b4b7 100644
--- a/lib/private/Diagnostics/EventLogger.php
+++ b/lib/private/Diagnostics/EventLogger.php
@@ -72,7 +72,7 @@ class EventLogger implements IEventLogger {
/**
* @inheritdoc
*/
- public function start($id, $description) {
+ public function start($id, $description = '') {
if ($this->activated) {
$this->events[$id] = new Event($id, $description, microtime(true));
$this->writeLog($this->events[$id]);
diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php
index 1ce3662000e..ca01e91216b 100644
--- a/lib/private/legacy/OC_App.php
+++ b/lib/private/legacy/OC_App.php
@@ -173,6 +173,7 @@ class OC_App {
$hasAppPhpFile = is_file($appPath . '/appinfo/app.php');
+ \OC::$server->getEventLogger()->start('bootstrap:load_app_' . $app, 'Load app: ' . $app);
if ($isBootable && $hasAppPhpFile) {
\OC::$server->getLogger()->error('/appinfo/app.php is not loaded when \OCP\AppFramework\Bootstrap\IBootstrap on the application class is used. Migrate everything from app.php to the Application class.', [
'app' => $app,
@@ -181,7 +182,6 @@ class OC_App {
\OC::$server->getLogger()->debug('/appinfo/app.php is deprecated, use \OCP\AppFramework\Bootstrap\IBootstrap on the application class instead.', [
'app' => $app,
]);
- \OC::$server->getEventLogger()->start('load_app_' . $app, 'Load app: ' . $app);
try {
self::requireAppFile($app);
} catch (Throwable $ex) {
@@ -201,8 +201,9 @@ class OC_App {
]);
}
}
- \OC::$server->getEventLogger()->end('load_app_' . $app);
}
+ \OC::$server->getEventLogger()->end('bootstrap:load_app_' . $app);
+
$coordinator->bootApp($app);
$info = self::getAppInfo($app);