diff --git a/core/command/upgrade.php b/core/command/upgrade.php
index cf376148a00..de65d6176e8 100644
--- a/core/command/upgrade.php
+++ b/core/command/upgrade.php
@@ -46,6 +46,11 @@ class Upgrade extends Command {
*/
private $config;
+ /**
+ * @var bool
+ */
+ private $showTimestamp = false;
+
/**
* @param IConfig $config
*/
@@ -75,6 +80,12 @@ class Upgrade extends Command {
null,
InputOption::VALUE_NONE,
'skips the disable of third party apps'
+ )
+ ->addOption(
+ '--show-timestamp',
+ null,
+ InputOption::VALUE_NONE,
+ 'show timestamp for each output during upgrade'
);
}
@@ -99,6 +110,9 @@ class Upgrade extends Command {
if ($input->getOption('no-app-disable')) {
$skip3rdPartyAppsDisable = true;
}
+ if ($input->getOption('show-timestamp')) {
+ $this->showTimestamp = true;
+ }
if (!$simulateStepEnabled && !$updateStepEnabled) {
$output->writeln(
@@ -118,13 +132,13 @@ class Upgrade extends Command {
$updater->setSkip3rdPartyAppsDisable($skip3rdPartyAppsDisable);
$updater->listen('\OC\Updater', 'maintenanceEnabled', function () use($output) {
- $output->writeln('Turned on maintenance mode');
+ $this->writeln($output, 'Turned on maintenance mode');
});
$updater->listen('\OC\Updater', 'maintenanceDisabled', function () use($output) {
- $output->writeln('Turned off maintenance mode');
+ $this->writeln($output, 'Turned off maintenance mode');
});
$updater->listen('\OC\Updater', 'maintenanceActive', function () use($output) {
- $output->writeln('Maintenance mode is kept active');
+ $this->writeln($output, 'Maintenance mode is kept active');
});
$updater->listen('\OC\Updater', 'updateEnd',
function ($success) use($output, $updateStepEnabled, $self) {
@@ -132,40 +146,40 @@ class Upgrade extends Command {
$status = $success ? 'successful' : 'failed' ;
$type = $success ? 'info' : 'error';
$message = "<$type>$mode $status$type>";
- $output->writeln($message);
+ $this->writeln($output, $message);
});
$updater->listen('\OC\Updater', 'dbUpgrade', function () use($output) {
- $output->writeln('Updated database');
+ $this->writeln($output, 'Updated database');
});
$updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use($output) {
- $output->writeln('Checked database schema update');
+ $this->writeln($output, 'Checked database schema update');
});
$updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use($output) {
- $output->writeln('Disabled incompatible app: ' . $app . '');
+ $$this->writeln($output, 'Disabled incompatible app: ' . $app . '');
});
$updater->listen('\OC\Updater', 'thirdPartyAppDisabled', function ($app) use ($output) {
- $output->writeln('Disabled 3rd-party app: ' . $app . '');
+ $this->writeln($output, 'Disabled 3rd-party app: ' . $app . '');
});
$updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use($output) {
- $output->writeln('Update 3rd-party app: ' . $app . '');
+ $this->writeln($output, 'Update 3rd-party app: ' . $app . '');
});
$updater->listen('\OC\Updater', 'repairWarning', function ($app) use($output) {
- $output->writeln('Repair warning: ' . $app . '');
+ $this->writeln($output, 'Repair warning: ' . $app . '');
});
$updater->listen('\OC\Updater', 'repairError', function ($app) use($output) {
- $output->writeln('Repair error: ' . $app . '');
+ $this->writeln($output, 'Repair error: ' . $app . '');
});
$updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($output) {
- $output->writeln('Checked database schema update for apps');
+ $this->writeln($output, 'Checked database schema update for apps');
});
$updater->listen('\OC\Updater', 'appUpgradeStarted', function ($app, $version) use ($output) {
$output->writeln("Updating <$app> ...");
});
$updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($output) {
- $output->writeln("Updated <$app> to $version");
+ $this->writeln($output, "Updated <$app> to $version");
});
$updater->listen('\OC\Updater', 'failure', function ($message) use($output, $self) {
- $output->writeln("$message");
+ $this->writeln($output, "$message");
});
$success = $updater->upgrade();
@@ -208,4 +222,19 @@ class Upgrade extends Command {
);
}
}
+
+ /**
+ * Prints a line to output and adds a timestamp if needed
+ *
+ * @param OutputInterface $output
+ * @param string $line
+ */
+ protected function writeln(OutputInterface $output, $line) {
+ $t = '';
+ if($this->showTimestamp) {
+ $time = new \DateTime();
+ $t = $time->format(\DateTime::ISO8601) . ' ';
+ }
+ $output->writeln($t . $line);
+ }
}