diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2018-04-25 15:22:28 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2018-04-26 10:45:52 +0200 |
commit | 38a90130ce425d531a804dff591df4a883de3154 (patch) | |
tree | d579e7442832672ab2987f9c9ecf62e79ca09a8d /lib/private | |
parent | 12c5db90322f61d4d48e1bb534bb94382d17e317 (diff) | |
download | nextcloud-server-38a90130ce425d531a804dff591df4a883de3154.tar.gz nextcloud-server-38a90130ce425d531a804dff591df4a883de3154.zip |
move log constants to ILogger
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib/private')
38 files changed, 189 insertions, 153 deletions
diff --git a/lib/private/App/AppStore/Fetcher/AppFetcher.php b/lib/private/App/AppStore/Fetcher/AppFetcher.php index 5203515e09b..cf5839e4994 100644 --- a/lib/private/App/AppStore/Fetcher/AppFetcher.php +++ b/lib/private/App/AppStore/Fetcher/AppFetcher.php @@ -101,7 +101,7 @@ class AppFetcher extends Fetcher { $releases[] = $release; } } catch (\InvalidArgumentException $e) { - $this->logger->logException($e, ['app' => 'appstoreFetcher', 'level' => Util::WARN]); + $this->logger->logException($e, ['app' => 'appstoreFetcher', 'level' => ILogger::WARN]); } } } diff --git a/lib/private/App/AppStore/Fetcher/Fetcher.php b/lib/private/App/AppStore/Fetcher/Fetcher.php index 172584c522b..973c4e55e9f 100644 --- a/lib/private/App/AppStore/Fetcher/Fetcher.php +++ b/lib/private/App/AppStore/Fetcher/Fetcher.php @@ -171,10 +171,10 @@ abstract class Fetcher { $file->putContent(json_encode($responseJson)); return json_decode($file->getContent(), true)['data']; } catch (ConnectException $e) { - $this->logger->logException($e, ['app' => 'appstoreFetcher', 'level' => Util::INFO, 'message' => 'Could not connect to appstore']); + $this->logger->logException($e, ['app' => 'appstoreFetcher', 'level' => ILogger::INFO, 'message' => 'Could not connect to appstore']); return []; } catch (\Exception $e) { - $this->logger->logException($e, ['app' => 'appstoreFetcher', 'level' => Util::INFO]); + $this->logger->logException($e, ['app' => 'appstoreFetcher', 'level' => ILogger::INFO]); return []; } } diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php index 4dcb94a1d33..37a34106dbe 100644 --- a/lib/private/AppFramework/DependencyInjection/DIContainer.php +++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php @@ -57,6 +57,7 @@ use OCP\Files\Folder; use OCP\Files\IAppData; use OCP\GlobalScale\IConfig; use OCP\IL10N; +use OCP\ILogger; use OCP\IRequest; use OCP\IServerContainer; use OCP\IUserSession; @@ -375,19 +376,19 @@ class DIContainer extends SimpleContainer implements IAppContainer { public function log($message, $level) { switch($level){ case 'debug': - $level = \OCP\Util::DEBUG; + $level = ILogger::DEBUG; break; case 'info': - $level = \OCP\Util::INFO; + $level = ILogger::INFO; break; case 'warn': - $level = \OCP\Util::WARN; + $level = ILogger::WARN; break; case 'fatal': - $level = \OCP\Util::FATAL; + $level = ILogger::FATAL; break; default: - $level = \OCP\Util::ERROR; + $level = ILogger::ERROR; break; } \OCP\Util::writeLog($this->getAppName(), $message, $level); diff --git a/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php b/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php index 7eb730ac2a3..2eedc39c3ab 100644 --- a/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php +++ b/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php @@ -255,7 +255,7 @@ class SecurityMiddleware extends Middleware { } $this->logger->logException($exception, [ - 'level' => \OCP\Util::DEBUG, + 'level' => ILogger::DEBUG, 'app' => 'core', ]); return $response; diff --git a/lib/private/Archive/ZIP.php b/lib/private/Archive/ZIP.php index fb727aba224..bbfe91ada49 100644 --- a/lib/private/Archive/ZIP.php +++ b/lib/private/Archive/ZIP.php @@ -31,6 +31,7 @@ namespace OC\Archive; use Icewind\Streams\CallbackWrapper; +use OCP\ILogger; class ZIP extends Archive{ /** @@ -47,7 +48,7 @@ class ZIP extends Archive{ $this->zip=new \ZipArchive(); if($this->zip->open($source, \ZipArchive::CREATE)) { }else{ - \OCP\Util::writeLog('files_archive', 'Error while opening archive '.$source, \OCP\Util::WARN); + \OCP\Util::writeLog('files_archive', 'Error while opening archive '.$source, ILogger::WARN); } } /** diff --git a/lib/private/Cache/File.php b/lib/private/Cache/File.php index ab51b54b8c8..7d2d468ec2f 100644 --- a/lib/private/Cache/File.php +++ b/lib/private/Cache/File.php @@ -30,6 +30,7 @@ namespace OC\Cache; use OC\Files\Filesystem; use OC\Files\View; use OCP\ICache; +use OCP\ILogger; use OCP\Security\ISecureRandom; class File implements ICache { @@ -58,7 +59,7 @@ class File implements ICache { $this->storage = new View('/' . $user->getUID() . '/cache'); return $this->storage; } else { - \OCP\Util::writeLog('core', 'Can\'t get cache storage, user not logged in', \OCP\Util::ERROR); + \OCP\Util::writeLog('core', 'Can\'t get cache storage, user not logged in', ILogger::ERROR); throw new \OC\ForbiddenException('Can\t get cache storage, user not logged in'); } } diff --git a/lib/private/CapabilitiesManager.php b/lib/private/CapabilitiesManager.php index fb272764597..ceb8205a7bb 100644 --- a/lib/private/CapabilitiesManager.php +++ b/lib/private/CapabilitiesManager.php @@ -57,7 +57,7 @@ class CapabilitiesManager { } catch (QueryException $e) { $this->logger->logException($e, [ 'message' => 'CapabilitiesManager', - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'core', ]); continue; diff --git a/lib/private/DateTimeZone.php b/lib/private/DateTimeZone.php index 59da2f601ab..5bd5735226c 100644 --- a/lib/private/DateTimeZone.php +++ b/lib/private/DateTimeZone.php @@ -26,6 +26,7 @@ namespace OC; use OCP\IConfig; use OCP\IDateTimeZone; +use OCP\ILogger; use OCP\ISession; class DateTimeZone implements IDateTimeZone { @@ -64,7 +65,7 @@ class DateTimeZone implements IDateTimeZone { try { return new \DateTimeZone($timeZone); } catch (\Exception $e) { - \OCP\Util::writeLog('datetimezone', 'Failed to created DateTimeZone "' . $timeZone . "'", \OCP\Util::DEBUG); + \OCP\Util::writeLog('datetimezone', 'Failed to created DateTimeZone "' . $timeZone . "'", ILogger::DEBUG); return new \DateTimeZone($this->getDefaultTimeZone()); } } @@ -109,7 +110,7 @@ class DateTimeZone implements IDateTimeZone { } // No timezone found, fallback to UTC - \OCP\Util::writeLog('datetimezone', 'Failed to find DateTimeZone for offset "' . $offset . "'", \OCP\Util::DEBUG); + \OCP\Util::writeLog('datetimezone', 'Failed to find DateTimeZone for offset "' . $offset . "'", ILogger::DEBUG); return new \DateTimeZone($this->getDefaultTimeZone()); } } diff --git a/lib/private/Files/Cache/Scanner.php b/lib/private/Files/Cache/Scanner.php index 8f5f09319dd..e148a25accd 100644 --- a/lib/private/Files/Cache/Scanner.php +++ b/lib/private/Files/Cache/Scanner.php @@ -38,6 +38,7 @@ use OC\Files\Filesystem; use OC\Hooks\BasicEmitter; use OCP\Files\Cache\IScanner; use OCP\Files\ForbiddenException; +use OCP\ILogger; use OCP\Lock\ILockingProvider; /** @@ -110,7 +111,7 @@ class Scanner extends BasicEmitter implements IScanner { protected function getData($path) { $data = $this->storage->getMetaData($path); if (is_null($data)) { - \OCP\Util::writeLog(Scanner::class, "!!! Path '$path' is not accessible or present !!!", \OCP\Util::DEBUG); + \OCP\Util::writeLog(Scanner::class, "!!! Path '$path' is not accessible or present !!!", ILogger::DEBUG); } return $data; } @@ -454,7 +455,7 @@ class Scanner extends BasicEmitter implements IScanner { } \OC::$server->getLogger()->logException($ex, [ 'message' => 'Exception while scanning file "' . $child . '"', - 'level' => \OCP\Util::DEBUG, + 'level' => ILogger::DEBUG, 'app' => 'core', ]); $exceptionOccurred = true; diff --git a/lib/private/Files/Filesystem.php b/lib/private/Files/Filesystem.php index b9f0813c84a..12e59e5ba2d 100644 --- a/lib/private/Files/Filesystem.php +++ b/lib/private/Files/Filesystem.php @@ -65,6 +65,7 @@ use OC\Files\Storage\StorageFactory; use OC\Lockdown\Filesystem\NullStorage; use OCP\Files\Config\IMountProvider; use OCP\Files\NotFoundException; +use OCP\ILogger; use OCP\IUserManager; class Filesystem { @@ -408,7 +409,7 @@ class Filesystem { $userObject = $userManager->get($user); if (is_null($userObject)) { - \OCP\Util::writeLog('files', ' Backends provided no user object for ' . $user, \OCP\Util::ERROR); + \OCP\Util::writeLog('files', ' Backends provided no user object for ' . $user, ILogger::ERROR); // reset flag, this will make it possible to rethrow the exception if called again unset(self::$usersSetup[$user]); throw new \OC\User\NoUserException('Backends provided no user object for ' . $user); @@ -418,7 +419,7 @@ class Filesystem { // workaround in case of different casings if ($user !== $realUid) { $stack = json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 50)); - \OCP\Util::writeLog('files', 'initMountPoints() called with wrong user casing. This could be a bug. Expected: "' . $realUid . '" got "' . $user . '". Stack: ' . $stack, \OCP\Util::WARN); + \OCP\Util::writeLog('files', 'initMountPoints() called with wrong user casing. This could be a bug. Expected: "' . $realUid . '" got "' . $user . '". Stack: ' . $stack, ILogger::WARN); $user = $realUid; // again with the correct casing diff --git a/lib/private/Files/Mount/MountPoint.php b/lib/private/Files/Mount/MountPoint.php index 26150de2bd1..36e10bfb45a 100644 --- a/lib/private/Files/Mount/MountPoint.php +++ b/lib/private/Files/Mount/MountPoint.php @@ -33,6 +33,7 @@ use \OC\Files\Filesystem; use OC\Files\Storage\StorageFactory; use OC\Files\Storage\Storage; use OCP\Files\Mount\IMountPoint; +use OCP\ILogger; class MountPoint implements IMountPoint { /** @@ -152,12 +153,12 @@ class MountPoint implements IMountPoint { // the root storage could not be initialized, show the user! throw new \Exception('The root storage could not be initialized. Please contact your local administrator.', $exception->getCode(), $exception); } else { - \OC::$server->getLogger()->logException($exception, ['level' => \OCP\Util::ERROR]); + \OC::$server->getLogger()->logException($exception, ['level' => ILogger::ERROR]); } return; } } else { - \OCP\Util::writeLog('core', 'storage backend ' . $this->class . ' not found', \OCP\Util::ERROR); + \OCP\Util::writeLog('core', 'storage backend ' . $this->class . ' not found', ILogger::ERROR); $this->invalidStorage = true; return; } diff --git a/lib/private/Files/Mount/ObjectHomeMountProvider.php b/lib/private/Files/Mount/ObjectHomeMountProvider.php index 9c09c0737c8..62669020884 100644 --- a/lib/private/Files/Mount/ObjectHomeMountProvider.php +++ b/lib/private/Files/Mount/ObjectHomeMountProvider.php @@ -26,6 +26,7 @@ namespace OC\Files\Mount; use OCP\Files\Config\IHomeMountProvider; use OCP\Files\Storage\IStorageFactory; use OCP\IConfig; +use OCP\ILogger; use OCP\IUser; /** @@ -79,7 +80,7 @@ class ObjectHomeMountProvider implements IHomeMountProvider { // sanity checks if (empty($config['class'])) { - \OCP\Util::writeLog('files', 'No class given for objectstore', \OCP\Util::ERROR); + \OCP\Util::writeLog('files', 'No class given for objectstore', ILogger::ERROR); } if (!isset($config['arguments'])) { $config['arguments'] = []; @@ -104,7 +105,7 @@ class ObjectHomeMountProvider implements IHomeMountProvider { // sanity checks if (empty($config['class'])) { - \OCP\Util::writeLog('files', 'No class given for objectstore', \OCP\Util::ERROR); + \OCP\Util::writeLog('files', 'No class given for objectstore', ILogger::ERROR); } if (!isset($config['arguments'])) { $config['arguments'] = []; diff --git a/lib/private/Files/ObjectStore/S3ConnectionTrait.php b/lib/private/Files/ObjectStore/S3ConnectionTrait.php index 2556180173a..9565a82ac31 100644 --- a/lib/private/Files/ObjectStore/S3ConnectionTrait.php +++ b/lib/private/Files/ObjectStore/S3ConnectionTrait.php @@ -27,6 +27,7 @@ namespace OC\Files\ObjectStore; use Aws\ClientResolver; use Aws\S3\Exception\S3Exception; use Aws\S3\S3Client; +use OCP\ILogger; trait S3ConnectionTrait { /** @var array */ @@ -113,7 +114,7 @@ trait S3ConnectionTrait { } catch (S3Exception $e) { $logger->logException($e, [ 'message' => 'Invalid remote storage.', - 'level' => \OCP\Util::DEBUG, + 'level' => ILogger::DEBUG, 'app' => 'objectstore', ]); throw new \Exception('Creation of bucket "' . $this->bucket . '" failed. ' . $e->getMessage()); diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index c9a91a7c56a..0d0f1da2594 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -54,6 +54,7 @@ use OCP\Files\InvalidPathException; use OCP\Files\ReservedWordException; use OCP\Files\Storage\ILockingStorage; use OCP\Files\Storage\IStorage; +use OCP\ILogger; use OCP\Lock\ILockingProvider; use OCP\Lock\LockedException; @@ -453,7 +454,7 @@ abstract class Common implements Storage, ILockingStorage { return false; } catch (\Exception $e) { \OC::$server->getLogger()->info("External storage not available: " . $e->getMessage()); - \OC::$server->getLogger()->logException($e, ['level' => \OCP\Util::DEBUG]); + \OC::$server->getLogger()->logException($e, ['level' => ILogger::DEBUG]); return false; } } diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php index b3c2dc00189..1ce7b8acd45 100644 --- a/lib/private/Files/Storage/DAV.php +++ b/lib/private/Files/Storage/DAV.php @@ -35,6 +35,7 @@ namespace OC\Files\Storage; use Exception; use GuzzleHttp\Exception\RequestException; +use OCP\ILogger; use Psr\Http\Message\ResponseInterface; use Icewind\Streams\CallbackWrapper; use OC\Files\Filesystem; @@ -357,7 +358,7 @@ class DAV extends Common { if ($response->getStatusCode() === Http::STATUS_LOCKED) { throw new \OCP\Lock\LockedException($path); } else { - Util::writeLog("webdav client", 'Guzzle get returned status code ' . $response->getStatusCode(), Util::ERROR); + Util::writeLog("webdav client", 'Guzzle get returned status code ' . $response->getStatusCode(), ILogger::ERROR); } } diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index a0e20f4cba1..46b53dcf95c 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -42,6 +42,7 @@ namespace OC\Files\Storage; use OC\Files\Storage\Wrapper\Jail; use OCP\Files\ForbiddenException; use OCP\Files\Storage\IStorage; +use OCP\ILogger; /** * for local filestore, we only have to map the paths @@ -235,17 +236,17 @@ class Local extends \OC\Files\Storage\Common { $dstParent = dirname($path2); if (!$this->isUpdatable($srcParent)) { - \OCP\Util::writeLog('core', 'unable to rename, source directory is not writable : ' . $srcParent, \OCP\Util::ERROR); + \OCP\Util::writeLog('core', 'unable to rename, source directory is not writable : ' . $srcParent, ILogger::ERROR); return false; } if (!$this->isUpdatable($dstParent)) { - \OCP\Util::writeLog('core', 'unable to rename, destination directory is not writable : ' . $dstParent, \OCP\Util::ERROR); + \OCP\Util::writeLog('core', 'unable to rename, destination directory is not writable : ' . $dstParent, ILogger::ERROR); return false; } if (!$this->file_exists($path1)) { - \OCP\Util::writeLog('core', 'unable to rename, file does not exists : ' . $path1, \OCP\Util::ERROR); + \OCP\Util::writeLog('core', 'unable to rename, file does not exists : ' . $path1, ILogger::ERROR); return false; } @@ -382,7 +383,7 @@ class Local extends \OC\Files\Storage\Common { return $fullPath; } - \OCP\Util::writeLog('core', "Following symlinks is not allowed ('$fullPath' -> '$realPath' not inside '{$this->realDataDir}')", \OCP\Util::ERROR); + \OCP\Util::writeLog('core', "Following symlinks is not allowed ('$fullPath' -> '$realPath' not inside '{$this->realDataDir}')", ILogger::ERROR); throw new ForbiddenException('Following symlinks is not allowed', false); } diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php index 488218e8e74..109de4c4e5c 100644 --- a/lib/private/Files/Storage/Wrapper/Encryption.php +++ b/lib/private/Files/Storage/Wrapper/Encryption.php @@ -441,7 +441,7 @@ class Encryption extends Wrapper { } catch (ModuleDoesNotExistsException $e) { $this->logger->logException($e, [ 'message' => 'Encryption module "' . $encryptionModuleId . '" not found, file will be stored unencrypted', - 'level' => \OCP\Util::WARN, + 'level' => ILogger::WARN, 'app' => 'core', ]); } diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index aaf14b4d7e0..a149cdf0af5 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -59,6 +59,7 @@ use OCP\Files\InvalidPathException; use OCP\Files\Mount\IMountPoint; use OCP\Files\NotFoundException; use OCP\Files\ReservedWordException; +use OCP\ILogger; use OCP\IUser; use OCP\Lock\ILockingProvider; use OCP\Lock\LockedException; @@ -975,7 +976,7 @@ class View { $hooks[] = 'write'; break; default: - \OCP\Util::writeLog('core', 'invalid mode (' . $mode . ') for ' . $path, \OCP\Util::ERROR); + \OCP\Util::writeLog('core', 'invalid mode (' . $mode . ') for ' . $path, ILogger::ERROR); } if ($mode !== 'r' && $mode !== 'w') { @@ -1463,7 +1464,7 @@ class View { // sometimes when the storage is not available it can be any exception \OC::$server->getLogger()->logException($e, [ 'message' => 'Exception while scanning storage "' . $subStorage->getId() . '"', - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'lib', ]); continue; @@ -1752,7 +1753,7 @@ class View { if (!$targetStorage->instanceOfStorage('\OCP\Files\IHomeStorage')) { \OCP\Util::writeLog('files', 'It is not allowed to move one mount point into another one', - \OCP\Util::DEBUG); + ILogger::DEBUG); return false; } @@ -1775,7 +1776,7 @@ class View { if (count($shares) > 0) { \OCP\Util::writeLog('files', 'It is not allowed to move one mount point into a shared folder', - \OCP\Util::DEBUG); + ILogger::DEBUG); return false; } diff --git a/lib/private/Installer.php b/lib/private/Installer.php index 391e98171cf..b6586eceabe 100644 --- a/lib/private/Installer.php +++ b/lib/private/Installer.php @@ -175,7 +175,7 @@ class Installer { $this->downloadApp($appId); } catch (\Exception $e) { $this->logger->logException($e, [ - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'core', ]); return false; @@ -460,7 +460,7 @@ class Installer { OC_Helper::rmdirr($appDir); return true; }else{ - \OCP\Util::writeLog('core', 'can\'t remove app '.$appId.'. It is not installed.', \OCP\Util::ERROR); + \OCP\Util::writeLog('core', 'can\'t remove app '.$appId.'. It is not installed.', ILogger::ERROR); return false; } diff --git a/lib/private/Log.php b/lib/private/Log.php index e1f9eb213be..ffe8c665c6f 100644 --- a/lib/private/Log.php +++ b/lib/private/Log.php @@ -107,7 +107,7 @@ class Log implements ILogger { * @return void */ public function emergency(string $message, array $context = []) { - $this->log(Util::FATAL, $message, $context); + $this->log(ILogger::FATAL, $message, $context); } /** @@ -121,7 +121,7 @@ class Log implements ILogger { * @return void */ public function alert(string $message, array $context = []) { - $this->log(Util::ERROR, $message, $context); + $this->log(ILogger::ERROR, $message, $context); } /** @@ -134,7 +134,7 @@ class Log implements ILogger { * @return void */ public function critical(string $message, array $context = []) { - $this->log(Util::ERROR, $message, $context); + $this->log(ILogger::ERROR, $message, $context); } /** @@ -146,7 +146,7 @@ class Log implements ILogger { * @return void */ public function error(string $message, array $context = []) { - $this->log(Util::ERROR, $message, $context); + $this->log(ILogger::ERROR, $message, $context); } /** @@ -160,7 +160,7 @@ class Log implements ILogger { * @return void */ public function warning(string $message, array $context = []) { - $this->log(Util::WARN, $message, $context); + $this->log(ILogger::WARN, $message, $context); } /** @@ -171,7 +171,7 @@ class Log implements ILogger { * @return void */ public function notice(string $message, array $context = []) { - $this->log(Util::INFO, $message, $context); + $this->log(ILogger::INFO, $message, $context); } /** @@ -184,7 +184,7 @@ class Log implements ILogger { * @return void */ public function info(string $message, array $context = []) { - $this->log(Util::INFO, $message, $context); + $this->log(ILogger::INFO, $message, $context); } /** @@ -195,7 +195,7 @@ class Log implements ILogger { * @return void */ public function debug(string $message, array $context = []) { - $this->log(Util::DEBUG, $message, $context); + $this->log(ILogger::DEBUG, $message, $context); } @@ -260,7 +260,7 @@ class Log implements ILogger { // if log condition is satisfied change the required log level to DEBUG if ($this->logConditionSatisfied) { - return Util::DEBUG; + return ILogger::DEBUG; } if (isset($context['app'])) { @@ -274,11 +274,11 @@ class Log implements ILogger { if (!empty($logCondition) && isset($logCondition['apps']) && in_array($app, $logCondition['apps'], true)) { - return Util::DEBUG; + return ILogger::DEBUG; } } - return min($this->config->getValue('loglevel', Util::WARN), Util::FATAL); + return min($this->config->getValue('loglevel', ILogger::WARN), ILogger::FATAL); } /** @@ -291,7 +291,7 @@ class Log implements ILogger { */ public function logException(\Throwable $exception, array $context = []) { $app = $context['app'] ?? 'no app in context'; - $level = $context['level'] ?? Util::ERROR; + $level = $context['level'] ?? ILogger::ERROR; $serializer = new ExceptionSerializer(); $data = $serializer->serializeException($exception); diff --git a/lib/private/Log/File.php b/lib/private/Log/File.php index 2d7e4b6c14f..755c4729c7a 100644 --- a/lib/private/Log/File.php +++ b/lib/private/Log/File.php @@ -37,6 +37,8 @@ namespace OC\Log; +use OCP\ILogger; + /** * logging utilities * @@ -159,7 +161,7 @@ class File { */ public static function getEntries($limit=50, $offset=0) { self::init(); - $minLevel = \OC::$server->getSystemConfig()->getValue("loglevel", \OCP\Util::WARN); + $minLevel = \OC::$server->getSystemConfig()->getValue("loglevel", ILogger::WARN); $entries = array(); $handle = @fopen(self::$logFile, 'rb'); if ($handle) { diff --git a/lib/private/Log/Rotate.php b/lib/private/Log/Rotate.php index 97a772b5251..48b96c98a8d 100644 --- a/lib/private/Log/Rotate.php +++ b/lib/private/Log/Rotate.php @@ -24,6 +24,7 @@ */ namespace OC\Log; +use OCP\ILogger; /** * This rotates the current logfile to a new name, this way the total log usage @@ -49,6 +50,6 @@ class Rotate extends \OC\BackgroundJob\Job { $rotatedLogfile = $logfile.'.1'; rename($logfile, $rotatedLogfile); $msg = 'Log file "'.$logfile.'" was over '.$this->max_log_size.' bytes, moved to "'.$rotatedLogfile.'"'; - \OCP\Util::writeLog(Rotate::class, $msg, \OCP\Util::WARN); + \OCP\Util::writeLog(Rotate::class, $msg, ILogger::WARN); } } diff --git a/lib/private/Log/Syslog.php b/lib/private/Log/Syslog.php index c6ea0a40350..7b3d931ef31 100644 --- a/lib/private/Log/Syslog.php +++ b/lib/private/Log/Syslog.php @@ -25,13 +25,15 @@ namespace OC\Log; +use OCP\ILogger; + class Syslog { static protected $levels = array( - \OCP\Util::DEBUG => LOG_DEBUG, - \OCP\Util::INFO => LOG_INFO, - \OCP\Util::WARN => LOG_WARNING, - \OCP\Util::ERROR => LOG_ERR, - \OCP\Util::FATAL => LOG_CRIT, + ILogger::DEBUG => LOG_DEBUG, + ILogger::INFO => LOG_INFO, + ILogger::WARN => LOG_WARNING, + ILogger::ERROR => LOG_ERR, + ILogger::FATAL => LOG_CRIT, ); /** diff --git a/lib/private/NaturalSort.php b/lib/private/NaturalSort.php index 636e5cd0219..470e720c54c 100644 --- a/lib/private/NaturalSort.php +++ b/lib/private/NaturalSort.php @@ -27,6 +27,8 @@ namespace OC; +use OCP\ILogger; + class NaturalSort { private static $instance; private $collator; @@ -41,7 +43,7 @@ class NaturalSort { // or inject an instance of \OC\NaturalSort_DefaultCollator to force using Owncloud's default collator if (isset($injectedCollator)) { $this->collator = $injectedCollator; - \OCP\Util::writeLog('core', 'forced use of '.get_class($injectedCollator), \OCP\Util::DEBUG); + \OCP\Util::writeLog('core', 'forced use of '.get_class($injectedCollator), ILogger::DEBUG); } } diff --git a/lib/private/Preview/Bitmap.php b/lib/private/Preview/Bitmap.php index ff6093fcf81..89b56bfc9e8 100644 --- a/lib/private/Preview/Bitmap.php +++ b/lib/private/Preview/Bitmap.php @@ -26,6 +26,7 @@ namespace OC\Preview; use Imagick; +use OCP\ILogger; /** * Creates a PNG preview using ImageMagick via the PECL extension @@ -50,7 +51,7 @@ abstract class Bitmap extends Provider { } catch (\Exception $e) { \OC::$server->getLogger()->logException($e, [ 'message' => 'Imagick says:', - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'core', ]); return false; diff --git a/lib/private/Preview/Office.php b/lib/private/Preview/Office.php index 6403cf5dd8d..955ab249df2 100644 --- a/lib/private/Preview/Office.php +++ b/lib/private/Preview/Office.php @@ -25,6 +25,8 @@ */ namespace OC\Preview; +use OCP\ILogger; + abstract class Office extends Provider { private $cmd; @@ -60,7 +62,7 @@ abstract class Office extends Provider { unlink($absPath); unlink($pdfPreview); \OC::$server->getLogger()->logException($e, [ - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'core', ]); return false; diff --git a/lib/private/Preview/SVG.php b/lib/private/Preview/SVG.php index e0abf04d931..e283175c2e2 100644 --- a/lib/private/Preview/SVG.php +++ b/lib/private/Preview/SVG.php @@ -24,6 +24,8 @@ */ namespace OC\Preview; +use OCP\ILogger; + class SVG extends Provider { /** * {@inheritDoc} @@ -54,7 +56,7 @@ class SVG extends Provider { $svg->setImageFormat('png32'); } catch (\Exception $e) { \OC::$server->getLogger()->logException($e, [ - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'core', ]); return false; diff --git a/lib/private/Settings/Manager.php b/lib/private/Settings/Manager.php index 7111511eca2..49f699223f6 100644 --- a/lib/private/Settings/Manager.php +++ b/lib/private/Settings/Manager.php @@ -150,12 +150,12 @@ class Manager implements IManager { /** @var ISection $section */ $section = \OC::$server->query($class); } catch (QueryException $e) { - $this->log->logException($e, ['level' => Util::INFO]); + $this->log->logException($e, ['level' => ILogger::INFO]); continue; } if (!$section instanceof ISection) { - $this->log->logException(new \InvalidArgumentException('Invalid settings section registered'), ['level' => Util::INFO]); + $this->log->logException(new \InvalidArgumentException('Invalid settings section registered'), ['level' => ILogger::INFO]); continue; } @@ -200,12 +200,12 @@ class Manager implements IManager { /** @var ISettings $setting */ $setting = \OC::$server->query($class); } catch (QueryException $e) { - $this->log->logException($e, ['level' => Util::INFO]); + $this->log->logException($e, ['level' => ILogger::INFO]); continue; } if (!$setting instanceof ISettings) { - $this->log->logException(new \InvalidArgumentException('Invalid settings setting registered'), ['level' => Util::INFO]); + $this->log->logException(new \InvalidArgumentException('Invalid settings setting registered'), ['level' => ILogger::INFO]); continue; } diff --git a/lib/private/Setup/MySQL.php b/lib/private/Setup/MySQL.php index d3b39007aa9..dd215f96cbe 100644 --- a/lib/private/Setup/MySQL.php +++ b/lib/private/Setup/MySQL.php @@ -31,6 +31,7 @@ namespace OC\Setup; use OC\DB\MySqlTools; use OCP\IDBConnection; +use OCP\ILogger; class MySQL extends AbstractDatabase { public $dbprettyname = 'MySQL/MariaDB'; @@ -70,7 +71,7 @@ class MySQL extends AbstractDatabase { } catch (\Exception $ex) { $this->logger->logException($ex, [ 'message' => 'Database creation failed.', - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'mysql.setup', ]); return; @@ -83,7 +84,7 @@ class MySQL extends AbstractDatabase { } catch (\Exception $ex) { $this->logger->logException($ex, [ 'message' => 'Could not automatically grant privileges, this can be ignored if database user already had privileges.', - 'level' => \OCP\Util::DEBUG, + 'level' => ILogger::DEBUG, 'app' => 'mysql.setup', ]); } @@ -107,7 +108,7 @@ class MySQL extends AbstractDatabase { catch (\Exception $ex){ $this->logger->logException($ex, [ 'message' => 'Database user creation failed.', - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'mysql.setup', ]); } @@ -162,7 +163,7 @@ class MySQL extends AbstractDatabase { } catch (\Exception $ex) { $this->logger->logException($ex, [ 'message' => 'Can not create a new MySQL user, will continue with the provided user.', - 'level' => \OCP\Util::INFO, + 'level' => ILogger::INFO, 'app' => 'mysql.setup', ]); } diff --git a/lib/private/Share/Share.php b/lib/private/Share/Share.php index 9c82fcc268b..ea00cfaca26 100644 --- a/lib/private/Share/Share.php +++ b/lib/private/Share/Share.php @@ -41,6 +41,7 @@ namespace OC\Share; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IConfig; +use OCP\ILogger; use OCP\Util; /** @@ -92,7 +93,7 @@ class Share extends Constants { \OCP\Util::writeLog('OCP\Share', 'Sharing backend '.$class.' not registered, '.self::$backendTypes[$itemType]['class'] .' is already registered for '.$itemType, - \OCP\Util::WARN); + ILogger::WARN); } return false; } @@ -264,7 +265,7 @@ class Share extends Constants { $query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share` WHERE `token` = ?', 1); $result = $query->execute(array($token)); if ($result === false) { - \OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage() . ', token=' . $token, \OCP\Util::ERROR); + \OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage() . ', token=' . $token, ILogger::ERROR); } $row = $result->fetchRow(); if ($row === false) { @@ -335,7 +336,7 @@ class Share extends Constants { if ($backend->isShareTypeAllowed($shareType) === false) { $message = 'Sharing %s failed, because the backend does not allow shares from type %i'; $message_t = $l->t('Sharing %s failed, because the backend does not allow shares from type %i', array($itemSourceName, $shareType)); - \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareType), \OCP\Util::DEBUG); + \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareType), ILogger::DEBUG); throw new \Exception($message_t); } @@ -356,14 +357,14 @@ class Share extends Constants { if (!$path) { $message = 'Sharing %s failed, because the file does not exist'; $message_t = $l->t('Sharing %s failed, because the file does not exist', array($itemSourceName)); - \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::DEBUG); + \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), ILogger::DEBUG); throw new \Exception($message_t); } // verify that the user has share permission if (!\OC\Files\Filesystem::isSharable($path) || \OCP\Util::isSharingDisabledForUser()) { $message = 'You are not allowed to share %s'; $message_t = $l->t('You are not allowed to share %s', [$path]); - \OCP\Util::writeLog('OCP\Share', sprintf($message, $path), \OCP\Util::DEBUG); + \OCP\Util::writeLog('OCP\Share', sprintf($message, $path), ILogger::DEBUG); throw new \Exception($message_t); } } @@ -376,7 +377,7 @@ class Share extends Constants { foreach ($mounts as $mount) { if ($mount->getStorage()->instanceOfStorage('\OCA\Files_Sharing\ISharedStorage')) { $message = 'Sharing "' . $itemSourceName . '" failed, because it contains files shared with you!'; - \OCP\Util::writeLog('OCP\Share', $message, \OCP\Util::DEBUG); + \OCP\Util::writeLog('OCP\Share', $message, ILogger::DEBUG); throw new \Exception($message); } @@ -408,13 +409,13 @@ class Share extends Constants { if ($shareWith == $uidOwner) { $message = 'Sharing %s failed, because you can not share with yourself'; $message_t = $l->t('Sharing %s failed, because you can not share with yourself', [$itemName]); - \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::DEBUG); + \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), ILogger::DEBUG); throw new \Exception($message_t); } if (!\OC::$server->getUserManager()->userExists($shareWith)) { $message = 'Sharing %s failed, because the user %s does not exist'; $message_t = $l->t('Sharing %s failed, because the user %s does not exist', array($itemSourceName, $shareWith)); - \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG); + \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), ILogger::DEBUG); throw new \Exception($message_t); } if ($shareWithinGroupOnly) { @@ -435,7 +436,7 @@ class Share extends Constants { $message = 'Sharing %s failed, because the user ' .'%s is not a member of any groups that %s is a member of'; $message_t = $l->t('Sharing %s failed, because the user %s is not a member of any groups that %s is a member of', array($itemName, $shareWith, $uidOwner)); - \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemName, $shareWith, $uidOwner), \OCP\Util::DEBUG); + \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemName, $shareWith, $uidOwner), ILogger::DEBUG); throw new \Exception($message_t); } } @@ -448,7 +449,7 @@ class Share extends Constants { if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) { $message = 'Sharing %s failed, because this item is already shared with %s'; $message_t = $l->t('Sharing %s failed, because this item is already shared with %s', array($itemSourceName, $shareWith)); - \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG); + \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), ILogger::DEBUG); throw new \Exception($message_t); } } @@ -460,7 +461,7 @@ class Share extends Constants { if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) { $message = 'Sharing %s failed, because this item is already shared with user %s'; $message_t = $l->t('Sharing %s failed, because this item is already shared with user %s', array($itemSourceName, $shareWith)); - \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::ERROR); + \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), ILogger::ERROR); throw new \Exception($message_t); } } @@ -468,7 +469,7 @@ class Share extends Constants { if (!\OC::$server->getGroupManager()->groupExists($shareWith)) { $message = 'Sharing %s failed, because the group %s does not exist'; $message_t = $l->t('Sharing %s failed, because the group %s does not exist', array($itemSourceName, $shareWith)); - \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG); + \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), ILogger::DEBUG); throw new \Exception($message_t); } if ($shareWithinGroupOnly) { @@ -478,7 +479,7 @@ class Share extends Constants { $message = 'Sharing %s failed, because ' . '%s is not a member of the group %s'; $message_t = $l->t('Sharing %s failed, because %s is not a member of the group %s', array($itemSourceName, $uidOwner, $shareWith)); - \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $uidOwner, $shareWith), \OCP\Util::DEBUG); + \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $uidOwner, $shareWith), ILogger::DEBUG); throw new \Exception($message_t); } } @@ -490,7 +491,7 @@ class Share extends Constants { if ($checkExists['share_with'] === $shareWith && $checkExists['share_type'] === \OCP\Share::SHARE_TYPE_GROUP) { $message = 'Sharing %s failed, because this item is already shared with %s'; $message_t = $l->t('Sharing %s failed, because this item is already shared with %s', array($itemSourceName, $shareWith)); - \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG); + \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), ILogger::DEBUG); throw new \Exception($message_t); } } @@ -557,7 +558,7 @@ class Share extends Constants { if (\OCP\Util::isPublicLinkPasswordRequired() && empty($shareWith)) { $message = 'You need to provide a password to create a public link, only protected links are allowed'; $message_t = $l->t('You need to provide a password to create a public link, only protected links are allowed'); - \OCP\Util::writeLog('OCP\Share', $message, \OCP\Util::DEBUG); + \OCP\Util::writeLog('OCP\Share', $message, ILogger::DEBUG); throw new \Exception($message_t); } @@ -585,7 +586,7 @@ class Share extends Constants { } $message = 'Sharing %s failed, because sharing with links is not allowed'; $message_t = $l->t('Sharing %s failed, because sharing with links is not allowed', array($itemSourceName)); - \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::DEBUG); + \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), ILogger::DEBUG); throw new \Exception($message_t); } else if ($shareType === self::SHARE_TYPE_REMOTE) { @@ -596,7 +597,7 @@ class Share extends Constants { $shareWith, $uidOwner, self::FORMAT_NONE, null, 1, true, true)) { $message = 'Sharing %s failed, because this item is already shared with %s'; $message_t = $l->t('Sharing %s failed, because this item is already shared with %s', array($itemSourceName, $shareWith)); - \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG); + \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), ILogger::DEBUG); throw new \Exception($message_t); } @@ -607,7 +608,7 @@ class Share extends Constants { if (Helper::isSameUserOnSameServer($user, $remote, $currentUser, $currentServer)) { $message = 'Not allowed to create a federated share with the same user.'; $message_t = $l->t('Not allowed to create a federated share with the same user'); - \OCP\Util::writeLog('OCP\Share', $message, \OCP\Util::DEBUG); + \OCP\Util::writeLog('OCP\Share', $message, ILogger::DEBUG); throw new \Exception($message_t); } @@ -634,7 +635,7 @@ class Share extends Constants { // Future share types need to include their own conditions $message = 'Share type %s is not valid for %s'; $message_t = $l->t('Share type %s is not valid for %s', array($shareType, $itemSource)); - \OCP\Util::writeLog('OCP\Share', sprintf($message, $shareType, $itemSource), \OCP\Util::DEBUG); + \OCP\Util::writeLog('OCP\Share', sprintf($message, $shareType, $itemSource), ILogger::DEBUG); throw new \Exception($message_t); } @@ -703,7 +704,7 @@ class Share extends Constants { $result = $query->execute(array($status, $itemType, $itemSource, $shareType, $recipient)); if($result === false) { - \OCP\Util::writeLog('OCP\Share', 'Couldn\'t set send mail status', \OCP\Util::ERROR); + \OCP\Util::writeLog('OCP\Share', 'Couldn\'t set send mail status', ILogger::ERROR); } } @@ -740,7 +741,7 @@ class Share extends Constants { if ($date > $maxDate) { $warning = 'Cannot set expiration date. Shares cannot expire later than ' . $maxDays . ' after they have been shared'; $warning_t = $l->t('Cannot set expiration date. Shares cannot expire later than %s after they have been shared', array($maxDays)); - \OCP\Util::writeLog('OCP\Share', $warning, \OCP\Util::WARN); + \OCP\Util::writeLog('OCP\Share', $warning, ILogger::WARN); throw new \Exception($warning_t); } } @@ -748,7 +749,7 @@ class Share extends Constants { if ($date < $today) { $message = 'Cannot set expiration date. Expiration date is in the past'; $message_t = $l->t('Cannot set expiration date. Expiration date is in the past'); - \OCP\Util::writeLog('OCP\Share', $message, \OCP\Util::WARN); + \OCP\Util::writeLog('OCP\Share', $message, ILogger::WARN); throw new \Exception($message_t); } @@ -849,20 +850,20 @@ class Share extends Constants { if (!(self::$backends[$itemType] instanceof \OCP\Share_Backend)) { $message = 'Sharing backend %s must implement the interface OCP\Share_Backend'; $message_t = $l->t('Sharing backend %s must implement the interface OCP\Share_Backend', array($class)); - \OCP\Util::writeLog('OCP\Share', sprintf($message, $class), \OCP\Util::ERROR); + \OCP\Util::writeLog('OCP\Share', sprintf($message, $class), ILogger::ERROR); throw new \Exception($message_t); } return self::$backends[$itemType]; } else { $message = 'Sharing backend %s not found'; $message_t = $l->t('Sharing backend %s not found', array($class)); - \OCP\Util::writeLog('OCP\Share', sprintf($message, $class), \OCP\Util::ERROR); + \OCP\Util::writeLog('OCP\Share', sprintf($message, $class), ILogger::ERROR); throw new \Exception($message_t); } } $message = 'Sharing backend for %s not found'; $message_t = $l->t('Sharing backend for %s not found', array($itemType)); - \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemType), \OCP\Util::ERROR); + \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemType), ILogger::ERROR); throw new \Exception($message_t); } @@ -1133,7 +1134,7 @@ class Share extends Constants { if ($result === false) { \OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage() . ', select=' . $select . ' where=', - \OCP\Util::ERROR); + ILogger::ERROR); } $items = array(); $targets = array(); @@ -1197,7 +1198,7 @@ class Share extends Constants { if ($result === false) { \OCP\Util::writeLog('OCP\Share', 'Can\'t select parent: ' . \OC_DB::getErrorMessage() . ', select=' . $select . ' where=' . $where, - \OCP\Util::ERROR); + ILogger::ERROR); } else { $parentRow = $parentResult->fetchRow(); $tmpPath = $parentRow['file_target']; @@ -1668,7 +1669,7 @@ class Share extends Constants { $message = 'Sharing %s failed, because the user %s is the original sharer'; $message_t = $l->t('Sharing failed, because the user %s is the original sharer', [$shareWith]); - \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG); + \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), ILogger::DEBUG); throw new \Exception($message_t); } } @@ -1680,7 +1681,7 @@ class Share extends Constants { $message = 'Sharing %s failed, because the permissions exceed permissions granted to %s'; $message_t = $l->t('Sharing %s failed, because the permissions exceed permissions granted to %s', array($itemSourceName, $uidOwner)); - \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $uidOwner), \OCP\Util::DEBUG); + \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $uidOwner), ILogger::DEBUG); throw new \Exception($message_t); } else { // TODO Don't check if inside folder @@ -1712,7 +1713,7 @@ class Share extends Constants { $message = 'Sharing %s failed, because resharing is not allowed'; $message_t = $l->t('Sharing %s failed, because resharing is not allowed', array($itemSourceName)); - \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::DEBUG); + \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), ILogger::DEBUG); throw new \Exception($message_t); } } else { @@ -1725,7 +1726,7 @@ class Share extends Constants { $message = 'Sharing %s failed, because the sharing backend for ' .'%s could not find its source'; $message_t = $l->t('Sharing %s failed, because the sharing backend for %s could not find its source', array($itemSource, $itemType)); - \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSource, $itemType), \OCP\Util::DEBUG); + \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSource, $itemType), ILogger::DEBUG); throw new \Exception($message_t); } if ($backend instanceof \OCP\Share_Backend_File_Dependent) { @@ -1740,7 +1741,7 @@ class Share extends Constants { $message = 'Sharing %s failed, because the file could not be found in the file cache'; $message_t = $l->t('Sharing %s failed, because the file could not be found in the file cache', array($itemSource)); - \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSource), \OCP\Util::DEBUG); + \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSource), ILogger::DEBUG); throw new \Exception($message_t); } } else { diff --git a/lib/private/Tags.php b/lib/private/Tags.php index c78297e5290..10c9affa277 100644 --- a/lib/private/Tags.php +++ b/lib/private/Tags.php @@ -47,6 +47,7 @@ namespace OC; use OC\Tagging\Tag; use OC\Tagging\TagMapper; use OCP\DB\QueryBuilder\IQueryBuilder; +use OCP\ILogger; class Tags implements \OCP\ITags { @@ -237,14 +238,14 @@ class Tags implements \OCP\ITags { $entries[$objId][] = $row['category']; } if ($result === null) { - \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), \OCP\Util::ERROR); + \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); return false; } } } catch(\Exception $e) { \OC::$server->getLogger()->logException($e, [ 'message' => __METHOD__, - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'core', ]); return false; @@ -270,7 +271,7 @@ class Tags implements \OCP\ITags { } elseif(is_string($tag)) { $tag = trim($tag); if($tag === '') { - \OCP\Util::writeLog('core', __METHOD__.', Cannot use empty tag names', \OCP\Util::DEBUG); + \OCP\Util::writeLog('core', __METHOD__.', Cannot use empty tag names', ILogger::DEBUG); return false; } $tagId = $this->getTagId($tag); @@ -291,13 +292,13 @@ class Tags implements \OCP\ITags { $stmt = \OC_DB::prepare($sql); $result = $stmt->execute(array($tagId)); if ($result === null) { - \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), \OCP\Util::ERROR); + \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); return false; } } catch(\Exception $e) { \OC::$server->getLogger()->logException($e, [ 'message' => __METHOD__, - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'core', ]); return false; @@ -360,11 +361,11 @@ class Tags implements \OCP\ITags { $name = trim($name); if($name === '') { - \OCP\Util::writeLog('core', __METHOD__.', Cannot add an empty tag', \OCP\Util::DEBUG); + \OCP\Util::writeLog('core', __METHOD__.', Cannot add an empty tag', ILogger::DEBUG); return false; } if($this->userHasTag($name, $this->user)) { - \OCP\Util::writeLog('core', __METHOD__.', name: ' . $name. ' exists already', \OCP\Util::DEBUG); + \OCP\Util::writeLog('core', __METHOD__.', name: ' . $name. ' exists already', ILogger::DEBUG); return false; } try { @@ -374,12 +375,12 @@ class Tags implements \OCP\ITags { } catch(\Exception $e) { \OC::$server->getLogger()->logException($e, [ 'message' => __METHOD__, - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'core', ]); return false; } - \OCP\Util::writeLog('core', __METHOD__.', id: ' . $tag->getId(), \OCP\Util::DEBUG); + \OCP\Util::writeLog('core', __METHOD__.', id: ' . $tag->getId(), ILogger::DEBUG); return $tag->getId(); } @@ -395,7 +396,7 @@ class Tags implements \OCP\ITags { $to = trim($to); if($to === '' || $from === '') { - \OCP\Util::writeLog('core', __METHOD__.', Cannot use empty tag names', \OCP\Util::DEBUG); + \OCP\Util::writeLog('core', __METHOD__.', Cannot use empty tag names', ILogger::DEBUG); return false; } @@ -405,13 +406,13 @@ class Tags implements \OCP\ITags { $key = $this->getTagByName($from); } if($key === false) { - \OCP\Util::writeLog('core', __METHOD__.', tag: ' . $from. ' does not exist', \OCP\Util::DEBUG); + \OCP\Util::writeLog('core', __METHOD__.', tag: ' . $from. ' does not exist', ILogger::DEBUG); return false; } $tag = $this->tags[$key]; if($this->userHasTag($to, $tag->getOwner())) { - \OCP\Util::writeLog('core', __METHOD__.', A tag named ' . $to. ' already exists for user ' . $tag->getOwner() . '.', \OCP\Util::DEBUG); + \OCP\Util::writeLog('core', __METHOD__.', A tag named ' . $to. ' already exists for user ' . $tag->getOwner() . '.', ILogger::DEBUG); return false; } @@ -421,7 +422,7 @@ class Tags implements \OCP\ITags { } catch(\Exception $e) { \OC::$server->getLogger()->logException($e, [ 'message' => __METHOD__, - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'core', ]); return false; @@ -476,7 +477,7 @@ class Tags implements \OCP\ITags { } catch(\Exception $e) { \OC::$server->getLogger()->logException($e, [ 'message' => __METHOD__, - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'core', ]); } @@ -485,7 +486,7 @@ class Tags implements \OCP\ITags { // reload tags to get the proper ids. $this->tags = $this->mapper->loadTags($this->owners, $this->type); \OCP\Util::writeLog('core', __METHOD__.', tags: ' . print_r($this->tags, true), - \OCP\Util::DEBUG); + ILogger::DEBUG); // Loop through temporarily cached objectid/tagname pairs // and save relations. $tags = $this->tags; @@ -494,7 +495,7 @@ class Tags implements \OCP\ITags { $dbConnection = \OC::$server->getDatabaseConnection(); foreach(self::$relations as $relation) { $tagId = $this->getTagId($relation['tag']); - \OCP\Util::writeLog('core', __METHOD__ . 'catid, ' . $relation['tag'] . ' ' . $tagId, \OCP\Util::DEBUG); + \OCP\Util::writeLog('core', __METHOD__ . 'catid, ' . $relation['tag'] . ' ' . $tagId, ILogger::DEBUG); if($tagId) { try { $dbConnection->insertIfNotExist(self::RELATION_TABLE, @@ -506,7 +507,7 @@ class Tags implements \OCP\ITags { } catch(\Exception $e) { \OC::$server->getLogger()->logException($e, [ 'message' => __METHOD__, - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'core', ]); } @@ -515,7 +516,7 @@ class Tags implements \OCP\ITags { self::$relations = array(); // reset } else { \OCP\Util::writeLog('core', __METHOD__.', $this->tags is not an array! ' - . print_r($this->tags, true), \OCP\Util::ERROR); + . print_r($this->tags, true), ILogger::ERROR); } } @@ -534,12 +535,12 @@ class Tags implements \OCP\ITags { . 'WHERE `uid` = ?'); $result = $stmt->execute(array($arguments['uid'])); if ($result === null) { - \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), \OCP\Util::ERROR); + \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); } } catch(\Exception $e) { \OC::$server->getLogger()->logException($e, [ 'message' => __METHOD__, - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'core', ]); } @@ -554,7 +555,7 @@ class Tags implements \OCP\ITags { } catch(\Exception $e) { \OC::$server->getLogger()->logException($e, [ 'message' => __METHOD__, - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'core', ]); } @@ -562,7 +563,7 @@ class Tags implements \OCP\ITags { } catch(\Exception $e) { \OC::$server->getLogger()->logException($e, [ 'message' => __METHOD__, - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'core', ]); } @@ -572,12 +573,12 @@ class Tags implements \OCP\ITags { . 'WHERE `uid` = ?'); $result = $stmt->execute(array($arguments['uid'])); if ($result === null) { - \OCP\Util::writeLog('core', __METHOD__. ', DB error: ' . \OC::$server->getDatabaseConnection()->getError(), \OCP\Util::ERROR); + \OCP\Util::writeLog('core', __METHOD__. ', DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); } } catch(\Exception $e) { \OC::$server->getLogger()->logException($e, [ 'message' => __METHOD__, - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'core', ]); } @@ -603,13 +604,13 @@ class Tags implements \OCP\ITags { $stmt = \OC_DB::prepare($query); $result = $stmt->execute($updates); if ($result === null) { - \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), \OCP\Util::ERROR); + \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); return false; } } catch(\Exception $e) { \OC::$server->getLogger()->logException($e, [ 'message' => __METHOD__, - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'core', ]); return false; @@ -628,7 +629,7 @@ class Tags implements \OCP\ITags { } catch(\Exception $e) { \OC::$server->getLogger()->logException($e, [ 'message' => __METHOD__, - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'core', ]); return array(); @@ -669,7 +670,7 @@ class Tags implements \OCP\ITags { if(is_string($tag) && !is_numeric($tag)) { $tag = trim($tag); if($tag === '') { - \OCP\Util::writeLog('core', __METHOD__.', Cannot add an empty tag', \OCP\Util::DEBUG); + \OCP\Util::writeLog('core', __METHOD__.', Cannot add an empty tag', ILogger::DEBUG); return false; } if(!$this->hasTag($tag)) { @@ -689,7 +690,7 @@ class Tags implements \OCP\ITags { } catch(\Exception $e) { \OC::$server->getLogger()->logException($e, [ 'message' => __METHOD__, - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'core', ]); return false; @@ -708,7 +709,7 @@ class Tags implements \OCP\ITags { if(is_string($tag) && !is_numeric($tag)) { $tag = trim($tag); if($tag === '') { - \OCP\Util::writeLog('core', __METHOD__.', Tag name is empty', \OCP\Util::DEBUG); + \OCP\Util::writeLog('core', __METHOD__.', Tag name is empty', ILogger::DEBUG); return false; } $tagId = $this->getTagId($tag); @@ -724,7 +725,7 @@ class Tags implements \OCP\ITags { } catch(\Exception $e) { \OC::$server->getLogger()->logException($e, [ 'message' => __METHOD__, - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'core', ]); return false; @@ -747,7 +748,7 @@ class Tags implements \OCP\ITags { array_filter($names); \OCP\Util::writeLog('core', __METHOD__ . ', before: ' - . print_r($this->tags, true), \OCP\Util::DEBUG); + . print_r($this->tags, true), ILogger::DEBUG); foreach($names as $name) { $id = null; @@ -763,7 +764,7 @@ class Tags implements \OCP\ITags { $this->mapper->delete($tag); } else { \OCP\Util::writeLog('core', __METHOD__ . 'Cannot delete tag ' . $name - . ': not found.', \OCP\Util::ERROR); + . ': not found.', ILogger::ERROR); } if(!is_null($id) && $id !== false) { try { @@ -774,13 +775,13 @@ class Tags implements \OCP\ITags { if ($result === null) { \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), - \OCP\Util::ERROR); + ILogger::ERROR); return false; } } catch(\Exception $e) { \OC::$server->getLogger()->logException($e, [ 'message' => __METHOD__, - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'core', ]); return false; diff --git a/lib/private/Updater.php b/lib/private/Updater.php index 49a4a1094ed..e6e38798142 100644 --- a/lib/private/Updater.php +++ b/lib/private/Updater.php @@ -100,9 +100,9 @@ class Updater extends BasicEmitter { $this->emitRepairEvents(); $this->logAllEvents(); - $logLevel = $this->config->getSystemValue('loglevel', Util::WARN); + $logLevel = $this->config->getSystemValue('loglevel', ILogger::WARN); $this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]); - $this->config->setSystemValue('loglevel', Util::DEBUG); + $this->config->setSystemValue('loglevel', ILogger::DEBUG); $wasMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); diff --git a/lib/private/User/Database.php b/lib/private/User/Database.php index 001e0c0f4a5..b2c54cd7c7e 100644 --- a/lib/private/User/Database.php +++ b/lib/private/User/Database.php @@ -59,6 +59,7 @@ namespace OC\User; use OC\Cache\CappedMemoryCache; use OCP\IDBConnection; +use OCP\ILogger; use OCP\User\Backend\ABackend; use OCP\User\Backend\ICheckPasswordBackend; use OCP\User\Backend\ICountUsersBackend; @@ -408,7 +409,7 @@ class Database extends ABackend $query = \OC_DB::prepare('SELECT COUNT(*) FROM `*PREFIX*users`'); $result = $query->execute(); if ($result === false) { - Util::writeLog('core', \OC_DB::getErrorMessage(), Util::ERROR); + Util::writeLog('core', \OC_DB::getErrorMessage(), ILogger::ERROR); return false; } return $result->fetchOne(); diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php index 88d5ce1f135..7931eecc502 100644 --- a/lib/private/legacy/app.php +++ b/lib/private/legacy/app.php @@ -56,6 +56,7 @@ use OC\DB\MigrationService; use OC\Installer; use OC\Repair; use OCP\App\ManagerEvent; +use OCP\ILogger; /** * This class manages the apps. It allows them to register and integrate in the @@ -425,7 +426,7 @@ class OC_App { } } - \OCP\Util::writeLog('core', 'No application directories are marked as writable.', \OCP\Util::ERROR); + \OCP\Util::writeLog('core', 'No application directories are marked as writable.', ILogger::ERROR); return null; } @@ -666,7 +667,7 @@ class OC_App { foreach (OC::$APPSROOTS as $apps_dir) { if (!is_readable($apps_dir['path'])) { - \OCP\Util::writeLog('core', 'unable to read app folder : ' . $apps_dir['path'], \OCP\Util::WARN); + \OCP\Util::writeLog('core', 'unable to read app folder : ' . $apps_dir['path'], ILogger::WARN); continue; } $dh = opendir($apps_dir['path']); @@ -707,12 +708,12 @@ class OC_App { $info = OC_App::getAppInfo($app, false, $langCode); if (!is_array($info)) { - \OCP\Util::writeLog('core', 'Could not read app info file for app "' . $app . '"', \OCP\Util::ERROR); + \OCP\Util::writeLog('core', 'Could not read app info file for app "' . $app . '"', ILogger::ERROR); continue; } if (!isset($info['name'])) { - \OCP\Util::writeLog('core', 'App id "' . $app . '" has no name in appinfo', \OCP\Util::ERROR); + \OCP\Util::writeLog('core', 'App id "' . $app . '" has no name in appinfo', ILogger::ERROR); continue; } @@ -994,11 +995,11 @@ class OC_App { } return new \OC\Files\View('/' . OC_User::getUser() . '/' . $appId); } else { - \OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ', user not logged in', \OCP\Util::ERROR); + \OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ', user not logged in', ILogger::ERROR); return false; } } else { - \OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ' not enabled', \OCP\Util::ERROR); + \OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ' not enabled', ILogger::ERROR); return false; } } diff --git a/lib/private/legacy/db.php b/lib/private/legacy/db.php index 7c556baeaeb..7e18cbe1875 100644 --- a/lib/private/legacy/db.php +++ b/lib/private/legacy/db.php @@ -28,6 +28,8 @@ * */ +use OCP\ILogger; + /** * This class manages the access to the database. It basically is a wrapper for * Doctrine with some adaptions. @@ -185,7 +187,7 @@ class OC_DB { try { $result = $schemaManager->updateDbFromStructure($file); } catch (Exception $e) { - \OCP\Util::writeLog('core', 'Failed to update database structure ('.$e.')', \OCP\Util::FATAL); + \OCP\Util::writeLog('core', 'Failed to update database structure ('.$e.')', ILogger::FATAL); throw $e; } return $result; diff --git a/lib/private/legacy/files.php b/lib/private/legacy/files.php index 9281c1f7da4..00cd5fbfe51 100644 --- a/lib/private/legacy/files.php +++ b/lib/private/legacy/files.php @@ -41,6 +41,7 @@ use OC\Files\View; use OC\Streamer; +use OCP\ILogger; use OCP\Lock\ILockingProvider; /** @@ -422,7 +423,7 @@ class OC_Files { if (!$handle) { \OCP\Util::writeLog('files', 'Can\'t write upload limit to ' . $filename . '. Please check the file permissions', - \OCP\Util::WARN); + ILogger::WARN); $success = false; continue; // try to update as many files as possible } diff --git a/lib/private/legacy/user.php b/lib/private/legacy/user.php index 9c877f22a46..ebb1ff2215b 100644 --- a/lib/private/legacy/user.php +++ b/lib/private/legacy/user.php @@ -38,6 +38,8 @@ * */ +use OCP\ILogger; + /** * This class provides wrapper methods for user management. Multiple backends are * supported. User management operations are delegated to the configured backend for @@ -89,7 +91,7 @@ class OC_User { case 'database': case 'mysql': case 'sqlite': - \OCP\Util::writeLog('core', 'Adding user backend ' . $backend . '.', \OCP\Util::DEBUG); + \OCP\Util::writeLog('core', 'Adding user backend ' . $backend . '.', ILogger::DEBUG); self::$_usedBackends[$backend] = new \OC\User\Database(); \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); break; @@ -98,7 +100,7 @@ class OC_User { \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); break; default: - \OCP\Util::writeLog('core', 'Adding default user backend ' . $backend . '.', \OCP\Util::DEBUG); + \OCP\Util::writeLog('core', 'Adding default user backend ' . $backend . '.', ILogger::DEBUG); $className = 'OC_USER_' . strtoupper($backend); self::$_usedBackends[$backend] = new $className(); \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); @@ -143,10 +145,10 @@ class OC_User { self::useBackend($backend); self::$_setupedBackends[] = $i; } else { - \OCP\Util::writeLog('core', 'User backend ' . $class . ' already initialized.', \OCP\Util::DEBUG); + \OCP\Util::writeLog('core', 'User backend ' . $class . ' already initialized.', ILogger::DEBUG); } } else { - \OCP\Util::writeLog('core', 'User backend ' . $class . ' not found.', \OCP\Util::ERROR); + \OCP\Util::writeLog('core', 'User backend ' . $class . ' not found.', ILogger::ERROR); } } } diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php index 3313ccdec91..d3599d14e7a 100644 --- a/lib/private/legacy/util.php +++ b/lib/private/legacy/util.php @@ -62,6 +62,7 @@ use OCP\IConfig; use OCP\IGroupManager; +use OCP\ILogger; use OCP\IUser; class OC_Util { @@ -100,7 +101,7 @@ class OC_Util { private static function initObjectStoreRootFS($config) { // check misconfiguration if (empty($config['class'])) { - \OCP\Util::writeLog('files', 'No class given for objectstore', \OCP\Util::ERROR); + \OCP\Util::writeLog('files', 'No class given for objectstore', ILogger::ERROR); } if (!isset($config['arguments'])) { $config['arguments'] = array(); @@ -134,7 +135,7 @@ class OC_Util { private static function initObjectStoreMultibucketRootFS($config) { // check misconfiguration if (empty($config['class'])) { - \OCP\Util::writeLog('files', 'No class given for objectstore', \OCP\Util::ERROR); + \OCP\Util::writeLog('files', 'No class given for objectstore', ILogger::ERROR); } if (!isset($config['arguments'])) { $config['arguments'] = array(); @@ -409,7 +410,7 @@ class OC_Util { \OCP\Util::writeLog( 'files_skeleton', 'copying skeleton for '.$userId.' from '.$skeletonDirectory.' to '.$userDirectory->getFullPath('/'), - \OCP\Util::DEBUG + ILogger::DEBUG ); self::copyr($skeletonDirectory, $userDirectory); // update the file cache @@ -1378,7 +1379,7 @@ class OC_Util { // XCache if (function_exists('xcache_clear_cache')) { if (\OC::$server->getIniWrapper()->getBool('xcache.admin.enable_auth')) { - \OCP\Util::writeLog('core', 'XCache opcode cache will not be cleared because "xcache.admin.enable_auth" is enabled.', \OCP\Util::WARN); + \OCP\Util::writeLog('core', 'XCache opcode cache will not be cleared because "xcache.admin.enable_auth" is enabled.', ILogger::WARN); } else { @xcache_clear_cache(XC_TYPE_PHP, 0); } |