[upgrade] switch to debug logging on upgrade

* resets afterwards
* adds output about the previous log level
This commit is contained in:
Morris Jobke 2015-09-29 14:35:32 +02:00
parent c2dd0f80ec
commit 5acb38b5b3
3 changed files with 28 additions and 0 deletions

View File

@ -88,6 +88,12 @@ if (OC::checkUpgrade(false)) {
$eventSource->close(); $eventSource->close();
OC_Config::setValue('maintenance', false); OC_Config::setValue('maintenance', false);
}); });
$updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use($eventSource, $l) {
$eventSource->send('success', (string)$l->t('Set log level to debug - current level: "%s"', [ $logLevelName ]));
});
$updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($eventSource, $l) {
$eventSource->send('success', (string)$l->t('Reset log level to "%s"', [ $logLevelName ]));
});
try { try {
$updater->upgrade(); $updater->upgrade();

View File

@ -177,6 +177,12 @@ class Upgrade extends Command {
$updater->listen('\OC\Updater', 'failure', function ($message) use($output, $self) { $updater->listen('\OC\Updater', 'failure', function ($message) use($output, $self) {
$output->writeln("<error>$message</error>"); $output->writeln("<error>$message</error>");
}); });
$updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use($output) {
$output->writeln("<info>Set log level to debug - current level: '$logLevelName'</info>");
});
$updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($output) {
$output->writeln("<info>Reset log level to '$logLevelName'</info>");
});
if(OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { if(OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
$updater->listen('\OC\Updater', 'repairInfo', function ($message) use($output) { $updater->listen('\OC\Updater', 'repairInfo', function ($message) use($output) {

View File

@ -32,6 +32,7 @@
namespace OC; namespace OC;
use OC\Core\Command\Log\Manage;
use OC\Hooks\BasicEmitter; use OC\Hooks\BasicEmitter;
use OC_App; use OC_App;
use OC_Installer; use OC_Installer;
@ -69,6 +70,14 @@ class Updater extends BasicEmitter {
/** @var bool */ /** @var bool */
private $skip3rdPartyAppsDisable; private $skip3rdPartyAppsDisable;
private $logLevelNames = [
0 => 'Debug',
1 => 'Info',
2 => 'Warning',
3 => 'Error',
4 => 'Fatal',
];
/** /**
* @param HTTPHelper $httpHelper * @param HTTPHelper $httpHelper
* @param IConfig $config * @param IConfig $config
@ -177,6 +186,10 @@ class Updater extends BasicEmitter {
* @return bool true if the operation succeeded, false otherwise * @return bool true if the operation succeeded, false otherwise
*/ */
public function upgrade() { public function upgrade() {
$logLevel = $this->config->getSystemValue('loglevel', \OCP\Util::WARN);
$this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
$this->config->setSystemValue('loglevel', \OCP\Util::DEBUG);
$wasMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); $wasMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false);
if(!$wasMaintenanceModeEnabled) { if(!$wasMaintenanceModeEnabled) {
@ -208,6 +221,9 @@ class Updater extends BasicEmitter {
$this->emit('\OC\Updater', 'maintenanceActive'); $this->emit('\OC\Updater', 'maintenanceActive');
} }
$this->emit('\OC\Updater', 'resetLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
$this->config->setSystemValue('loglevel', $logLevel);
return $success; return $success;
} }