diff options
Diffstat (limited to 'core/Command/Log/Manage.php')
-rw-r--r-- | core/Command/Log/Manage.php | 93 |
1 files changed, 34 insertions, 59 deletions
diff --git a/core/Command/Log/Manage.php b/core/Command/Log/Manage.php index 4c7e7dd8497..f67f0d969f6 100644 --- a/core/Command/Log/Manage.php +++ b/core/Command/Log/Manage.php @@ -1,28 +1,9 @@ <?php + /** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Joas Schilling <coding@schilljs.com> - * @author Johannes Ernst <jernst@indiecomputing.com> - * @author Robin McCorkell <robin@mccorkell.me.uk> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * @author Tim Terhorst <mynamewastaken+gitlab@gmail.com> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only */ namespace OC\Core\Command\Log; @@ -39,11 +20,9 @@ class Manage extends Command implements CompletionAwareInterface { public const DEFAULT_LOG_LEVEL = 2; public const DEFAULT_TIMEZONE = 'UTC'; - /** @var IConfig */ - protected $config; - - public function __construct(IConfig $config) { - $this->config = $config; + public function __construct( + protected IConfig $config, + ) { parent::__construct(); } @@ -105,14 +84,14 @@ class Manage extends Command implements CompletionAwareInterface { // display configuration $backend = $this->config->getSystemValue('log_type', self::DEFAULT_BACKEND); - $output->writeln('Enabled logging backend: '.$backend); + $output->writeln('Enabled logging backend: ' . $backend); $levelNum = $this->config->getSystemValue('loglevel', self::DEFAULT_LOG_LEVEL); $level = $this->convertLevelNumber($levelNum); - $output->writeln('Log level: '.$level.' ('.$levelNum.')'); + $output->writeln('Log level: ' . $level . ' (' . $levelNum . ')'); $timezone = $this->config->getSystemValue('logtimezone', self::DEFAULT_TIMEZONE); - $output->writeln('Log timezone: '.$timezone); + $output->writeln('Log timezone: ' . $timezone); return 0; } @@ -121,7 +100,7 @@ class Manage extends Command implements CompletionAwareInterface { * @throws \InvalidArgumentException */ protected function validateBackend($backend) { - if (!class_exists('OC\\Log\\'.ucfirst($backend))) { + if (!class_exists('OC\\Log\\' . ucfirst($backend))) { throw new \InvalidArgumentException('Invalid backend'); } } @@ -142,18 +121,18 @@ class Manage extends Command implements CompletionAwareInterface { protected function convertLevelString($level) { $level = strtolower($level); switch ($level) { - case 'debug': - return 0; - case 'info': - return 1; - case 'warning': - case 'warn': - return 2; - case 'error': - case 'err': - return 3; - case 'fatal': - return 4; + case 'debug': + return 0; + case 'info': + return 1; + case 'warning': + case 'warn': + return 2; + case 'error': + case 'err': + return 3; + case 'fatal': + return 4; } throw new \InvalidArgumentException('Invalid log level string'); } @@ -165,16 +144,16 @@ class Manage extends Command implements CompletionAwareInterface { */ protected function convertLevelNumber($levelNum) { switch ($levelNum) { - case 0: - return 'Debug'; - case 1: - return 'Info'; - case 2: - return 'Warning'; - case 3: - return 'Error'; - case 4: - return 'Fatal'; + case 0: + return 'Debug'; + case 1: + return 'Info'; + case 2: + return 'Warning'; + case 3: + return 'Error'; + case 4: + return 'Fatal'; } throw new \InvalidArgumentException('Invalid log level number'); } @@ -190,11 +169,7 @@ class Manage extends Command implements CompletionAwareInterface { } elseif ($optionName === 'level') { return ['debug', 'info', 'warning', 'error', 'fatal']; } elseif ($optionName === 'timezone') { - $identifier = \DateTimeZone::listIdentifiers(); - if ($identifier === false) { - return []; - } - return $identifier; + return \DateTimeZone::listIdentifiers(); } return []; } |