aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-11-25 09:12:27 +0100
committerGitHub <noreply@github.com>2016-11-25 09:12:27 +0100
commitb3696f3910848a3543577704a7ae25f24991c0b8 (patch)
tree014dc7c08ab7e14b64c63b4a1c9369836c016933 /lib
parentf514bb2be632d0fd689b21477da3f679d0b6566d (diff)
parent3620d8118425a99dced331d3b25a825155828386 (diff)
downloadnextcloud-server-b3696f3910848a3543577704a7ae25f24991c0b8.tar.gz
nextcloud-server-b3696f3910848a3543577704a7ae25f24991c0b8.zip
Merge pull request #2314 from nextcloud/log-upgrade-steps
Log all events that happen during an upgrade
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Updater.php131
1 files changed, 131 insertions, 0 deletions
diff --git a/lib/private/Updater.php b/lib/private/Updater.php
index c3d8ef9fea3..e30777227cc 100644
--- a/lib/private/Updater.php
+++ b/lib/private/Updater.php
@@ -102,6 +102,7 @@ class Updater extends BasicEmitter {
*/
public function upgrade() {
$this->emitRepairEvents();
+ $this->logAllEvents();
$logLevel = $this->config->getSystemValue('loglevel', Util::WARN);
$this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
@@ -477,5 +478,135 @@ class Updater extends BasicEmitter {
});
}
+ private function logAllEvents() {
+ $log = $this->log;
+
+ $dispatcher = \OC::$server->getEventDispatcher();
+ $dispatcher->addListener('\OC\DB\Migrator::executeSql', function($event) use ($log) {
+ if (!$event instanceof GenericEvent) {
+ return;
+ }
+ $log->info('\OC\DB\Migrator::executeSql: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']);
+ });
+ $dispatcher->addListener('\OC\DB\Migrator::checkTable', function($event) use ($log) {
+ if (!$event instanceof GenericEvent) {
+ return;
+ }
+ $log->info('\OC\DB\Migrator::checkTable: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']);
+ });
+
+ $repairListener = function($event) use ($log) {
+ if (!$event instanceof GenericEvent) {
+ return;
+ }
+ switch ($event->getSubject()) {
+ case '\OC\Repair::startProgress':
+ $log->info('\OC\Repair::startProgress: Starting ... ' . $event->getArgument(1) . ' (' . $event->getArgument(0) . ')', ['app' => 'updater']);
+ break;
+ case '\OC\Repair::advance':
+ $desc = $event->getArgument(1);
+ if (empty($desc)) {
+ $desc = '';
+ }
+ $log->info('\OC\Repair::advance: ' . $desc . ' (' . $event->getArgument(0) . ')', ['app' => 'updater']);
+
+ break;
+ case '\OC\Repair::finishProgress':
+ $log->info('\OC\Repair::finishProgress', ['app' => 'updater']);
+ break;
+ case '\OC\Repair::step':
+ $log->info('\OC\Repair::step: Repair step: ' . $event->getArgument(0), ['app' => 'updater']);
+ break;
+ case '\OC\Repair::info':
+ $log->info('\OC\Repair::info: Repair info: ' . $event->getArgument(0), ['app' => 'updater']);
+ break;
+ case '\OC\Repair::warning':
+ $log->warning('\OC\Repair::warning: Repair warning: ' . $event->getArgument(0), ['app' => 'updater']);
+ break;
+ case '\OC\Repair::error':
+ $log->error('\OC\Repair::error: Repair error: ' . $event->getArgument(0), ['app' => 'updater']);
+ break;
+ }
+ };
+
+ $dispatcher->addListener('\OC\Repair::startProgress', $repairListener);
+ $dispatcher->addListener('\OC\Repair::advance', $repairListener);
+ $dispatcher->addListener('\OC\Repair::finishProgress', $repairListener);
+ $dispatcher->addListener('\OC\Repair::step', $repairListener);
+ $dispatcher->addListener('\OC\Repair::info', $repairListener);
+ $dispatcher->addListener('\OC\Repair::warning', $repairListener);
+ $dispatcher->addListener('\OC\Repair::error', $repairListener);
+
+
+ $this->listen('\OC\Updater', 'maintenanceEnabled', function () use($log) {
+ $log->info('\OC\Updater::maintenanceEnabled: Turned on maintenance mode', ['app' => 'updater']);
+ });
+ $this->listen('\OC\Updater', 'maintenanceDisabled', function () use($log) {
+ $log->info('\OC\Updater::maintenanceDisabled: Turned off maintenance mode', ['app' => 'updater']);
+ });
+ $this->listen('\OC\Updater', 'maintenanceActive', function () use($log) {
+ $log->info('\OC\Updater::maintenanceActive: Maintenance mode is kept active', ['app' => 'updater']);
+ });
+ $this->listen('\OC\Updater', 'updateEnd', function ($success) use($log) {
+ if ($success) {
+ $log->info('\OC\Updater::updateEnd: Update successful', ['app' => 'updater']);
+ } else {
+ $log->error('\OC\Updater::updateEnd: Update failed', ['app' => 'updater']);
+ }
+ });
+ $this->listen('\OC\Updater', 'dbUpgradeBefore', function () use($log) {
+ $log->info('\OC\Updater::dbUpgradeBefore: Updating database schema', ['app' => 'updater']);
+ });
+ $this->listen('\OC\Updater', 'dbUpgrade', function () use($log) {
+ $log->info('\OC\Updater::dbUpgrade: Updated database', ['app' => 'updater']);
+ });
+ $this->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($log) {
+ $log->info('\OC\Updater::dbSimulateUpgradeBefore: Checking whether the database schema can be updated (this can take a long time depending on the database size)', ['app' => 'updater']);
+ });
+ $this->listen('\OC\Updater', 'dbSimulateUpgrade', function () use($log) {
+ $log->info('\OC\Updater::dbSimulateUpgrade: Checked database schema update', ['app' => 'updater']);
+ });
+ $this->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use($log) {
+ $log->info('\OC\Updater::incompatibleAppDisabled: Disabled incompatible app: ' . $app, ['app' => 'updater']);
+ });
+ $this->listen('\OC\Updater', 'thirdPartyAppDisabled', function ($app) use ($log) {
+ $log->info('\OC\Updater::thirdPartyAppDisabled: Disabled 3rd-party app: ' . $app, ['app' => 'updater']);
+ });
+ $this->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use($log) {
+ $log->info('\OC\Updater::upgradeAppStoreApp: Update 3rd-party app: ' . $app, ['app' => 'updater']);
+ });
+ $this->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($log) {
+ $log->info('\OC\Updater::appUpgradeCheckBefore: Checking updates of apps', ['app' => 'updater']);
+ });
+ $this->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($log) {
+ $log->info('\OC\Updater::appSimulateUpdate: Checking whether the database schema for <' . $app . '> can be updated (this can take a long time depending on the database size)', ['app' => 'updater']);
+ });
+ $this->listen('\OC\Updater', 'appUpgradeCheck', function () use ($log) {
+ $log->info('\OC\Updater::appUpgradeCheck: Checked database schema update for apps', ['app' => 'updater']);
+ });
+ $this->listen('\OC\Updater', 'appUpgradeStarted', function ($app) use ($log) {
+ $log->info('\OC\Updater::appUpgradeStarted: Updating <' . $app . '> ...', ['app' => 'updater']);
+ });
+ $this->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($log) {
+ $log->info('\OC\Updater::appUpgrade: Updated <' . $app . '> to ' . $version, ['app' => 'updater']);
+ });
+ $this->listen('\OC\Updater', 'failure', function ($message) use($log) {
+ $log->error('\OC\Updater::failure: ' . $message, ['app' => 'updater']);
+ });
+ $this->listen('\OC\Updater', 'setDebugLogLevel', function () use($log) {
+ $log->info('\OC\Updater::setDebugLogLevel: Set log level to debug', ['app' => 'updater']);
+ });
+ $this->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($log) {
+ $log->info('\OC\Updater::resetLogLevel: Reset log level to ' . $logLevelName . '(' . $logLevel . ')', ['app' => 'updater']);
+ });
+ $this->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($log) {
+ $log->info('\OC\Updater::startCheckCodeIntegrity: Starting code integrity check...', ['app' => 'updater']);
+ });
+ $this->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($log) {
+ $log->info('\OC\Updater::finishedCheckCodeIntegrity: Finished code integrity check', ['app' => 'updater']);
+ });
+
+ }
+
}