aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib/User
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2021-11-09 15:11:15 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2021-11-09 15:11:15 +0100
commit6b960de47cabaa7a231e72479012ba4dcbc2e882 (patch)
tree362d7052250df7f8ec341f9035f4320666a9e748 /apps/user_ldap/lib/User
parent81b60c14c985b0a46fd31733db2add9efd7bedba (diff)
downloadnextcloud-server-6b960de47cabaa7a231e72479012ba4dcbc2e882.tar.gz
nextcloud-server-6b960de47cabaa7a231e72479012ba4dcbc2e882.zip
Get rid of LogWrapper calling deprecated logger and use LoggerInterface from PSR instead
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/user_ldap/lib/User')
-rw-r--r--apps/user_ldap/lib/User/Manager.php12
-rw-r--r--apps/user_ldap/lib/User/User.php34
2 files changed, 19 insertions, 27 deletions
diff --git a/apps/user_ldap/lib/User/Manager.php b/apps/user_ldap/lib/User/Manager.php
index 87f75f093db..63af3cf1770 100644
--- a/apps/user_ldap/lib/User/Manager.php
+++ b/apps/user_ldap/lib/User/Manager.php
@@ -31,7 +31,6 @@ namespace OCA\User_LDAP\User;
use OC\Cache\CappedMemoryCache;
use OCA\User_LDAP\Access;
use OCA\User_LDAP\FilesystemHelper;
-use OCA\User_LDAP\LogWrapper;
use OCP\IAvatarManager;
use OCP\IConfig;
use OCP\IDBConnection;
@@ -39,6 +38,7 @@ use OCP\Image;
use OCP\IUserManager;
use OCP\Notification\IManager as INotificationManager;
use OCP\Share\IManager;
+use Psr\Log\LoggerInterface;
/**
* Manager
@@ -65,8 +65,8 @@ class Manager {
/** @var FilesystemHelper */
protected $ocFilesystem;
- /** @var LogWrapper */
- protected $ocLog;
+ /** @var LoggerInterface */
+ protected $logger;
/** @var Image */
protected $image;
@@ -88,7 +88,7 @@ class Manager {
public function __construct(
IConfig $ocConfig,
FilesystemHelper $ocFilesystem,
- LogWrapper $ocLog,
+ LoggerInterface $logger,
IAvatarManager $avatarManager,
Image $image,
IUserManager $userManager,
@@ -97,7 +97,7 @@ class Manager {
) {
$this->ocConfig = $ocConfig;
$this->ocFilesystem = $ocFilesystem;
- $this->ocLog = $ocLog;
+ $this->logger = $logger;
$this->avatarManager = $avatarManager;
$this->image = $image;
$this->userManager = $userManager;
@@ -126,7 +126,7 @@ class Manager {
private function createAndCache($dn, $uid) {
$this->checkAccess();
$user = new User($uid, $dn, $this->access, $this->ocConfig,
- $this->ocFilesystem, clone $this->image, $this->ocLog,
+ $this->ocFilesystem, clone $this->image, $this->logger,
$this->avatarManager, $this->userManager,
$this->notificationManager);
$this->usersByDN[$dn] = $user;
diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php
index b09fbd18327..431009f047a 100644
--- a/apps/user_ldap/lib/User/User.php
+++ b/apps/user_ldap/lib/User/User.php
@@ -35,7 +35,6 @@ use OCA\User_LDAP\Access;
use OCA\User_LDAP\Connection;
use OCA\User_LDAP\Exceptions\AttributeNotSet;
use OCA\User_LDAP\FilesystemHelper;
-use OCA\User_LDAP\LogWrapper;
use OCP\IAvatarManager;
use OCP\IConfig;
use OCP\ILogger;
@@ -43,6 +42,7 @@ use OCP\Image;
use OCP\IUser;
use OCP\IUserManager;
use OCP\Notification\IManager as INotificationManager;
+use Psr\Log\LoggerInterface;
/**
* User
@@ -71,9 +71,9 @@ class User {
*/
protected $image;
/**
- * @var LogWrapper
+ * @var LoggerInterface
*/
- protected $log;
+ private $logger;
/**
* @var IAvatarManager
*/
@@ -112,24 +112,16 @@ class User {
* @brief constructor, make sure the subclasses call this one!
* @param string $username the internal username
* @param string $dn the LDAP DN
- * @param Access $access
- * @param IConfig $config
- * @param FilesystemHelper $fs
- * @param Image $image any empty instance
- * @param LogWrapper $log
- * @param IAvatarManager $avatarManager
- * @param IUserManager $userManager
- * @param INotificationManager $notificationManager
*/
public function __construct($username, $dn, Access $access,
IConfig $config, FilesystemHelper $fs, Image $image,
- LogWrapper $log, IAvatarManager $avatarManager, IUserManager $userManager,
+ LoggerInterface $logger, IAvatarManager $avatarManager, IUserManager $userManager,
INotificationManager $notificationManager) {
if ($username === null) {
- $log->log("uid for '$dn' must not be null!", ILogger::ERROR);
+ $logger->error("uid for '$dn' must not be null!", ['app' => 'user_ldap']);
throw new \InvalidArgumentException('uid must not be null!');
} elseif ($username === '') {
- $log->log("uid for '$dn' must not be an empty string", ILogger::ERROR);
+ $logger->error("uid for '$dn' must not be an empty string", ['app' => 'user_ldap']);
throw new \InvalidArgumentException('uid must not be an empty string!');
}
@@ -140,7 +132,7 @@ class User {
$this->dn = $dn;
$this->uid = $username;
$this->image = $image;
- $this->log = $log;
+ $this->logger = $logger;
$this->avatarManager = $avatarManager;
$this->userManager = $userManager;
$this->notificationManager = $notificationManager;
@@ -493,19 +485,19 @@ class User {
if ($aQuota && (count($aQuota) > 0) && $this->verifyQuotaValue($aQuota[0])) {
$quota = $aQuota[0];
} elseif (is_array($aQuota) && isset($aQuota[0])) {
- $this->log->log('no suitable LDAP quota found for user ' . $this->uid . ': [' . $aQuota[0] . ']', ILogger::DEBUG);
+ $this->logger->debug('no suitable LDAP quota found for user ' . $this->uid . ': [' . $aQuota[0] . ']', ['app' => 'user_ldap']);
}
} elseif ($this->verifyQuotaValue($valueFromLDAP)) {
$quota = $valueFromLDAP;
} else {
- $this->log->log('no suitable LDAP quota found for user ' . $this->uid . ': [' . $valueFromLDAP . ']', ILogger::DEBUG);
+ $this->logger->debug('no suitable LDAP quota found for user ' . $this->uid . ': [' . $valueFromLDAP . ']', ['app' => 'user_ldap']);
}
if ($quota === false && $this->verifyQuotaValue($defaultQuota)) {
// quota not found using the LDAP attribute (or not parseable). Try the default quota
$quota = $defaultQuota;
} elseif ($quota === false) {
- $this->log->log('no suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', ILogger::DEBUG);
+ $this->logger->debug('no suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', ['app' => 'user_ldap']);
return;
}
@@ -513,7 +505,7 @@ class User {
if ($targetUser instanceof IUser) {
$targetUser->setQuota($quota);
} else {
- $this->log->log('trying to set a quota for user ' . $this->uid . ' but the user is missing', ILogger::INFO);
+ $this->logger->info('trying to set a quota for user ' . $this->uid . ' but the user is missing', ['app' => 'user_ldap']);
}
}
@@ -573,7 +565,7 @@ class User {
*/
private function setOwnCloudAvatar() {
if (!$this->image->valid()) {
- $this->log->log('avatar image data from LDAP invalid for '.$this->dn, ILogger::ERROR);
+ $this->logger->error('avatar image data from LDAP invalid for '.$this->dn, ['app' => 'user_ldap']);
return false;
}
@@ -581,7 +573,7 @@ class User {
//make sure it is a square and not bigger than 128x128
$size = min([$this->image->width(), $this->image->height(), 128]);
if (!$this->image->centerCrop($size)) {
- $this->log->log('croping image for avatar failed for '.$this->dn, ILogger::ERROR);
+ $this->logger->error('croping image for avatar failed for '.$this->dn, ['app' => 'user_ldap']);
return false;
}