mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Merge pull request #31752 from nextcloud/fix/remove-still-more-ilogger
Move away from deprecated ILogger
This commit is contained in:
commit
459202d54c
21 changed files with 109 additions and 230 deletions
|
|
@ -1501,7 +1501,6 @@ return array(
|
|||
'OC\\Share20\\UserRemovedListener' => $baseDir . '/lib/private/Share20/UserRemovedListener.php',
|
||||
'OC\\Share\\Constants' => $baseDir . '/lib/private/Share/Constants.php',
|
||||
'OC\\Share\\Helper' => $baseDir . '/lib/private/Share/Helper.php',
|
||||
'OC\\Share\\SearchResultSorter' => $baseDir . '/lib/private/Share/SearchResultSorter.php',
|
||||
'OC\\Share\\Share' => $baseDir . '/lib/private/Share/Share.php',
|
||||
'OC\\StreamImage' => $baseDir . '/lib/private/StreamImage.php',
|
||||
'OC\\Streamer' => $baseDir . '/lib/private/Streamer.php',
|
||||
|
|
|
|||
|
|
@ -1530,7 +1530,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
|
|||
'OC\\Share20\\UserRemovedListener' => __DIR__ . '/../../..' . '/lib/private/Share20/UserRemovedListener.php',
|
||||
'OC\\Share\\Constants' => __DIR__ . '/../../..' . '/lib/private/Share/Constants.php',
|
||||
'OC\\Share\\Helper' => __DIR__ . '/../../..' . '/lib/private/Share/Helper.php',
|
||||
'OC\\Share\\SearchResultSorter' => __DIR__ . '/../../..' . '/lib/private/Share/SearchResultSorter.php',
|
||||
'OC\\Share\\Share' => __DIR__ . '/../../..' . '/lib/private/Share/Share.php',
|
||||
'OC\\StreamImage' => __DIR__ . '/../../..' . '/lib/private/StreamImage.php',
|
||||
'OC\\Streamer' => __DIR__ . '/../../..' . '/lib/private/Streamer.php',
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ namespace OC\Cache;
|
|||
use OC\Files\Filesystem;
|
||||
use OC\Files\View;
|
||||
use OCP\ICache;
|
||||
use OCP\ILogger;
|
||||
use OCP\Security\ISecureRandom;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class File implements ICache {
|
||||
|
||||
|
|
@ -61,7 +61,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', ILogger::ERROR);
|
||||
\OC::$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');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,9 +30,9 @@ use InvalidArgumentException;
|
|||
use OCP\AppFramework\QueryException;
|
||||
use OCP\Dashboard\IManager;
|
||||
use OCP\Dashboard\IWidget;
|
||||
use OCP\ILogger;
|
||||
use OCP\IServerContainer;
|
||||
use Throwable;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Manager implements IManager {
|
||||
|
||||
|
|
@ -72,10 +72,10 @@ class Manager implements IManager {
|
|||
* There is a circular dependency between the logger and the registry, so
|
||||
* we can not inject it. Thus the static call.
|
||||
*/
|
||||
\OC::$server->getLogger()->logException($e, [
|
||||
'message' => 'Could not load lazy dashbaord widget: ' . $e->getMessage(),
|
||||
'level' => ILogger::FATAL,
|
||||
]);
|
||||
\OC::$server->get(LoggerInterface::class)->critical(
|
||||
'Could not load lazy dashboard widget: ' . $e->getMessage(),
|
||||
['excepiton' => $e]
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Try to register the loaded reporter. Theoretically it could be of a wrong
|
||||
|
|
@ -88,10 +88,10 @@ class Manager implements IManager {
|
|||
* There is a circular dependency between the logger and the registry, so
|
||||
* we can not inject it. Thus the static call.
|
||||
*/
|
||||
\OC::$server->getLogger()->logException($e, [
|
||||
'message' => 'Could not register lazy dashboard widget: ' . $e->getMessage(),
|
||||
'level' => ILogger::FATAL,
|
||||
]);
|
||||
\OC::$server->get(LoggerInterface::class)->critical(
|
||||
'Could not register lazy dashboard widget: ' . $e->getMessage(),
|
||||
['excepiton' => $e]
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -100,16 +100,19 @@ class Manager implements IManager {
|
|||
$endTime = microtime(true);
|
||||
$duration = $endTime - $startTime;
|
||||
if ($duration > 1) {
|
||||
\OC::$server->getLogger()->error('Dashboard widget {widget} took {duration} seconds to load.', [
|
||||
'widget' => $widget->getId(),
|
||||
'duration' => round($duration, 2),
|
||||
]);
|
||||
\OC::$server->get(LoggerInterface::class)->error(
|
||||
'Dashboard widget {widget} took {duration} seconds to load.',
|
||||
[
|
||||
'widget' => $widget->getId(),
|
||||
'duration' => round($duration, 2),
|
||||
]
|
||||
);
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
\OC::$server->getLogger()->logException($e, [
|
||||
'message' => 'Error during dashboard widget loading: ' . $e->getMessage(),
|
||||
'level' => ILogger::FATAL,
|
||||
]);
|
||||
\OC::$server->get(LoggerInterface::class)->critical(
|
||||
'Error during dashboard widget loading: ' . $e->getMessage(),
|
||||
['excepiton' => $e]
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->lazyWidgets = [];
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ namespace OC;
|
|||
|
||||
use OCP\IConfig;
|
||||
use OCP\IDateTimeZone;
|
||||
use OCP\ILogger;
|
||||
use OCP\ISession;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class DateTimeZone implements IDateTimeZone {
|
||||
/** @var IConfig */
|
||||
|
|
@ -65,7 +65,7 @@ class DateTimeZone implements IDateTimeZone {
|
|||
try {
|
||||
return new \DateTimeZone($timeZone);
|
||||
} catch (\Exception $e) {
|
||||
\OCP\Util::writeLog('datetimezone', 'Failed to created DateTimeZone "' . $timeZone . "'", ILogger::DEBUG);
|
||||
\OC::$server->get(LoggerInterface::class)->debug('Failed to created DateTimeZone "' . $timeZone . '"', ['app' => 'datetimezone']);
|
||||
return new \DateTimeZone($this->getDefaultTimeZone());
|
||||
}
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ class DateTimeZone implements IDateTimeZone {
|
|||
}
|
||||
|
||||
// No timezone found, fallback to UTC
|
||||
\OCP\Util::writeLog('datetimezone', 'Failed to find DateTimeZone for offset "' . $offset . "'", ILogger::DEBUG);
|
||||
\OC::$server->get(LoggerInterface::class)->debug('Failed to find DateTimeZone for offset "' . $offset . '"', ['app' => 'datetimezone']);
|
||||
return new \DateTimeZone($this->getDefaultTimeZone());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,14 +36,14 @@
|
|||
namespace OC\Files\Cache;
|
||||
|
||||
use Doctrine\DBAL\Exception;
|
||||
use OC\Files\Storage\Wrapper\Jail;
|
||||
use OC\Files\Storage\Wrapper\Encoding;
|
||||
use OC\Hooks\BasicEmitter;
|
||||
use OCP\Files\Cache\IScanner;
|
||||
use OCP\Files\ForbiddenException;
|
||||
use OCP\Files\Storage\IReliableEtagStorage;
|
||||
use OCP\ILogger;
|
||||
use OCP\Lock\ILockingProvider;
|
||||
use OC\Files\Storage\Wrapper\Encoding;
|
||||
use OC\Files\Storage\Wrapper\Jail;
|
||||
use OC\Hooks\BasicEmitter;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Class Scanner
|
||||
|
|
@ -115,7 +115,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 !!!", ILogger::DEBUG);
|
||||
\OC::$server->get(LoggerInterface::class)->debug("!!! Path '$path' is not accessible or present !!!", ['app' => 'core']);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
|
@ -425,7 +425,7 @@ class Scanner extends BasicEmitter implements IScanner {
|
|||
$file = trim(\OC\Files\Filesystem::normalizePath($originalFile), '/');
|
||||
if (trim($originalFile, '/') !== $file) {
|
||||
// encoding mismatch, might require compatibility wrapper
|
||||
\OC::$server->getLogger()->debug('Scanner: Skipping non-normalized file name "'. $originalFile . '" in path "' . $path . '".', ['app' => 'core']);
|
||||
\OC::$server->get(LoggerInterface::class)->debug('Scanner: Skipping non-normalized file name "'. $originalFile . '" in path "' . $path . '".', ['app' => 'core']);
|
||||
$this->emit('\OC\Files\Cache\Scanner', 'normalizedNameMismatch', [$path ? $path . '/' . $originalFile : $originalFile]);
|
||||
// skip this entry
|
||||
continue;
|
||||
|
|
@ -456,10 +456,9 @@ class Scanner extends BasicEmitter implements IScanner {
|
|||
\OC::$server->getDatabaseConnection()->rollback();
|
||||
\OC::$server->getDatabaseConnection()->beginTransaction();
|
||||
}
|
||||
\OC::$server->getLogger()->logException($ex, [
|
||||
'message' => 'Exception while scanning file "' . $child . '"',
|
||||
'level' => ILogger::DEBUG,
|
||||
\OC::$server->get(LoggerInterface::class)->debug('Exception while scanning file "' . $child . '"', [
|
||||
'app' => 'core',
|
||||
'exception' => $ex,
|
||||
]);
|
||||
$exceptionOccurred = true;
|
||||
} catch (\OCP\Lock\LockedException $e) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ use OC\Files\Storage\Storage;
|
|||
use OC\Files\Storage\StorageFactory;
|
||||
use OCP\Files\Mount\IMountPoint;
|
||||
use OCP\Files\Storage\IStorageFactory;
|
||||
use OCP\ILogger;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class MountPoint implements IMountPoint {
|
||||
/**
|
||||
|
|
@ -173,12 +173,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' => ILogger::ERROR]);
|
||||
\OC::$server->get(LoggerInterface::class)->error($exception->getMessage(), ['exception' => $exception]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
\OCP\Util::writeLog('core', 'storage backend ' . $this->class . ' not found', ILogger::ERROR);
|
||||
\OC::$server->get(LoggerInterface::class)->error('Storage backend ' . $this->class . ' not found', ['app' => 'core']);
|
||||
$this->invalidStorage = true;
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ namespace OC\Files\Mount;
|
|||
use OCP\Files\Config\IHomeMountProvider;
|
||||
use OCP\Files\Storage\IStorageFactory;
|
||||
use OCP\IConfig;
|
||||
use OCP\ILogger;
|
||||
use OCP\IUser;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Mount provider for object store home storages
|
||||
|
|
@ -80,7 +80,7 @@ class ObjectHomeMountProvider implements IHomeMountProvider {
|
|||
|
||||
// sanity checks
|
||||
if (empty($config['class'])) {
|
||||
\OCP\Util::writeLog('files', 'No class given for objectstore', ILogger::ERROR);
|
||||
\OC::$server->get(LoggerInterface::class)->error('No class given for objectstore', ['app' => 'files']);
|
||||
}
|
||||
if (!isset($config['arguments'])) {
|
||||
$config['arguments'] = [];
|
||||
|
|
@ -105,7 +105,7 @@ class ObjectHomeMountProvider implements IHomeMountProvider {
|
|||
|
||||
// sanity checks
|
||||
if (empty($config['class'])) {
|
||||
\OCP\Util::writeLog('files', 'No class given for objectstore', ILogger::ERROR);
|
||||
\OC::$server->get(LoggerInterface::class)->error('No class given for objectstore', ['app' => 'files']);
|
||||
}
|
||||
if (!isset($config['arguments'])) {
|
||||
$config['arguments'] = [];
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ use Aws\S3\S3Client;
|
|||
use GuzzleHttp\Promise;
|
||||
use GuzzleHttp\Promise\RejectedPromise;
|
||||
use OCP\ICertificateManager;
|
||||
use OCP\ILogger;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
trait S3ConnectionTrait {
|
||||
/** @var array */
|
||||
|
|
@ -150,13 +150,13 @@ trait S3ConnectionTrait {
|
|||
$this->connection = new S3Client($options);
|
||||
|
||||
if (!$this->connection::isBucketDnsCompatible($this->bucket)) {
|
||||
$logger = \OC::$server->getLogger();
|
||||
$logger = \OC::$server->get(LoggerInterface::class);
|
||||
$logger->debug('Bucket "' . $this->bucket . '" This bucket name is not dns compatible, it may contain invalid characters.',
|
||||
['app' => 'objectstore']);
|
||||
}
|
||||
|
||||
if ($this->params['verify_bucket_exists'] && !$this->connection->doesBucketExist($this->bucket)) {
|
||||
$logger = \OC::$server->getLogger();
|
||||
$logger = \OC::$server->get(LoggerInterface::class);
|
||||
try {
|
||||
$logger->info('Bucket "' . $this->bucket . '" does not exist - creating it.', ['app' => 'objectstore']);
|
||||
if (!$this->connection::isBucketDnsCompatible($this->bucket)) {
|
||||
|
|
@ -165,9 +165,8 @@ trait S3ConnectionTrait {
|
|||
$this->connection->createBucket(['Bucket' => $this->bucket]);
|
||||
$this->testTimeout();
|
||||
} catch (S3Exception $e) {
|
||||
$logger->logException($e, [
|
||||
'message' => 'Invalid remote storage.',
|
||||
'level' => ILogger::DEBUG,
|
||||
$logger->debug('Invalid remote storage.', [
|
||||
'exception' => $e,
|
||||
'app' => 'objectstore',
|
||||
]);
|
||||
throw new \Exception('Creation of bucket "' . $this->bucket . '" failed. ' . $e->getMessage());
|
||||
|
|
|
|||
|
|
@ -61,9 +61,9 @@ use OCP\Files\ReservedWordException;
|
|||
use OCP\Files\Storage\ILockingStorage;
|
||||
use OCP\Files\Storage\IStorage;
|
||||
use OCP\Files\Storage\IWriteStreamStorage;
|
||||
use OCP\ILogger;
|
||||
use OCP\Lock\ILockingProvider;
|
||||
use OCP\Lock\LockedException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Storage backend class for providing common filesystem operation methods
|
||||
|
|
@ -89,7 +89,9 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
|
|||
protected $mountOptions = [];
|
||||
protected $owner = null;
|
||||
|
||||
/** @var ?bool */
|
||||
private $shouldLogLocks = null;
|
||||
/** @var ?LoggerInterface */
|
||||
private $logger;
|
||||
|
||||
public function __construct($parameters) {
|
||||
|
|
@ -237,7 +239,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
|
|||
$target = $this->fopen($path2, 'w');
|
||||
[, $result] = \OC_Helper::streamCopy($source, $target);
|
||||
if (!$result) {
|
||||
\OC::$server->getLogger()->warning("Failed to write data while copying $path1 to $path2");
|
||||
\OC::$server->get(LoggerInterface::class)->warning("Failed to write data while copying $path1 to $path2");
|
||||
}
|
||||
$this->removeCachedFile($path2);
|
||||
return $result;
|
||||
|
|
@ -459,11 +461,13 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
|
|||
if ($this->stat('')) {
|
||||
return true;
|
||||
}
|
||||
\OC::$server->getLogger()->info("External storage not available: stat() failed");
|
||||
\OC::$server->get(LoggerInterface::class)->info("External storage not available: stat() failed");
|
||||
return false;
|
||||
} catch (\Exception $e) {
|
||||
\OC::$server->getLogger()->warning("External storage not available: " . $e->getMessage());
|
||||
\OC::$server->getLogger()->logException($e, ['level' => ILogger::WARN]);
|
||||
\OC::$server->get(LoggerInterface::class)->warning(
|
||||
"External storage not available: " . $e->getMessage(),
|
||||
['exception' => $e]
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -628,7 +632,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
|
|||
$this->writeStream($targetInternalPath, $source);
|
||||
$result = true;
|
||||
} catch (\Exception $e) {
|
||||
\OC::$server->getLogger()->logException($e, ['level' => ILogger::WARN, 'message' => 'Failed to copy stream to storage']);
|
||||
\OC::$server->get(LoggerInterface::class)->warning('Failed to copy stream to storage', ['exception' => $e]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -758,7 +762,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
|
|||
$provider->acquireLock('files/' . md5($this->getId() . '::' . trim($path, '/')), $type, $this->getId() . '::' . $path);
|
||||
} catch (LockedException $e) {
|
||||
if ($logger) {
|
||||
$logger->logException($e, ['level' => ILogger::INFO]);
|
||||
$logger->info($e->getMessage(), ['exception' => $e]);
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
|
|
@ -790,7 +794,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
|
|||
$provider->releaseLock('files/' . md5($this->getId() . '::' . trim($path, '/')), $type);
|
||||
} catch (LockedException $e) {
|
||||
if ($logger) {
|
||||
$logger->logException($e, ['level' => ILogger::INFO]);
|
||||
$logger->info($e->getMessage(), ['exception' => $e]);
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
|
|
@ -821,15 +825,17 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
|
|||
try {
|
||||
$provider->changeLock('files/' . md5($this->getId() . '::' . trim($path, '/')), $type);
|
||||
} catch (LockedException $e) {
|
||||
\OC::$server->getLogger()->logException($e, ['level' => ILogger::INFO]);
|
||||
if ($logger) {
|
||||
$logger->info($e->getMessage(), ['exception' => $e]);
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
private function getLockLogger() {
|
||||
private function getLockLogger(): ?LoggerInterface {
|
||||
if (is_null($this->shouldLogLocks)) {
|
||||
$this->shouldLogLocks = \OC::$server->getConfig()->getSystemValue('filelocking.debug', false);
|
||||
$this->logger = $this->shouldLogLocks ? \OC::$server->getLogger() : null;
|
||||
$this->logger = $this->shouldLogLocks ? \OC::$server->get(LoggerInterface::class) : null;
|
||||
}
|
||||
return $this->logger;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,13 +50,12 @@ use OCP\Files\StorageInvalidException;
|
|||
use OCP\Files\StorageNotAvailableException;
|
||||
use OCP\Http\Client\IClientService;
|
||||
use OCP\ICertificateManager;
|
||||
use OCP\ILogger;
|
||||
use OCP\Util;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Sabre\DAV\Client;
|
||||
use Sabre\DAV\Xml\Property\ResourceType;
|
||||
use Sabre\HTTP\ClientException;
|
||||
use Sabre\HTTP\ClientHttpException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Class DAV
|
||||
|
|
@ -370,7 +369,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(), ILogger::ERROR);
|
||||
\OC::$server->get(LoggerInterface::class)->error('Guzzle get returned status code ' . $response->getStatusCode(), ['app' => 'webdav client']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -843,7 +842,7 @@ class DAV extends Common {
|
|||
* @throws ForbiddenException if the action is not allowed
|
||||
*/
|
||||
protected function convertException(Exception $e, $path = '') {
|
||||
\OC::$server->getLogger()->logException($e, ['app' => 'files_external', 'level' => ILogger::DEBUG]);
|
||||
\OC::$server->get(LoggerInterface::class)->debug($e->getMessage(), ['app' => 'files_external', 'exception' => $e]);
|
||||
if ($e instanceof ClientHttpException) {
|
||||
if ($e->getHttpStatus() === Http::STATUS_LOCKED) {
|
||||
throw new \OCP\Lock\LockedException($path);
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ use OCP\Files\GenericFileException;
|
|||
use OCP\Files\IMimeTypeDetector;
|
||||
use OCP\Files\Storage\IStorage;
|
||||
use OCP\IConfig;
|
||||
use OCP\ILogger;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* for local filestore, we only have to map the paths
|
||||
|
|
@ -323,17 +323,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, ILogger::ERROR);
|
||||
\OC::$server->get(LoggerInterface::class)->error('unable to rename, source directory is not writable : ' . $srcParent, ['app' => 'core']);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$this->isUpdatable($dstParent)) {
|
||||
\OCP\Util::writeLog('core', 'unable to rename, destination directory is not writable : ' . $dstParent, ILogger::ERROR);
|
||||
\OC::$server->get(LoggerInterface::class)->error('unable to rename, destination directory is not writable : ' . $dstParent, ['app' => 'core']);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$this->file_exists($path1)) {
|
||||
\OCP\Util::writeLog('core', 'unable to rename, file does not exists : ' . $path1, ILogger::ERROR);
|
||||
\OC::$server->get(LoggerInterface::class)->error('unable to rename, file does not exists : ' . $path1, ['app' => 'core']);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -484,7 +484,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}')", ILogger::ERROR);
|
||||
\OC::$server->get(LoggerInterface::class)->error("Following symlinks is not allowed ('$fullPath' -> '$realPath' not inside '{$this->realDataDir}')", ['app' => 'core']);
|
||||
throw new ForbiddenException('Following symlinks is not allowed', false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,10 +64,10 @@ use OCP\Files\Mount\IMountPoint;
|
|||
use OCP\Files\NotFoundException;
|
||||
use OCP\Files\ReservedWordException;
|
||||
use OCP\Files\Storage\IStorage;
|
||||
use OCP\ILogger;
|
||||
use OCP\IUser;
|
||||
use OCP\Lock\ILockingProvider;
|
||||
use OCP\Lock\LockedException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Class to provide access to ownCloud filesystem via a "view", and methods for
|
||||
|
|
@ -101,8 +101,7 @@ class View {
|
|||
/** @var \OC\User\Manager */
|
||||
private $userManager;
|
||||
|
||||
/** @var \OCP\ILogger */
|
||||
private $logger;
|
||||
private LoggerInterface $logger;
|
||||
|
||||
private DisplayNameCache $displayNameCache;
|
||||
|
||||
|
|
@ -123,7 +122,7 @@ class View {
|
|||
$this->lockingEnabled = !($this->lockingProvider instanceof \OC\Lock\NoopLockingProvider);
|
||||
$this->userManager = \OC::$server->getUserManager();
|
||||
$this->displayNameCache = \OC::$server->get(DisplayNameCache::class);
|
||||
$this->logger = \OC::$server->getLogger();
|
||||
$this->logger = \OC::$server->get(LoggerInterface::class);
|
||||
}
|
||||
|
||||
public function getAbsolutePath($path = '/') {
|
||||
|
|
@ -579,7 +578,7 @@ class View {
|
|||
try {
|
||||
$result = $this->basicOperation('touch', $path, $hooks, $mtime);
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->logException($e, ['level' => ILogger::INFO, 'message' => 'Error while setting modified time']);
|
||||
$this->logger->info('Error while setting modified time', ['app' => 'core', 'exception' => $e]);
|
||||
$result = false;
|
||||
}
|
||||
if (!$result) {
|
||||
|
|
@ -1000,11 +999,11 @@ class View {
|
|||
$hooks[] = 'write';
|
||||
break;
|
||||
default:
|
||||
\OCP\Util::writeLog('core', 'invalid mode (' . $mode . ') for ' . $path, ILogger::ERROR);
|
||||
$this->logger->error('invalid mode (' . $mode . ') for ' . $path, ['app' => 'core']);
|
||||
}
|
||||
|
||||
if ($mode !== 'r' && $mode !== 'w') {
|
||||
\OC::$server->getLogger()->info('Trying to open a file with a mode other than "r" or "w" can cause severe performance issues with some backends');
|
||||
$this->logger->info('Trying to open a file with a mode other than "r" or "w" can cause severe performance issues with some backends', ['app' => 'core']);
|
||||
}
|
||||
|
||||
return $this->basicOperation('fopen', $path, $hooks, $mode);
|
||||
|
|
@ -1418,7 +1417,7 @@ class View {
|
|||
|
||||
return $info;
|
||||
} else {
|
||||
\OC::$server->getLogger()->warning('Storage not valid for mountpoint: ' . $mount->getMountPoint());
|
||||
$this->logger->warning('Storage not valid for mountpoint: ' . $mount->getMountPoint(), ['app' => 'core']);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -1502,10 +1501,9 @@ class View {
|
|||
continue;
|
||||
} catch (\Exception $e) {
|
||||
// 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' => ILogger::ERROR,
|
||||
'app' => 'lib',
|
||||
$this->logger->error('Exception while scanning storage "' . $subStorage->getId() . '"', [
|
||||
'exception' => $e,
|
||||
'app' => 'core',
|
||||
]);
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1816,9 +1814,9 @@ class View {
|
|||
);
|
||||
|
||||
if (count($shares) > 0) {
|
||||
\OCP\Util::writeLog('files',
|
||||
$this->logger->debug(
|
||||
'It is not allowed to move one mount point into a shared folder',
|
||||
ILogger::DEBUG);
|
||||
['app' => 'files']);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -2146,9 +2144,9 @@ class View {
|
|||
// "$user", "files", "path/to/dir"
|
||||
if (!isset($parts[1]) || $parts[1] !== 'files') {
|
||||
$this->logger->error(
|
||||
'$absolutePath must be relative to "files", value is "%s"',
|
||||
'$absolutePath must be relative to "files", value is "{absolutePath}"',
|
||||
[
|
||||
$absolutePath
|
||||
'absolutePath' => $absolutePath,
|
||||
]
|
||||
);
|
||||
throw new \InvalidArgumentException('$absolutePath must be relative to "files"');
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ use OC_Helper;
|
|||
use OCP\HintException;
|
||||
use OCP\Http\Client\IClientService;
|
||||
use OCP\IConfig;
|
||||
use OCP\ILogger;
|
||||
use OCP\ITempManager;
|
||||
use phpseclib\File\X509;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
|
@ -501,7 +500,7 @@ class Installer {
|
|||
OC_Helper::rmdirr($appDir);
|
||||
return true;
|
||||
} else {
|
||||
\OCP\Util::writeLog('core', 'can\'t remove app '.$appId.'. It is not installed.', ILogger::ERROR);
|
||||
$this->logger->error('can\'t remove app '.$appId.'. It is not installed.');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
namespace OC;
|
||||
|
||||
use OCP\ILogger;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class NaturalSort {
|
||||
private static $instance;
|
||||
|
|
@ -42,7 +42,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), ILogger::DEBUG);
|
||||
\OC::$server->get(LoggerInterface::class)->debug('forced use of '.get_class($injectedCollator));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace OC\Preview;
|
|||
use OCP\Files\File;
|
||||
use OCP\Files\FileInfo;
|
||||
use OCP\IImage;
|
||||
use OCP\ILogger;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
abstract class Office extends ProviderV2 {
|
||||
/**
|
||||
|
|
@ -76,8 +76,8 @@ abstract class Office extends ProviderV2 {
|
|||
} catch (\Exception $e) {
|
||||
$this->cleanTmpFiles();
|
||||
unlink($pngPreview);
|
||||
\OC::$server->getLogger()->logException($e, [
|
||||
'level' => ILogger::ERROR,
|
||||
\OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [
|
||||
'exception' => $e,
|
||||
'app' => 'core',
|
||||
]);
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace OC\Preview;
|
|||
|
||||
use OCP\Files\File;
|
||||
use OCP\IImage;
|
||||
use OCP\ILogger;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class SVG extends ProviderV2 {
|
||||
/**
|
||||
|
|
@ -60,8 +60,8 @@ class SVG extends ProviderV2 {
|
|||
$svg->readImageBlob($content);
|
||||
$svg->setImageFormat('png32');
|
||||
} catch (\Exception $e) {
|
||||
\OC::$server->getLogger()->logException($e, [
|
||||
'level' => ILogger::ERROR,
|
||||
\OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [
|
||||
'exception' => $e,
|
||||
'app' => 'core',
|
||||
]);
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -1,77 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
||||
*
|
||||
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
|
||||
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
* @author J0WI <J0WI@users.noreply.github.com>
|
||||
* @author Morris Jobke <hey@morrisjobke.de>
|
||||
* @author Robin McCorkell <robin@mccorkell.me.uk>
|
||||
*
|
||||
* @license AGPL-3.0
|
||||
*
|
||||
* This code is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License, version 3,
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*/
|
||||
namespace OC\Share;
|
||||
|
||||
use OCP\ILogger;
|
||||
|
||||
class SearchResultSorter {
|
||||
private $search;
|
||||
private $encoding;
|
||||
private $key;
|
||||
private $log;
|
||||
|
||||
/**
|
||||
* @param string $search the search term as was given by the user
|
||||
* @param string $key the array key containing the value that should be compared
|
||||
* against
|
||||
* @param string $encoding optional, encoding to use, defaults to UTF-8
|
||||
* @param ILogger $log optional
|
||||
*/
|
||||
public function __construct($search, $key, ILogger $log = null, $encoding = 'UTF-8') {
|
||||
$this->encoding = $encoding;
|
||||
$this->key = $key;
|
||||
$this->log = $log;
|
||||
$this->search = mb_strtolower($search, $this->encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* User and Group names matching the search term at the beginning shall appear
|
||||
* on top of the share dialog. Following entries in alphabetical order.
|
||||
* Callback function for usort. https://www.php.net/usort
|
||||
*/
|
||||
public function sort($a, $b) {
|
||||
if (!isset($a[$this->key]) || !isset($b[$this->key])) {
|
||||
if (!is_null($this->log)) {
|
||||
$this->log->error('Sharing dialogue: cannot sort due to ' .
|
||||
'missing array key', ['app' => 'core']);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
$nameA = mb_strtolower($a[$this->key], $this->encoding);
|
||||
$nameB = mb_strtolower($b[$this->key], $this->encoding);
|
||||
$i = mb_strpos($nameA, $this->search, 0, $this->encoding);
|
||||
$j = mb_strpos($nameB, $this->search, 0, $this->encoding);
|
||||
|
||||
if ($i === $j || $i > 0 && $j > 0) {
|
||||
return strcmp(mb_strtolower($nameA, $this->encoding),
|
||||
mb_strtolower($nameB, $this->encoding));
|
||||
} elseif ($i === 0) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -35,8 +35,8 @@
|
|||
namespace OC\Share;
|
||||
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCP\ILogger;
|
||||
use OCP\Share\IShare;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* This class provides the ability for apps to share their content between users.
|
||||
|
|
@ -80,10 +80,10 @@ class Share extends Constants {
|
|||
];
|
||||
return true;
|
||||
}
|
||||
\OCP\Util::writeLog('OCP\Share',
|
||||
\OC::$server->get(LoggerInterface::class)->warning(
|
||||
'Sharing backend '.$class.' not registered, '.self::$backendTypes[$itemType]['class']
|
||||
.' is already registered for '.$itemType,
|
||||
ILogger::WARN);
|
||||
['app' => 'OCP\Share']);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -256,6 +256,7 @@ class Share extends Constants {
|
|||
*/
|
||||
public static function getBackend($itemType) {
|
||||
$l = \OC::$server->getL10N('lib');
|
||||
$logger = \OC::$server->get(LoggerInterface::class);
|
||||
if (isset(self::$backends[$itemType])) {
|
||||
return self::$backends[$itemType];
|
||||
} elseif (isset(self::$backendTypes[$itemType]['class'])) {
|
||||
|
|
@ -265,20 +266,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', [$class]);
|
||||
\OCP\Util::writeLog('OCP\Share', sprintf($message, $class), ILogger::ERROR);
|
||||
$logger->error(sprintf($message, $class), ['app' => 'OCP\Share']);
|
||||
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', [$class]);
|
||||
\OCP\Util::writeLog('OCP\Share', sprintf($message, $class), ILogger::ERROR);
|
||||
$logger->error(sprintf($message, $class), ['app' => 'OCP\Share']);
|
||||
throw new \Exception($message_t);
|
||||
}
|
||||
}
|
||||
$message = 'Sharing backend for %s not found';
|
||||
$message_t = $l->t('Sharing backend for %s not found', [$itemType]);
|
||||
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemType), ILogger::ERROR);
|
||||
$logger->error(sprintf($message, $itemType), ['app' => 'OCP\Share']);
|
||||
throw new \Exception($message_t);
|
||||
}
|
||||
|
||||
|
|
@ -482,9 +483,9 @@ class Share extends Constants {
|
|||
$query = \OC_DB::prepare('SELECT '.$select.' FROM `*PREFIX*share` '.$where, $queryLimit);
|
||||
$result = $query->execute($queryArgs);
|
||||
if ($result === false) {
|
||||
\OCP\Util::writeLog('OCP\Share',
|
||||
\OC::$server->get(LoggerInterface::class)->error(
|
||||
\OC_DB::getErrorMessage() . ', select=' . $select . ' where=',
|
||||
ILogger::ERROR);
|
||||
['app' => 'OCP\Share']);
|
||||
}
|
||||
$items = [];
|
||||
$targets = [];
|
||||
|
|
@ -552,9 +553,10 @@ class Share extends Constants {
|
|||
$parentResult->closeCursor();
|
||||
|
||||
if ($parentRow === false) {
|
||||
\OCP\Util::writeLog('OCP\Share', 'Can\'t select parent: ' .
|
||||
\OC::$server->get(LoggerInterface::class)->error(
|
||||
'Can\'t select parent: ' .
|
||||
\OC_DB::getErrorMessage() . ', select=' . $select . ' where=' . $where,
|
||||
ILogger::ERROR);
|
||||
['app' => 'OCP\Share']);
|
||||
} else {
|
||||
$tmpPath = $parentRow['file_target'];
|
||||
// find the right position where the row path continues from the target path
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@ namespace OC\Support\CrashReport;
|
|||
|
||||
use Exception;
|
||||
use OCP\AppFramework\QueryException;
|
||||
use OCP\ILogger;
|
||||
use OCP\IServerContainer;
|
||||
use OCP\Support\CrashReport\ICollectBreadcrumbs;
|
||||
use OCP\Support\CrashReport\IMessageReporter;
|
||||
use OCP\Support\CrashReport\IRegistry;
|
||||
use OCP\Support\CrashReport\IReporter;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Throwable;
|
||||
use function array_shift;
|
||||
|
||||
|
|
@ -48,9 +48,6 @@ class Registry implements IRegistry {
|
|||
/** @var IServerContainer */
|
||||
private $serverContainer;
|
||||
|
||||
/** @var ILogger */
|
||||
private $logger;
|
||||
|
||||
public function __construct(IServerContainer $serverContainer) {
|
||||
$this->serverContainer = $serverContainer;
|
||||
}
|
||||
|
|
@ -129,9 +126,8 @@ class Registry implements IRegistry {
|
|||
* There is a circular dependency between the logger and the registry, so
|
||||
* we can not inject it. Thus the static call.
|
||||
*/
|
||||
\OC::$server->getLogger()->logException($e, [
|
||||
'message' => 'Could not load lazy crash reporter: ' . $e->getMessage(),
|
||||
'level' => ILogger::FATAL,
|
||||
\OC::$server->get(LoggerInterface::class)->critical('Could not load lazy crash reporter: ' . $e->getMessage(), [
|
||||
'exception' => $e,
|
||||
]);
|
||||
}
|
||||
/**
|
||||
|
|
@ -145,9 +141,8 @@ class Registry implements IRegistry {
|
|||
* There is a circular dependency between the logger and the registry, so
|
||||
* we can not inject it. Thus the static call.
|
||||
*/
|
||||
\OC::$server->getLogger()->logException($e, [
|
||||
'message' => 'Could not register lazy crash reporter: ' . $e->getMessage(),
|
||||
'level' => ILogger::FATAL,
|
||||
\OC::$server->get(LoggerInterface::class)->critical('Could not register lazy crash reporter: ' . $e->getMessage(), [
|
||||
'exception' => $e,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* ownCloud
|
||||
*
|
||||
* @author Arthur Schiwon
|
||||
* @copyright 2014 Arthur Schiwon <blizzz@owncloud.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Test\Share;
|
||||
|
||||
class SearchResultSorterTest extends \Test\TestCase {
|
||||
public function testSort() {
|
||||
$search = 'lin';
|
||||
$sorter = new \OC\Share\SearchResultSorter($search, 'foobar');
|
||||
|
||||
$result = [
|
||||
['foobar' => 'woot'],
|
||||
['foobar' => 'linux'],
|
||||
['foobar' => 'Linus'],
|
||||
['foobar' => 'Bicyclerepairwoman'],
|
||||
];
|
||||
|
||||
usort($result, [$sorter, 'sort']);
|
||||
$this->assertTrue($result[0]['foobar'] === 'Linus');
|
||||
$this->assertTrue($result[1]['foobar'] === 'linux');
|
||||
$this->assertTrue($result[2]['foobar'] === 'Bicyclerepairwoman');
|
||||
$this->assertTrue($result[3]['foobar'] === 'woot');
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue