Browse Source

chore: Migrate away from OC::$server->getLogger

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
tags/v29.0.0beta1
Côme Chilliet 3 months ago
parent
commit
c0ce272e9c

+ 2
- 2
apps/files_sharing/lib/Controller/ShareAPIController.php View File

try { try {
$share = $this->shareManager->createShare($share); $share = $this->shareManager->createShare($share);
} catch (GenericShareException $e) { } 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(); $code = $e->getCode() === 0 ? 403 : $e->getCode();
throw new OCSException($e->getHint(), $code); throw new OCSException($e->getHint(), $code);
} catch (\Exception $e) { } catch (\Exception $e) {
\OC::$server->getLogger()->logException($e);
\OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
throw new OCSForbiddenException($e->getMessage(), $e); throw new OCSForbiddenException($e->getMessage(), $e);
} }



+ 7
- 6
apps/files_sharing/lib/DeleteOrphanedSharesJob.php View File



use OCP\AppFramework\Utility\ITimeFactory; use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob; 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. * Delete all share entries that have no matching entries in the file cache table.
class DeleteOrphanedSharesJob extends TimedJob { class DeleteOrphanedSharesJob extends TimedJob {
/** /**
* Default interval in minutes * Default interval in minutes
*
* @var int $defaultIntervalMin
**/ **/
protected $defaultIntervalMin = 15;
protected int $defaultIntervalMin = 15;


/** /**
* sets the correct interval for this timed job * sets the correct interval for this timed job
* @param array $argument unused argument * @param array $argument unused argument
*/ */
public function run($argument) { public function run($argument) {
$connection = \OC::$server->getDatabaseConnection();
$logger = \OC::$server->getLogger();
$connection = Server::get(IDBConnection::class);
$logger = Server::get(LoggerInterface::class);


$sql = $sql =
'DELETE FROM `*PREFIX*share` ' . 'DELETE FROM `*PREFIX*share` ' .
'WHERE `item_type` in (\'file\', \'folder\') ' . 'WHERE `item_type` in (\'file\', \'folder\') ' .
'AND NOT EXISTS (SELECT `fileid` FROM `*PREFIX*filecache` WHERE `file_source` = `fileid`)'; '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']); $logger->debug("$deletedEntries orphaned share(s) deleted", ['app' => 'DeleteOrphanedSharesJob']);
} }
} }

+ 2
- 1
apps/files_sharing/lib/ShareBackend/File.php View File



use OCA\FederatedFileSharing\FederatedShareProvider; use OCA\FederatedFileSharing\FederatedShareProvider;
use OCP\Share\IShare; use OCP\Share\IShare;
use Psr\Log\LoggerInterface;


class File implements \OCP\Share_Backend_File_Dependent { class File implements \OCP\Share_Backend_File_Dependent {
public const FORMAT_SHARED_STORAGE = 0; public const FORMAT_SHARED_STORAGE = 0;
if (isset($fileOwner)) { if (isset($fileOwner)) {
$source['fileOwner'] = $fileOwner; $source['fileOwner'] = $fileOwner;
} else { } 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; return $source;

+ 9
- 2
apps/files_sharing/lib/SharedMount.php View File

use OCP\ICache; use OCP\ICache;
use OCP\IUser; use OCP\IUser;
use OCP\Share\Events\VerifyMountPointEvent; use OCP\Share\Events\VerifyMountPointEvent;
use Psr\Log\LoggerInterface;


/** /**
* Shared mount points can be moved by the user * Shared mount points can be moved by the user


// it is not a file relative to data/user/files // it is not a file relative to data/user/files
if (count($split) < 3 || $split[1] !== '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); throw new \OCA\Files_Sharing\Exceptions\BrokenPath('Path does not start with /user/files', 10);
} }


$this->setMountPoint($target); $this->setMountPoint($target);
$this->storage->setMountPoint($relTargetPath); $this->storage->setMountPoint($relTargetPath);
} catch (\Exception $e) { } 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; return $result;

+ 3
- 1
apps/user_ldap/lib/Configuration.php View File

*/ */
namespace OCA\User_LDAP; namespace OCA\User_LDAP;


use Psr\Log\LoggerInterface;

/** /**
* @property int ldapPagingSize holds an integer * @property int ldapPagingSize holds an integer
* @property string ldapUserAvatarRule * @property string ldapUserAvatarRule
return [strtolower($attribute)]; return [strtolower($attribute)];
} }
if ($value !== self::AVATAR_PREFIX_DEFAULT) { 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; return $defaultAttributes;
} }

+ 2
- 1
apps/user_ldap/lib/GroupPluginManager.php View File

namespace OCA\User_LDAP; namespace OCA\User_LDAP;


use OCP\GroupInterface; use OCP\GroupInterface;
use Psr\Log\LoggerInterface;


class GroupPluginManager { class GroupPluginManager {
private int $respondToActions = 0; private int $respondToActions = 0;
foreach ($this->which as $action => $v) { foreach ($this->which as $action => $v) {
if ((bool)($respondToActions & $action)) { if ((bool)($respondToActions & $action)) {
$this->which[$action] = $plugin; $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']);
} }
} }
} }

+ 2
- 1
apps/user_ldap/lib/Mapping/AbstractMapping.php View File

use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Platforms\SqlitePlatform;
use OCP\DB\IPreparedStatement; use OCP\DB\IPreparedStatement;
use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\DB\QueryBuilder\IQueryBuilder;
use Psr\Log\LoggerInterface;


/** /**
* Class AbstractMapping * Class AbstractMapping
*/ */
public function map($fdn, $name, $uuid) { public function map($fdn, $name, $uuid) {
if (mb_strlen($fdn) > 4000) { if (mb_strlen($fdn) > 4000) {
\OC::$server->getLogger()->error(
\OCP\Server::get(LoggerInterface::class)->error(
'Cannot map, because the DN exceeds 4000 characters: {dn}', 'Cannot map, because the DN exceeds 4000 characters: {dn}',
[ [
'app' => 'user_ldap', 'app' => 'user_ldap',

+ 3
- 2
apps/user_ldap/lib/UserPluginManager.php View File

namespace OCA\User_LDAP; namespace OCA\User_LDAP;


use OC\User\Backend; use OC\User\Backend;
use Psr\Log\LoggerInterface;


class UserPluginManager { class UserPluginManager {
private int $respondToActions = 0; private int $respondToActions = 0;
foreach ($this->which as $action => $v) { foreach ($this->which as $action => $v) {
if (is_int($action) && (bool)($respondToActions & $action)) { if (is_int($action) && (bool)($respondToActions & $action)) {
$this->which[$action] = $plugin; $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')) { if (method_exists($plugin, 'deleteUser')) {
$this->which['deleteUser'] = $plugin; $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']);
} }
} }



+ 1
- 1
apps/user_ldap/tests/Integration/AbstractIntegrationTest.php View File

* initializes the Access test instance * initializes the Access test instance
*/ */
protected function initAccess() { 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));
} }


/** /**

+ 4
- 4
lib/private/Cache/File.php View File

$this->storage = new View('/' . $user->getUID() . '/cache'); $this->storage = new View('/' . $user->getUID() . '/cache');
return $this->storage; return $this->storage;
} else { } 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'); throw new \OC\ForbiddenException('Can\t get cache storage, user not logged in');
} }
} }
} }
} catch (\OCP\Lock\LockedException $e) { } catch (\OCP\Lock\LockedException $e) {
// ignore locked chunks // 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) { } 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) { } 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']);
} }
} }
} }

+ 2
- 1
lib/private/Files/Filesystem.php View File

use OCP\IUser; use OCP\IUser;
use OCP\IUserManager; use OCP\IUserManager;
use OCP\IUserSession; use OCP\IUserSession;
use Psr\Log\LoggerInterface;


class Filesystem { class Filesystem {
private static ?Mount\Manager $mounts = null; private static ?Mount\Manager $mounts = null;
*/ */
public static function addStorageWrapper($wrapperName, $wrapper, $priority = 50) { public static function addStorageWrapper($wrapperName, $wrapper, $priority = 50) {
if (self::$logWarningWhenAddingStorageWrapper) { 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, 'wrapper' => $wrapperName,
'app' => 'filesystem', 'app' => 'filesystem',
]); ]);

+ 54
- 33
lib/private/Files/ObjectStore/ObjectStoreStorage.php View File

use OCP\Files\ObjectStore\IObjectStoreMultiPartUpload; use OCP\Files\ObjectStore\IObjectStoreMultiPartUpload;
use OCP\Files\Storage\IChunkedFileWrite; use OCP\Files\Storage\IChunkedFileWrite;
use OCP\Files\Storage\IStorage; use OCP\Files\Storage\IStorage;
use OCP\ILogger;
use Psr\Log\LoggerInterface;


class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFileWrite { class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFileWrite {
use CopyDirectory; use CopyDirectory;
protected string $id; protected string $id;
private string $objectPrefix = 'urn:oid:'; private string $objectPrefix = 'urn:oid:';


private ILogger $logger;
private LoggerInterface $logger;


private bool $handleCopiesAsOwned; private bool $handleCopiesAsOwned;
protected bool $validateWrites = true; protected bool $validateWrites = true;
} }
$this->handleCopiesAsOwned = (bool)($params['handleCopiesAsOwned'] ?? false); $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) { public function mkdir($path, bool $force = false) {
$this->objectStore->deleteObject($this->getURN($entry->getId())); $this->objectStore->deleteObject($this->getURN($entry->getId()));
} catch (\Exception $ex) { } catch (\Exception $ex) {
if ($ex->getCode() !== 404) { 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; return false;
} }
//removing from cache is ok as it does not exist in the objectstore anyway //removing from cache is ok as it does not exist in the objectstore anyway


return IteratorDirectory::wrap($files); return IteratorDirectory::wrap($files);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->logException($e);
$this->logger->error($e->getMessage(), ['exception' => $e]);
return false; return false;
} }
} }
} }
return $handle; return $handle;
} catch (NotFoundException $e) { } 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; 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; return false;
} }
} else { } else {
]; ];
$this->getCache()->put($path, $stat); $this->getCache()->put($path, $stat);
} catch (\Exception $ex) { } 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; throw $ex;
} }
} }
* Else people lose access to existing files * Else people lose access to existing files
*/ */
$this->getCache()->remove($uploadPath); $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 { } 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 throw $ex; // make this bubble up
} }
} }
} catch (S3MultipartUploadException|S3Exception $e) { } catch (S3MultipartUploadException|S3Exception $e) {
$this->objectStore->abortMultipartUpload($urn, $writeToken); $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'); throw new GenericFileException('Could not write chunked file');
} }
return $size; return $size;

+ 2
- 1
lib/private/L10N/L10N.php View File



use OCP\IL10N; use OCP\IL10N;
use OCP\L10N\IFactory; use OCP\L10N\IFactory;
use Psr\Log\LoggerInterface;
use Punic\Calendar; use Punic\Calendar;
use Symfony\Component\Translation\IdentityTranslator; use Symfony\Component\Translation\IdentityTranslator;


$json = json_decode(file_get_contents($translationFile), true); $json = json_decode(file_get_contents($translationFile), true);
if (!\is_array($json)) { if (!\is_array($json)) {
$jsonError = json_last_error(); $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; return false;
} }



+ 7
- 5
lib/private/Log/Rotate.php View File

*/ */
namespace OC\Log; namespace OC\Log;


use OCP\IConfig;
use OCP\Log\RotationTrait; use OCP\Log\RotationTrait;
use Psr\Log\LoggerInterface;


/** /**
* This rotates the current logfile to a new name, this way the total log usage * This rotates the current logfile to a new name, this way the total log usage
class Rotate extends \OCP\BackgroundJob\Job { class Rotate extends \OCP\BackgroundJob\Job {
use RotationTrait; 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()) { if ($this->shouldRotateBySize()) {
$rotatedFile = $this->rotate(); $rotatedFile = $this->rotate();
$msg = 'Log file "'.$this->filePath.'" was over '.$this->maxSize.' bytes, moved to "'.$rotatedFile.'"'; $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]);
} }
} }
} }

+ 2
- 1
lib/private/Search.php View File

use OCP\ISearch; use OCP\ISearch;
use OCP\Search\PagedProvider; use OCP\Search\PagedProvider;
use OCP\Search\Provider; use OCP\Search\Provider;
use Psr\Log\LoggerInterface;


/** /**
* Provide an interface to all search providers * Provide an interface to all search providers
$results = array_merge($results, $providerResults); $results = array_merge($results, $providerResults);
} }
} else { } 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; return $results;

+ 3
- 1
lib/private/Share20/DefaultShareProvider.php View File

use OCP\Share\IAttributes; use OCP\Share\IAttributes;
use OCP\Share\IShare; use OCP\Share\IShare;
use OCP\Share\IShareProvider; use OCP\Share\IShareProvider;
use Psr\Log\LoggerInterface;
use function str_starts_with; use function str_starts_with;


/** /**
) )
); );
} else { } 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; return;
} }



+ 8
- 7
lib/private/Tags.php View File

use OCP\DB\Exception; use OCP\DB\Exception;
use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection; use OCP\IDBConnection;
use OCP\ILogger;
use OCP\ITags; use OCP\ITags;
use OCP\Share_Backend; use OCP\Share_Backend;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
try { try {
return $this->getIdsForTag(ITags::TAG_FAVORITE); return $this->getIdsForTag(ITags::TAG_FAVORITE);
} catch (\Exception $e) { } 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 []; return [];
} }
} }
try { try {
$qb->executeStatement(); $qb->executeStatement();
} catch (\Exception $e) { } catch (\Exception $e) {
\OC::$server->getLogger()->error($e->getMessage(), [
\OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), [
'app' => 'core', 'app' => 'core',
'exception' => $e, 'exception' => $e,
]); ]);

+ 2
- 1
lib/private/User/Manager.php View File

use OCP\User\Events\BeforeUserCreatedEvent; use OCP\User\Events\BeforeUserCreatedEvent;
use OCP\User\Events\UserCreatedEvent; use OCP\User\Events\UserCreatedEvent;
use OCP\UserInterface; use OCP\UserInterface;
use Psr\Log\LoggerInterface;


/** /**
* Class Manager * Class Manager
$result = $this->checkPasswordNoLogging($loginName, $password); $result = $this->checkPasswordNoLogging($loginName, $password);


if ($result === false) { 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; return $result;

+ 3
- 1
lib/public/AppFramework/App.php View File

use OC\Route\Router; use OC\Route\Router;
use OC\ServerContainer; use OC\ServerContainer;
use OCP\Route\IRouter; use OCP\Route\IRouter;
use Psr\Log\LoggerInterface;


/** /**
* Class App * Class App
} }


if (!$setUpViaQuery && $applicationClassName !== \OCP\AppFramework\App::class) { if (!$setUpViaQuery && $applicationClassName !== \OCP\AppFramework\App::class) {
\OC::$server->getLogger()->logException($e, [
\OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), [
'app' => $appName, 'app' => $appName,
'exception' => $e,
]); ]);
} }
} }

+ 2
- 1
ocs/v1.php View File

} }


use OCP\Security\Bruteforce\MaxDelayReached; use OCP\Security\Bruteforce\MaxDelayReached;
use Psr\Log\LoggerInterface;
use Symfony\Component\Routing\Exception\MethodNotAllowedException; use Symfony\Component\Routing\Exception\MethodNotAllowedException;
use Symfony\Component\Routing\Exception\ResourceNotFoundException; use Symfony\Component\Routing\Exception\ResourceNotFoundException;


} catch (\OC\User\LoginException $e) { } catch (\OC\User\LoginException $e) {
OC_API::respond(new \OC\OCS\Result(null, \OCP\AppFramework\OCSController::RESPOND_UNAUTHORISED, 'Unauthorised')); OC_API::respond(new \OC\OCS\Result(null, \OCP\AppFramework\OCSController::RESPOND_UNAUTHORISED, 'Unauthorised'));
} catch (\Exception $e) { } catch (\Exception $e) {
\OC::$server->getLogger()->logException($e);
\OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
OC_API::setContentType(); OC_API::setContentType();


$format = \OC::$server->getRequest()->getParam('format', 'xml'); $format = \OC::$server->getRequest()->getParam('format', 'xml');

+ 4
- 2
public.php View File

*/ */
require_once __DIR__ . '/lib/versioncheck.php'; require_once __DIR__ . '/lib/versioncheck.php';


use Psr\Log\LoggerInterface;

/** /**
* @param $service * @param $service
* @return string * @return string
$status = 503; $status = 503;
} }
//show the user a detailed error page //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); OC_Template::printExceptionErrorPage($ex, $status);
} catch (Error $ex) { } catch (Error $ex) {
//show the user a detailed error page //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); OC_Template::printExceptionErrorPage($ex, 500);
} }

+ 3
- 1
status.php View File

*/ */
require_once __DIR__ . '/lib/versioncheck.php'; require_once __DIR__ . '/lib/versioncheck.php';


use Psr\Log\LoggerInterface;

try { try {
require_once __DIR__ . '/lib/base.php'; require_once __DIR__ . '/lib/base.php';


} }
} catch (Exception $ex) { } catch (Exception $ex) {
http_response_code(500); http_response_code(500);
\OC::$server->getLogger()->logException($ex, ['app' => 'remote']);
\OCP\Server::get(LoggerInterface::class)->error($ex->getMessage(), ['app' => 'remote','exception' => $ex]);
} }

Loading…
Cancel
Save