Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/files_sharing/tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ protected static function loginHelper($user, $create = false, $password = false)
$userObject = $userManager->createUser($user, $password);
$group = $groupManager->createGroup('group');

if ($group and $userObject) {
if ($group && $userObject) {
$group->addUser($userObject);
}
}
Expand Down
2 changes: 1 addition & 1 deletion console.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function exceptionHandler($exception) {
\OC::$server->getConfig(),
\OC::$server->getEventDispatcher(),
\OC::$server->getRequest(),
\OC::$server->getLogger(),
\OC::$server->get(\Psr\Log\LoggerInterface::class),
\OC::$server->query(\OC\MemoryInfo::class)
);
$application->loadCommands(new ArgvInput(), new ConsoleOutput());
Expand Down
3 changes: 2 additions & 1 deletion core/Command/Maintenance/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use OC\Setup;
use OC\SystemConfig;
use OCP\Defaults;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -85,7 +86,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->iniGetWrapper,
$server->getL10N('lib'),
$server->query(Defaults::class),
$server->getLogger(),
$server->get(LoggerInterface::class),
$server->getSecureRandom(),
\OC::$server->query(Installer::class)
);
Expand Down
14 changes: 6 additions & 8 deletions core/Command/Upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
use OC\Installer;
use OC\Updater;
use OCP\IConfig;
use OCP\ILogger;
use OCP\Util;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -56,15 +56,13 @@ class Upgrade extends Command {
/** @var IConfig */
private $config;

/** @var ILogger */
/** @var LoggerInterface */
private $logger;

/**
* @param IConfig $config
* @param ILogger $logger
* @param Installer $installer
*/
public function __construct(IConfig $config, ILogger $logger, Installer $installer) {
/** @var Installer */
private $installer;

public function __construct(IConfig $config, LoggerInterface $logger, Installer $installer) {
parent::__construct();
$this->config = $config;
$this->logger = $logger;
Expand Down
2 changes: 1 addition & 1 deletion core/ajax/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function handleRepairFeedback($event) {
// avoid side effects
\OC_User::setIncognitoMode(true);

$logger = \OC::$server->getLogger();
$logger = \OC::$server->get(\Psr\Log\LoggerInterface::class);
$config = \OC::$server->getConfig();
$updater = new \OC\Updater(
$config,
Expand Down
2 changes: 1 addition & 1 deletion core/register_command.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
$application->add(new OC\Core\Command\Maintenance\UpdateHtaccess());
$application->add(new OC\Core\Command\Maintenance\UpdateTheme(\OC::$server->getMimeTypeDetector(), \OC::$server->getMemCacheFactory()));

$application->add(new OC\Core\Command\Upgrade(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->query(\OC\Installer::class)));
$application->add(new OC\Core\Command\Upgrade(\OC::$server->getConfig(), \OC::$server->get(LoggerInterface::class), \OC::$server->query(\OC\Installer::class)));
$application->add(new OC\Core\Command\Maintenance\Repair(
new \OC\Repair([], \OC::$server->getEventDispatcher(), \OC::$server->get(LoggerInterface::class)),
\OC::$server->getConfig(),
Expand Down
2 changes: 1 addition & 1 deletion lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ public static function handleRequest() {
\OC::$server->get(\bantu\IniGetWrapper\IniGetWrapper::class),
\OC::$server->getL10N('lib'),
\OC::$server->query(\OCP\Defaults::class),
\OC::$server->getLogger(),
\OC::$server->get(\Psr\Log\LoggerInterface::class),
\OC::$server->getSecureRandom(),
\OC::$server->query(\OC\Installer::class)
);
Expand Down
18 changes: 5 additions & 13 deletions lib/private/App/AppManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
use OCP\IConfig;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\ILogger;
use OCP\IUser;
use OCP\IUserSession;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

class AppManager implements IAppManager {
Expand Down Expand Up @@ -83,7 +83,7 @@ class AppManager implements IAppManager {
/** @var EventDispatcherInterface */
private $dispatcher;

/** @var ILogger */
/** @var LoggerInterface */
private $logger;

/** @var string[] $appId => $enabled */
Expand All @@ -104,21 +104,13 @@ class AppManager implements IAppManager {
/** @var array */
private $autoDisabledApps = [];

/**
* @param IUserSession $userSession
* @param IConfig $config
* @param AppConfig $appConfig
* @param IGroupManager $groupManager
* @param ICacheFactory $memCacheFactory
* @param EventDispatcherInterface $dispatcher
*/
public function __construct(IUserSession $userSession,
IConfig $config,
AppConfig $appConfig,
IGroupManager $groupManager,
ICacheFactory $memCacheFactory,
EventDispatcherInterface $dispatcher,
ILogger $logger) {
LoggerInterface $logger) {
$this->userSession = $userSession;
$this->config = $config;
$this->appConfig = $appConfig;
Expand Down Expand Up @@ -249,7 +241,7 @@ private function checkAppForUser($enabled, $user) {

if (!is_array($groupIds)) {
$jsonError = json_last_error();
$this->logger->warning('AppManger::checkAppForUser - can\'t decode group IDs: ' . print_r($enabled, true) . ' - json error code: ' . $jsonError, ['app' => 'lib']);
$this->logger->warning('AppManger::checkAppForUser - can\'t decode group IDs: ' . print_r($enabled, true) . ' - json error code: ' . $jsonError);
return false;
}

Expand Down Expand Up @@ -282,7 +274,7 @@ private function checkAppForGroups(string $enabled, IGroup $group): bool {

if (!is_array($groupIds)) {
$jsonError = json_last_error();
$this->logger->warning('AppManger::checkAppForUser - can\'t decode group IDs: ' . print_r($enabled, true) . ' - json error code: ' . $jsonError, ['app' => 'lib']);
$this->logger->warning('AppManger::checkAppForUser - can\'t decode group IDs: ' . print_r($enabled, true) . ' - json error code: ' . $jsonError);
return false;
}

Expand Down
18 changes: 6 additions & 12 deletions lib/private/App/AppStore/Fetcher/AppFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\ILogger;
use Psr\Log\LoggerInterface;

class AppFetcher extends Fetcher {

Expand All @@ -46,20 +46,12 @@ class AppFetcher extends Fetcher {
/** @var bool */
private $ignoreMaxVersion;

/**
* @param Factory $appDataFactory
* @param IClientService $clientService
* @param ITimeFactory $timeFactory
* @param IConfig $config
* @param CompareVersion $compareVersion
* @param ILogger $logger
*/
public function __construct(Factory $appDataFactory,
IClientService $clientService,
ITimeFactory $timeFactory,
IConfig $config,
CompareVersion $compareVersion,
ILogger $logger) {
LoggerInterface $logger) {
parent::__construct(
$appDataFactory,
$clientService,
Expand All @@ -86,7 +78,7 @@ public function __construct(Factory $appDataFactory,
protected function fetch($ETag, $content, $allowUnstable = false) {
/** @var mixed[] $response */
$response = parent::fetch($ETag, $content);

if (empty($response)) {
return [];
}
Expand Down Expand Up @@ -134,7 +126,9 @@ protected function fetch($ETag, $content, $allowUnstable = false) {
$releases[] = $release;
}
} catch (\InvalidArgumentException $e) {
$this->logger->logException($e, ['app' => 'appstoreFetcher', 'level' => ILogger::WARN]);
$this->logger->warning($e->getMessage(), [
'exception' => $e,
]);
}
}
}
Expand Down
11 changes: 2 additions & 9 deletions lib/private/App/AppStore/Fetcher/CategoryFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,14 @@
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\ILogger;
use Psr\Log\LoggerInterface;

class CategoryFetcher extends Fetcher {
/**
* @param Factory $appDataFactory
* @param IClientService $clientService
* @param ITimeFactory $timeFactory
* @param IConfig $config
* @param ILogger $logger
*/
public function __construct(Factory $appDataFactory,
IClientService $clientService,
ITimeFactory $timeFactory,
IConfig $config,
ILogger $logger) {
LoggerInterface $logger) {
parent::__construct(
$appDataFactory,
$clientService,
Expand Down
18 changes: 7 additions & 11 deletions lib/private/App/AppStore/Fetcher/Fetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
use OCP\Files\NotFoundException;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\ILogger;
use Psr\Log\LoggerInterface;

abstract class Fetcher {
public const INVALIDATE_AFTER_SECONDS = 3600;
Expand All @@ -53,7 +53,7 @@ abstract class Fetcher {
protected $timeFactory;
/** @var IConfig */
protected $config;
/** @var Ilogger */
/** @var LoggerInterface */
protected $logger;
/** @var string */
protected $fileName;
Expand All @@ -64,18 +64,11 @@ abstract class Fetcher {
/** @var string */
protected $channel;

/**
* @param Factory $appDataFactory
* @param IClientService $clientService
* @param ITimeFactory $timeFactory
* @param IConfig $config
* @param ILogger $logger
*/
public function __construct(Factory $appDataFactory,
IClientService $clientService,
ITimeFactory $timeFactory,
IConfig $config,
ILogger $logger) {
LoggerInterface $logger) {
$this->appData = $appDataFactory->get('appstore');
$this->clientService = $clientService;
$this->timeFactory = $timeFactory;
Expand Down Expand Up @@ -202,7 +195,10 @@ public function get($allowUnstable = false) {
$this->logger->warning('Could not connect to appstore: ' . $e->getMessage(), ['app' => 'appstoreFetcher']);
return [];
} catch (\Exception $e) {
$this->logger->logException($e, ['app' => 'appstoreFetcher', 'level' => ILogger::WARN]);
$this->logger->warning($e->getMessage(), [
'exception' => $e,
'app' => 'appstoreFetcher',
]);
return [];
}
}
Expand Down
20 changes: 9 additions & 11 deletions lib/private/AppFramework/Bootstrap/Coordinator.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
use OCP\AppFramework\QueryException;
use OCP\Dashboard\IManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\ILogger;
use OCP\IServerContainer;
use Psr\Log\LoggerInterface;
use Throwable;
use function class_exists;
use function class_implements;
Expand All @@ -57,7 +57,7 @@ class Coordinator {
/** @var IEventDispatcher */
private $eventDispatcher;

/** @var ILogger */
/** @var LoggerInterface */
private $logger;

/** @var RegistrationContext|null */
Expand All @@ -70,7 +70,7 @@ public function __construct(IServerContainer $container,
Registry $registry,
IManager $dashboardManager,
IEventDispatcher $eventListener,
ILogger $logger) {
LoggerInterface $logger) {
$this->serverContainer = $container;
$this->registry = $registry;
$this->dashboardManager = $dashboardManager;
Expand Down Expand Up @@ -124,9 +124,8 @@ private function registerApps(array $appIds): void {
try {
$application->register($this->registrationContext->for($appId));
} catch (Throwable $e) {
$this->logger->logException($e, [
'message' => 'Error during app service registration: ' . $e->getMessage(),
'level' => ILogger::FATAL,
$this->logger->emergency('Error during app service registration: ' . $e->getMessage(), [
'exception' => $e,
]);
}
}
Expand Down Expand Up @@ -176,13 +175,12 @@ public function bootApp(string $appId): void {
$application->boot($context);
}
} catch (QueryException $e) {
$this->logger->logException($e, [
'message' => "Could not boot $appId" . $e->getMessage(),
$this->logger->error("Could not boot $appId" . $e->getMessage(), [
'exception' => $e,
]);
} catch (Throwable $e) {
$this->logger->logException($e, [
'message' => "Could not boot $appId" . $e->getMessage(),
'level' => ILogger::FATAL,
$this->logger->emergency("Could not boot $appId" . $e->getMessage(), [
'exception' => $e,
]);
}
}
Expand Down
Loading