Browse Source

Log exception using ILogger

Signed-off-by: Patrik Kernstock <info@pkern.at>
tags/v15.0.0beta1
Patrik Kernstock 5 years ago
parent
commit
1973556346
2 changed files with 15 additions and 2 deletions
  1. 14
    1
      core/Command/App/Remove.php
  2. 1
    1
      core/register_command.php

+ 14
- 1
core/Command/App/Remove.php View File

@@ -24,6 +24,7 @@ namespace OC\Core\Command\App;

use OC\Installer;
use OCP\App\IAppManager;
use OCP\ILogger;
use Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionAwareInterface;
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
use Symfony\Component\Console\Command\Command;
@@ -38,15 +39,19 @@ class Remove extends Command implements CompletionAwareInterface {
protected $manager;
/** @var Installer */
private $installer;
/** @var ILogger */
private $logger;

/**
* @param IAppManager $manager
* @param Installer $installer
* @param ILogger $logger
*/
public function __construct(IAppManager $manager, Installer $installer) {
public function __construct(IAppManager $manager, Installer $installer, ILogger $logger) {
parent::__construct();
$this->manager = $manager;
$this->installer = $installer;
$this->logger = $logger;
}

protected function configure() {
@@ -90,6 +95,10 @@ class Remove extends Command implements CompletionAwareInterface {
$output->writeln($appId . ' disabled');
} catch(\Exception $e) {
$output->writeln('Error: ' . $e->getMessage());
$this->logger->logException($e, [
'app' => 'CLI',
'level' => ILogger::ERROR
]);
return 1;
}
}
@@ -99,6 +108,10 @@ class Remove extends Command implements CompletionAwareInterface {
$result = $this->installer->removeApp($appId);
} catch(\Exception $e) {
$output->writeln('Error: ' . $e->getMessage());
$this->logger->logException($e, [
'app' => 'CLI',
'level' => ILogger::ERROR
]);
return 1;
}


+ 1
- 1
core/register_command.php View File

@@ -65,7 +65,7 @@ if (\OC::$server->getConfig()->getSystemValue('installed', false)) {
$application->add(new OC\Core\Command\App\Install());
$application->add(new OC\Core\Command\App\GetPath());
$application->add(new OC\Core\Command\App\ListApps(\OC::$server->getAppManager()));
$application->add(new OC\Core\Command\App\Remove(\OC::$server->getAppManager(), \OC::$server->query(\OC\Installer::class)));
$application->add(new OC\Core\Command\App\Remove(\OC::$server->getAppManager(), \OC::$server->query(\OC\Installer::class), \OC::$server->getLogger()));

$application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\Cleanup::class));
$application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\Enforce::class));

Loading…
Cancel
Save