]> source.dussan.org Git - nextcloud-server.git/commitdiff
chore: Migrate away from OC::$server->getLogger 43461/head
authorCôme Chilliet <come.chilliet@nextcloud.com>
Thu, 8 Feb 2024 14:47:39 +0000 (15:47 +0100)
committerCôme Chilliet <91878298+come-nc@users.noreply.github.com>
Tue, 13 Feb 2024 16:32:30 +0000 (17:32 +0100)
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
22 files changed:
apps/files_sharing/lib/Controller/ShareAPIController.php
apps/files_sharing/lib/DeleteOrphanedSharesJob.php
apps/files_sharing/lib/ShareBackend/File.php
apps/files_sharing/lib/SharedMount.php
apps/user_ldap/lib/Configuration.php
apps/user_ldap/lib/GroupPluginManager.php
apps/user_ldap/lib/Mapping/AbstractMapping.php
apps/user_ldap/lib/UserPluginManager.php
apps/user_ldap/tests/Integration/AbstractIntegrationTest.php
lib/private/Cache/File.php
lib/private/Files/Filesystem.php
lib/private/Files/ObjectStore/ObjectStoreStorage.php
lib/private/L10N/L10N.php
lib/private/Log/Rotate.php
lib/private/Search.php
lib/private/Share20/DefaultShareProvider.php
lib/private/Tags.php
lib/private/User/Manager.php
lib/public/AppFramework/App.php
ocs/v1.php
public.php
status.php

index aa239ae8bb6b3d6af8983799da931bc39d23afae..26a868381e6bd7b04c5a511f6d2a279022db17fc 100644 (file)
@@ -850,11 +850,11 @@ class ShareAPIController extends OCSController {
                try {
                        $share = $this->shareManager->createShare($share);
                } catch (GenericShareException $e) {
-                       \OC::$server->getLogger()->logException($e);
+                       \OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
                        $code = $e->getCode() === 0 ? 403 : $e->getCode();
                        throw new OCSException($e->getHint(), $code);
                } catch (\Exception $e) {
-                       \OC::$server->getLogger()->logException($e);
+                       \OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
                        throw new OCSForbiddenException($e->getMessage(), $e);
                }
 
index d2cc39ff060a89d166e174b4d41e3cf3e99d1ebe..2d166da2010c084319b32fe59c844e212423209c 100644 (file)
@@ -26,6 +26,9 @@ namespace OCA\Files_Sharing;
 
 use OCP\AppFramework\Utility\ITimeFactory;
 use OCP\BackgroundJob\TimedJob;
+use OCP\IDBConnection;
+use OCP\Server;
+use Psr\Log\LoggerInterface;
 
 /**
  * Delete all share entries that have no matching entries in the file cache table.
@@ -33,10 +36,8 @@ use OCP\BackgroundJob\TimedJob;
 class DeleteOrphanedSharesJob extends TimedJob {
        /**
         * Default interval in minutes
-        *
-        * @var int $defaultIntervalMin
         **/
-       protected $defaultIntervalMin = 15;
+       protected int $defaultIntervalMin = 15;
 
        /**
         * sets the correct interval for this timed job
@@ -53,15 +54,15 @@ class DeleteOrphanedSharesJob extends TimedJob {
         * @param array $argument unused argument
         */
        public function run($argument) {
-               $connection = \OC::$server->getDatabaseConnection();
-               $logger = \OC::$server->getLogger();
+               $connection = Server::get(IDBConnection::class);
+               $logger = Server::get(LoggerInterface::class);
 
                $sql =
                        'DELETE FROM `*PREFIX*share` ' .
                        'WHERE `item_type` in (\'file\', \'folder\') ' .
                        'AND NOT EXISTS (SELECT `fileid` FROM `*PREFIX*filecache` WHERE `file_source` = `fileid`)';
 
-               $deletedEntries = $connection->executeUpdate($sql);
+               $deletedEntries = $connection->executeStatement($sql);
                $logger->debug("$deletedEntries orphaned share(s) deleted", ['app' => 'DeleteOrphanedSharesJob']);
        }
 }
index c84cbd66c67ceb36a89bd88580b3cf94f587147e..23096d6415669b3dd0e51c76601287a7df81c44b 100644 (file)
@@ -35,6 +35,7 @@ namespace OCA\Files_Sharing\ShareBackend;
 
 use OCA\FederatedFileSharing\FederatedShareProvider;
 use OCP\Share\IShare;
+use Psr\Log\LoggerInterface;
 
 class File implements \OCP\Share_Backend_File_Dependent {
        public const FORMAT_SHARED_STORAGE = 0;
@@ -233,7 +234,7 @@ class File implements \OCP\Share_Backend_File_Dependent {
                if (isset($fileOwner)) {
                        $source['fileOwner'] = $fileOwner;
                } else {
-                       \OC::$server->getLogger()->error('No owner found for reshare', ['app' => 'files_sharing']);
+                       \OCP\Server::get(LoggerInterface::class)->error('No owner found for reshare', ['app' => 'files_sharing']);
                }
 
                return $source;
index 7dc24936d6b1feaa5e22a935cc8a2b2c11aa199d..66a3b619df08a0052b142563e0d235d82dcb168e 100644 (file)
@@ -40,6 +40,7 @@ use OCP\Files\Storage\IStorageFactory;
 use OCP\ICache;
 use OCP\IUser;
 use OCP\Share\Events\VerifyMountPointEvent;
+use Psr\Log\LoggerInterface;
 
 /**
  * Shared mount points can be moved by the user
@@ -198,7 +199,7 @@ class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint
 
                // it is not a file relative to data/user/files
                if (count($split) < 3 || $split[1] !== 'files') {
-                       \OC::$server->getLogger()->error('Can not strip userid and "files/" from path: ' . $path, ['app' => 'files_sharing']);
+                       \OCP\Server::get(LoggerInterface::class)->error('Can not strip userid and "files/" from path: ' . $path, ['app' => 'files_sharing']);
                        throw new \OCA\Files_Sharing\Exceptions\BrokenPath('Path does not start with /user/files', 10);
                }
 
@@ -226,7 +227,13 @@ class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint
                        $this->setMountPoint($target);
                        $this->storage->setMountPoint($relTargetPath);
                } catch (\Exception $e) {
-                       \OC::$server->getLogger()->logException($e, ['app' => 'files_sharing', 'message' => 'Could not rename mount point for shared folder "' . $this->getMountPoint() . '" to "' . $target . '"']);
+                       \OCP\Server::get(LoggerInterface::class)->error(
+                               'Could not rename mount point for shared folder "' . $this->getMountPoint() . '" to "' . $target . '"',
+                               [
+                                       'app' => 'files_sharing',
+                                       'exception' => $e,
+                               ]
+                       );
                }
 
                return $result;
index b009ba3f4809eefc741df296dfbd99b7b2231914..2791324be5b2f2c89eed7cc93453bffc3f882697 100644 (file)
@@ -35,6 +35,8 @@
  */
 namespace OCA\User_LDAP;
 
+use Psr\Log\LoggerInterface;
+
 /**
  * @property int ldapPagingSize holds an integer
  * @property string ldapUserAvatarRule
@@ -598,7 +600,7 @@ class Configuration {
                        return [strtolower($attribute)];
                }
                if ($value !== self::AVATAR_PREFIX_DEFAULT) {
-                       \OC::$server->getLogger()->warning('Invalid config value to ldapUserAvatarRule; falling back to default.');
+                       \OCP\Server::get(LoggerInterface::class)->warning('Invalid config value to ldapUserAvatarRule; falling back to default.');
                }
                return $defaultAttributes;
        }
index d99e17d7673efa51ebbe4d244dc54c4ad4d1772c..92bf0cb88889a1e9b793f5ed17afd6fd166e7e43 100644 (file)
@@ -24,6 +24,7 @@
 namespace OCA\User_LDAP;
 
 use OCP\GroupInterface;
+use Psr\Log\LoggerInterface;
 
 class GroupPluginManager {
        private int $respondToActions = 0;
@@ -58,7 +59,7 @@ class GroupPluginManager {
                foreach ($this->which as $action => $v) {
                        if ((bool)($respondToActions & $action)) {
                                $this->which[$action] = $plugin;
-                               \OC::$server->getLogger()->debug("Registered action ".$action." to plugin ".get_class($plugin), ['app' => 'user_ldap']);
+                               \OCP\Server::get(LoggerInterface::class)->debug("Registered action ".$action." to plugin ".get_class($plugin), ['app' => 'user_ldap']);
                        }
                }
        }
index 3f05091a5377832ed897b152ae6a853fddc80d02..40bc8624c3c17b893932eeb58ad98c1e55a0afa3 100644 (file)
@@ -30,6 +30,7 @@ use Doctrine\DBAL\Exception;
 use Doctrine\DBAL\Platforms\SqlitePlatform;
 use OCP\DB\IPreparedStatement;
 use OCP\DB\QueryBuilder\IQueryBuilder;
+use Psr\Log\LoggerInterface;
 
 /**
  * Class AbstractMapping
@@ -351,7 +352,7 @@ abstract class AbstractMapping {
         */
        public function map($fdn, $name, $uuid) {
                if (mb_strlen($fdn) > 4000) {
-                       \OC::$server->getLogger()->error(
+                       \OCP\Server::get(LoggerInterface::class)->error(
                                'Cannot map, because the DN exceeds 4000 characters: {dn}',
                                [
                                        'app' => 'user_ldap',
index 516338f006b90302a283f8a568154ee29eb8eb1c..527c6684103f0d81a3564e18fe4a5f04f1b267df 100644 (file)
@@ -26,6 +26,7 @@
 namespace OCA\User_LDAP;
 
 use OC\User\Backend;
+use Psr\Log\LoggerInterface;
 
 class UserPluginManager {
        private int $respondToActions = 0;
@@ -62,12 +63,12 @@ class UserPluginManager {
                foreach ($this->which as $action => $v) {
                        if (is_int($action) && (bool)($respondToActions & $action)) {
                                $this->which[$action] = $plugin;
-                               \OC::$server->getLogger()->debug("Registered action ".$action." to plugin ".get_class($plugin), ['app' => 'user_ldap']);
+                               \OCP\Server::get(LoggerInterface::class)->debug("Registered action ".$action." to plugin ".get_class($plugin), ['app' => 'user_ldap']);
                        }
                }
                if (method_exists($plugin, 'deleteUser')) {
                        $this->which['deleteUser'] = $plugin;
-                       \OC::$server->getLogger()->debug("Registered action deleteUser to plugin ".get_class($plugin), ['app' => 'user_ldap']);
+                       \OCP\Server::get(LoggerInterface::class)->debug("Registered action deleteUser to plugin ".get_class($plugin), ['app' => 'user_ldap']);
                }
        }
 
index 58475a2bea97f9de4715ebfa2a61d5932fc85cab..5ec04484bef8df00237b003251eb11b2c86156f8 100644 (file)
@@ -143,7 +143,7 @@ abstract class AbstractIntegrationTest {
         * initializes the Access test instance
         */
        protected function initAccess() {
-               $this->access = new Access($this->connection, $this->ldap, $this->userManager, $this->helper, \OC::$server->getConfig(), \OC::$server->getLogger());
+               $this->access = new Access($this->connection, $this->ldap, $this->userManager, $this->helper, \OC::$server->getConfig(), \OCP\Server::get(LoggerInterface::class));
        }
 
        /**
index 72fc95a802b19cfd1db9d771ca45c86b30d6fa2c..74e795cc3772711c72424295de6edf04ffc657ba 100644 (file)
@@ -60,7 +60,7 @@ class File implements ICache {
                        $this->storage = new View('/' . $user->getUID() . '/cache');
                        return $this->storage;
                } else {
-                       \OC::$server->get(LoggerInterface::class)->error('Can\'t get cache storage, user not logged in', ['app' => 'core']);
+                       \OCP\Server::get(LoggerInterface::class)->error('Can\'t get cache storage, user not logged in', ['app' => 'core']);
                        throw new \OC\ForbiddenException('Can\t get cache storage, user not logged in');
                }
        }
@@ -192,11 +192,11 @@ class File implements ICache {
                                                }
                                        } catch (\OCP\Lock\LockedException $e) {
                                                // ignore locked chunks
-                                               \OC::$server->getLogger()->debug('Could not cleanup locked chunk "' . $file . '"', ['app' => 'core']);
+                                               \OCP\Server::get(LoggerInterface::class)->debug('Could not cleanup locked chunk "' . $file . '"', ['app' => 'core']);
                                        } catch (\OCP\Files\ForbiddenException $e) {
-                                               \OC::$server->getLogger()->debug('Could not cleanup forbidden chunk "' . $file . '"', ['app' => 'core']);
+                                               \OCP\Server::get(LoggerInterface::class)->debug('Could not cleanup forbidden chunk "' . $file . '"', ['app' => 'core']);
                                        } catch (\OCP\Files\LockNotAcquiredException $e) {
-                                               \OC::$server->getLogger()->debug('Could not cleanup locked chunk "' . $file . '"', ['app' => 'core']);
+                                               \OCP\Server::get(LoggerInterface::class)->debug('Could not cleanup locked chunk "' . $file . '"', ['app' => 'core']);
                                        }
                                }
                        }
index 9f0d89052be7024c007300c1463e8899d31d6f34..c6a5513d5b7c796a25ec43b5bcabc6bf09d95f9e 100644 (file)
@@ -48,6 +48,7 @@ use OCP\Files\Storage\IStorageFactory;
 use OCP\IUser;
 use OCP\IUserManager;
 use OCP\IUserSession;
+use Psr\Log\LoggerInterface;
 
 class Filesystem {
        private static ?Mount\Manager $mounts = null;
@@ -200,7 +201,7 @@ class Filesystem {
         */
        public static function addStorageWrapper($wrapperName, $wrapper, $priority = 50) {
                if (self::$logWarningWhenAddingStorageWrapper) {
-                       \OC::$server->getLogger()->warning("Storage wrapper '{wrapper}' was not registered via the 'OC_Filesystem - preSetup' hook which could cause potential problems.", [
+                       \OCP\Server::get(LoggerInterface::class)->warning("Storage wrapper '{wrapper}' was not registered via the 'OC_Filesystem - preSetup' hook which could cause potential problems.", [
                                'wrapper' => $wrapperName,
                                'app' => 'filesystem',
                        ]);
index 3e0fbd1591956363edd541d139f10a5ec748e00f..7eb284fc7746391555597b837f2a88bb69a85985 100644 (file)
@@ -47,7 +47,7 @@ use OCP\Files\ObjectStore\IObjectStore;
 use OCP\Files\ObjectStore\IObjectStoreMultiPartUpload;
 use OCP\Files\Storage\IChunkedFileWrite;
 use OCP\Files\Storage\IStorage;
-use OCP\ILogger;
+use Psr\Log\LoggerInterface;
 
 class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFileWrite {
        use CopyDirectory;
@@ -56,7 +56,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil
        protected string $id;
        private string $objectPrefix = 'urn:oid:';
 
-       private ILogger $logger;
+       private LoggerInterface $logger;
 
        private bool $handleCopiesAsOwned;
        protected bool $validateWrites = true;
@@ -84,7 +84,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil
                }
                $this->handleCopiesAsOwned = (bool)($params['handleCopiesAsOwned'] ?? false);
 
-               $this->logger = \OC::$server->getLogger();
+               $this->logger = \OCP\Server::get(LoggerInterface::class);
        }
 
        public function mkdir($path, bool $force = false) {
@@ -220,10 +220,13 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil
                        $this->objectStore->deleteObject($this->getURN($entry->getId()));
                } catch (\Exception $ex) {
                        if ($ex->getCode() !== 404) {
-                               $this->logger->logException($ex, [
-                                       'app' => 'objectstore',
-                                       'message' => 'Could not delete object ' . $this->getURN($entry->getId()) . ' for ' . $entry->getPath(),
-                               ]);
+                               $this->logger->error(
+                                       'Could not delete object ' . $this->getURN($entry->getId()) . ' for ' . $entry->getPath(),
+                                       [
+                                               'app' => 'objectstore',
+                                               'exception' => $ex,
+                                       ]
+                               );
                                return false;
                        }
                        //removing from cache is ok as it does not exist in the objectstore anyway
@@ -286,7 +289,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil
 
                        return IteratorDirectory::wrap($files);
                } catch (\Exception $e) {
-                       $this->logger->logException($e);
+                       $this->logger->error($e->getMessage(), ['exception' => $e]);
                        return false;
                }
        }
@@ -336,16 +339,22 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil
                                                }
                                                return $handle;
                                        } catch (NotFoundException $e) {
-                                               $this->logger->logException($e, [
-                                                       'app' => 'objectstore',
-                                                       'message' => 'Could not get object ' . $this->getURN($stat['fileid']) . ' for file ' . $path,
-                                               ]);
+                                               $this->logger->error(
+                                                       'Could not get object ' . $this->getURN($stat['fileid']) . ' for file ' . $path,
+                                                       [
+                                                               'app' => 'objectstore',
+                                                               'exception' => $e,
+                                                       ]
+                                               );
                                                throw $e;
-                                       } catch (\Exception $ex) {
-                                               $this->logger->logException($ex, [
-                                                       'app' => 'objectstore',
-                                                       'message' => 'Could not get object ' . $this->getURN($stat['fileid']) . ' for file ' . $path,
-                                               ]);
+                                       } catch (\Exception $e) {
+                                               $this->logger->error(
+                                                       'Could not get object ' . $this->getURN($stat['fileid']) . ' for file ' . $path,
+                                                       [
+                                                               'app' => 'objectstore',
+                                                               'exception' => $e,
+                                                       ]
+                                               );
                                                return false;
                                        }
                                } else {
@@ -442,10 +451,13 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil
                                ];
                                $this->getCache()->put($path, $stat);
                        } catch (\Exception $ex) {
-                               $this->logger->logException($ex, [
-                                       'app' => 'objectstore',
-                                       'message' => 'Could not create object for ' . $path,
-                               ]);
+                               $this->logger->error(
+                                       'Could not create object for ' . $path,
+                                       [
+                                               'app' => 'objectstore',
+                                               'exception' => $ex,
+                                       ]
+                               );
                                throw $ex;
                        }
                }
@@ -540,15 +552,21 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil
                                 * Else people lose access to existing files
                                 */
                                $this->getCache()->remove($uploadPath);
-                               $this->logger->logException($ex, [
-                                       'app' => 'objectstore',
-                                       'message' => 'Could not create object ' . $urn . ' for ' . $path,
-                               ]);
+                               $this->logger->error(
+                                       'Could not create object ' . $urn . ' for ' . $path,
+                                       [
+                                               'app' => 'objectstore',
+                                               'exception' => $ex,
+                                       ]
+                               );
                        } else {
-                               $this->logger->logException($ex, [
-                                       'app' => 'objectstore',
-                                       'message' => 'Could not update object ' . $urn . ' for ' . $path,
-                               ]);
+                               $this->logger->error(
+                                       'Could not update object ' . $urn . ' for ' . $path,
+                                       [
+                                               'app' => 'objectstore',
+                                               'exception' => $ex,
+                                       ]
+                               );
                        }
                        throw $ex; // make this bubble up
                }
@@ -713,10 +731,13 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil
                        }
                } catch (S3MultipartUploadException|S3Exception $e) {
                        $this->objectStore->abortMultipartUpload($urn, $writeToken);
-                       $this->logger->logException($e, [
-                               'app' => 'objectstore',
-                               'message' => 'Could not compete multipart upload ' . $urn . ' with uploadId ' . $writeToken,
-                       ]);
+                       $this->logger->error(
+                               'Could not compete multipart upload ' . $urn . ' with uploadId ' . $writeToken,
+                               [
+                                       'app' => 'objectstore',
+                                       'exception' => $e,
+                               ]
+                       );
                        throw new GenericFileException('Could not write chunked file');
                }
                return $size;
index ea4aa0527bba9aac56be3c810d713a31494d306f..c44e4f9cf499b1fa402b83cfb72a99c83e349132 100644 (file)
@@ -30,6 +30,7 @@ namespace OC\L10N;
 
 use OCP\IL10N;
 use OCP\L10N\IFactory;
+use Psr\Log\LoggerInterface;
 use Punic\Calendar;
 use Symfony\Component\Translation\IdentityTranslator;
 
@@ -234,7 +235,7 @@ class L10N implements IL10N {
                $json = json_decode(file_get_contents($translationFile), true);
                if (!\is_array($json)) {
                        $jsonError = json_last_error();
-                       \OC::$server->getLogger()->warning("Failed to load $translationFile - json error code: $jsonError", ['app' => 'l10n']);
+                       \OCP\Server::get(LoggerInterface::class)->warning("Failed to load $translationFile - json error code: $jsonError", ['app' => 'l10n']);
                        return false;
                }
 
index efe548b7783959fa7c621972b1768d5a7b30212e..71965a12035afe88e3c67cb459b9f930a2d6095a 100644 (file)
@@ -24,7 +24,9 @@
  */
 namespace OC\Log;
 
+use OCP\IConfig;
 use OCP\Log\RotationTrait;
+use Psr\Log\LoggerInterface;
 
 /**
  * This rotates the current logfile to a new name, this way the total log usage
@@ -35,15 +37,15 @@ use OCP\Log\RotationTrait;
 class Rotate extends \OCP\BackgroundJob\Job {
        use RotationTrait;
 
-       public function run($dummy): void {
-               $systemConfig = \OC::$server->getSystemConfig();
-               $this->filePath = $systemConfig->getValue('logfile', $systemConfig->getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/nextcloud.log');
+       public function run($argument): void {
+               $config = \OCP\Server::get(IConfig::class);
+               $this->filePath = $config->getSystemValueString('logfile', $config->getSystemValueString('datadirectory', \OC::$SERVERROOT . '/data') . '/nextcloud.log');
 
-               $this->maxSize = \OC::$server->getConfig()->getSystemValueInt('log_rotate_size', 100 * 1024 * 1024);
+               $this->maxSize = $config->getSystemValueInt('log_rotate_size', 100 * 1024 * 1024);
                if ($this->shouldRotateBySize()) {
                        $rotatedFile = $this->rotate();
                        $msg = 'Log file "'.$this->filePath.'" was over '.$this->maxSize.' bytes, moved to "'.$rotatedFile.'"';
-                       \OC::$server->getLogger()->info($msg, ['app' => Rotate::class]);
+                       \OCP\Server::get(LoggerInterface::class)->info($msg, ['app' => Rotate::class]);
                }
        }
 }
index b1e39843e494a6d9f740d6a55c87287a507c272b..9f1a0323aa30b878d7bd2e5bde9a4ec22c169a0b 100644 (file)
@@ -30,6 +30,7 @@ namespace OC;
 use OCP\ISearch;
 use OCP\Search\PagedProvider;
 use OCP\Search\Provider;
+use Psr\Log\LoggerInterface;
 
 /**
  * Provide an interface to all search providers
@@ -65,7 +66,7 @@ class Search implements ISearch {
                                        $results = array_merge($results, $providerResults);
                                }
                        } else {
-                               \OC::$server->getLogger()->warning('Ignoring Unknown search provider', ['provider' => $provider]);
+                               \OCP\Server::get(LoggerInterface::class)->warning('Ignoring Unknown search provider', ['provider' => $provider]);
                        }
                }
                return $results;
index 55ac3eda644e1bd5126e88607f41cf6c168a6e14..b4ec16936f3545bc90626b1676017c54d4d1f752 100644 (file)
@@ -55,6 +55,7 @@ use OCP\Share\Exceptions\ShareNotFound;
 use OCP\Share\IAttributes;
 use OCP\Share\IShare;
 use OCP\Share\IShareProvider;
+use Psr\Log\LoggerInterface;
 use function str_starts_with;
 
 /**
@@ -1237,7 +1238,8 @@ class DefaultShareProvider implements IShareProvider {
                                )
                        );
                } else {
-                       \OC::$server->getLogger()->logException(new \InvalidArgumentException('Default share provider tried to delete all shares for type: ' . $shareType));
+                       $e = new \InvalidArgumentException('Default share provider tried to delete all shares for type: ' . $shareType);
+                       \OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
                        return;
                }
 
index 7b0c509324570df343d495e559a4c21a05cb90b3..5f84b692def45ac9a91c2a5947bbbd5d75c3fd63 100644 (file)
@@ -35,7 +35,6 @@ use OC\Tagging\TagMapper;
 use OCP\DB\Exception;
 use OCP\DB\QueryBuilder\IQueryBuilder;
 use OCP\IDBConnection;
-use OCP\ILogger;
 use OCP\ITags;
 use OCP\Share_Backend;
 use Psr\Log\LoggerInterface;
@@ -486,11 +485,13 @@ class Tags implements ITags {
                try {
                        return $this->getIdsForTag(ITags::TAG_FAVORITE);
                } catch (\Exception $e) {
-                       \OC::$server->getLogger()->logException($e, [
-                               'message' => __METHOD__,
-                               'level' => ILogger::ERROR,
-                               'app' => 'core',
-                       ]);
+                       \OCP\Server::get(LoggerInterface::class)->error(
+                               $e->getMessage(),
+                               [
+                                       'app' => 'core',
+                                       'exception' => $e,
+                               ]
+                       );
                        return [];
                }
        }
@@ -549,7 +550,7 @@ class Tags implements ITags {
                try {
                        $qb->executeStatement();
                } catch (\Exception $e) {
-                       \OC::$server->getLogger()->error($e->getMessage(), [
+                       \OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), [
                                'app' => 'core',
                                'exception' => $e,
                        ]);
index 705f5fbe66bd607463fd1fc1f7bb9b656c1c6694..96edf624628d299d9da8dd621f37d016ba084f37 100644 (file)
@@ -56,6 +56,7 @@ use OCP\User\Backend\ISearchKnownUsersBackend;
 use OCP\User\Events\BeforeUserCreatedEvent;
 use OCP\User\Events\UserCreatedEvent;
 use OCP\UserInterface;
+use Psr\Log\LoggerInterface;
 
 /**
  * Class Manager
@@ -235,7 +236,7 @@ class Manager extends PublicEmitter implements IUserManager {
                $result = $this->checkPasswordNoLogging($loginName, $password);
 
                if ($result === false) {
-                       \OC::$server->getLogger()->warning('Login failed: \''. $loginName .'\' (Remote IP: \''. \OC::$server->getRequest()->getRemoteAddress(). '\')', ['app' => 'core']);
+                       \OCP\Server::get(LoggerInterface::class)->warning('Login failed: \''. $loginName .'\' (Remote IP: \''. \OC::$server->getRequest()->getRemoteAddress(). '\')', ['app' => 'core']);
                }
 
                return $result;
index 4d6e9177b787d03cfb5e8f9f427422628aece546..f62c464ea55e131e4c9b4a4e11d8213695f63d53 100644 (file)
@@ -38,6 +38,7 @@ use OC\AppFramework\Routing\RouteConfig;
 use OC\Route\Router;
 use OC\ServerContainer;
 use OCP\Route\IRouter;
+use Psr\Log\LoggerInterface;
 
 /**
  * Class App
@@ -98,8 +99,9 @@ class App {
                        }
 
                        if (!$setUpViaQuery && $applicationClassName !== \OCP\AppFramework\App::class) {
-                               \OC::$server->getLogger()->logException($e, [
+                               \OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), [
                                        'app' => $appName,
+                                       'exception' => $e,
                                ]);
                        }
                }
index 55e9f426aba8de20a7d879d240972ac963675e83..a2c8adeb98236072a37d2c6ff90775e11ad63f1e 100644 (file)
@@ -42,6 +42,7 @@ if (\OCP\Util::needUpgrade()
 }
 
 use OCP\Security\Bruteforce\MaxDelayReached;
+use Psr\Log\LoggerInterface;
 use Symfony\Component\Routing\Exception\MethodNotAllowedException;
 use Symfony\Component\Routing\Exception\ResourceNotFoundException;
 
@@ -81,7 +82,7 @@ try {
 } catch (\OC\User\LoginException $e) {
        OC_API::respond(new \OC\OCS\Result(null, \OCP\AppFramework\OCSController::RESPOND_UNAUTHORISED, 'Unauthorised'));
 } catch (\Exception $e) {
-       \OC::$server->getLogger()->logException($e);
+       \OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
        OC_API::setContentType();
 
        $format = \OC::$server->getRequest()->getParam('format', 'xml');
index 9f3ffcec5e9195426d560b170901b1dbeea386e9..2bf710c72fcb6716965855a044afc8d23e4def87 100644 (file)
@@ -32,6 +32,8 @@
  */
 require_once __DIR__ . '/lib/versioncheck.php';
 
+use Psr\Log\LoggerInterface;
+
 /**
  * @param $service
  * @return string
@@ -103,10 +105,10 @@ try {
                $status = 503;
        }
        //show the user a detailed error page
-       \OC::$server->getLogger()->logException($ex, ['app' => 'public']);
+       \OCP\Server::get(LoggerInterface::class)->error($ex->getMessage(), ['app' => 'public', 'exception' => $ex]);
        OC_Template::printExceptionErrorPage($ex, $status);
 } catch (Error $ex) {
        //show the user a detailed error page
-       \OC::$server->getLogger()->logException($ex, ['app' => 'public']);
+       \OCP\Server::get(LoggerInterface::class)->error($ex->getMessage(), ['app' => 'public', 'exception' => $ex]);
        OC_Template::printExceptionErrorPage($ex, 500);
 }
index 62eb978781cc1645fee2be0268225aa7734130fd..99371bbe6939cf9968716a3b489f90e382296dfc 100644 (file)
@@ -33,6 +33,8 @@
  */
 require_once __DIR__ . '/lib/versioncheck.php';
 
+use Psr\Log\LoggerInterface;
+
 try {
        require_once __DIR__ . '/lib/base.php';
 
@@ -62,5 +64,5 @@ try {
        }
 } catch (Exception $ex) {
        http_response_code(500);
-       \OC::$server->getLogger()->logException($ex, ['app' => 'remote']);
+       \OCP\Server::get(LoggerInterface::class)->error($ex->getMessage(), ['app' => 'remote','exception' => $ex]);
 }