diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2018-04-25 15:22:28 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2018-04-26 10:45:52 +0200 |
commit | 38a90130ce425d531a804dff591df4a883de3154 (patch) | |
tree | d579e7442832672ab2987f9c9ecf62e79ca09a8d /apps | |
parent | 12c5db90322f61d4d48e1bb534bb94382d17e317 (diff) | |
download | nextcloud-server-38a90130ce425d531a804dff591df4a883de3154.tar.gz nextcloud-server-38a90130ce425d531a804dff591df4a883de3154.zip |
move log constants to ILogger
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps')
26 files changed, 167 insertions, 134 deletions
diff --git a/apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php b/apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php index 1678a8831dc..ecfd0e5692d 100644 --- a/apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php +++ b/apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php @@ -108,14 +108,14 @@ class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin { */ public function logException(\Exception $ex) { $exceptionClass = get_class($ex); - $level = \OCP\Util::FATAL; + $level = ILogger::FATAL; if (isset($this->nonFatalExceptions[$exceptionClass]) || ( $exceptionClass === ServiceUnavailable::class && $ex->getMessage() === 'System in maintenance mode.' ) ) { - $level = \OCP\Util::DEBUG; + $level = ILogger::DEBUG; } $this->logger->logException($ex, [ diff --git a/apps/encryption/lib/KeyManager.php b/apps/encryption/lib/KeyManager.php index d1776cbe50c..c66afc1ffc5 100644 --- a/apps/encryption/lib/KeyManager.php +++ b/apps/encryption/lib/KeyManager.php @@ -374,7 +374,7 @@ class KeyManager { } catch (\Exception $e) { $this->log->logException($e, [ 'message' => 'Could not decrypt the private key from user "' . $uid . '"" during login. Assume password change on the user back-end.', - 'level' => \OCP\Util::WARN, + 'level' => ILogger::WARN, 'app' => 'encryption', ]); return false; diff --git a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php index 8d27f13bb9b..d54f24d97fe 100644 --- a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php +++ b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php @@ -42,6 +42,7 @@ use OCP\Federation\ICloudIdManager; use OCP\Files\StorageInvalidException; use OCP\Http\Client\IClientService; use OCP\IL10N; +use OCP\ILogger; use OCP\IRequest; use OCP\ISession; use OCP\IUserSession; @@ -165,7 +166,7 @@ class MountPublicLinkController extends Controller { $this->federatedShareProvider->create($share); } catch (\Exception $e) { \OC::$server->getLogger()->logException($e, [ - 'level' => \OCP\Util::WARN, + 'level' => ILogger::WARN, 'app' => 'federatedfilesharing', ]); return new JSONResponse(['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST); diff --git a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php index caf9e329abd..422f12dda2e 100644 --- a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php +++ b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php @@ -217,7 +217,7 @@ class RequestHandlerController extends OCSController { } catch (\Exception $e) { $this->logger->logException($e, [ 'message' => 'Server can not add remote share.', - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'files_sharing' ]); throw new OCSException('internal server error, was not able to add share from ' . $remote, 500); diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index 6857dd48e98..ecc1e1710b8 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -266,7 +266,7 @@ class FederatedShareProvider implements IShareProvider { } catch (\Exception $e) { $this->logger->logException($e, [ 'message' => 'Failed to notify remote server of federated share, removing share.', - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'federatedfilesharing', ]); $failure = true; diff --git a/apps/federation/lib/BackgroundJob/GetSharedSecret.php b/apps/federation/lib/BackgroundJob/GetSharedSecret.php index 6f901062aca..30b04c5b123 100644 --- a/apps/federation/lib/BackgroundJob/GetSharedSecret.php +++ b/apps/federation/lib/BackgroundJob/GetSharedSecret.php @@ -194,14 +194,14 @@ class GetSharedSecret extends Job { $status = -1; // There is no status code if we could not connect $this->logger->logException($e, [ 'message' => 'Could not connect to ' . $target, - 'level' => \OCP\Util::INFO, + 'level' => ILogger::INFO, 'app' => 'federation', ]); } catch (RingException $e) { $status = -1; // There is no status code if we could not connect $this->logger->logException($e, [ 'message' => 'Could not connect to ' . $target, - 'level' => \OCP\Util::INFO, + 'level' => ILogger::INFO, 'app' => 'federation', ]); } catch (\Exception $e) { diff --git a/apps/federation/lib/Middleware/AddServerMiddleware.php b/apps/federation/lib/Middleware/AddServerMiddleware.php index c6ac42bd7c3..09335a0cdff 100644 --- a/apps/federation/lib/Middleware/AddServerMiddleware.php +++ b/apps/federation/lib/Middleware/AddServerMiddleware.php @@ -72,7 +72,7 @@ class AddServerMiddleware extends Middleware { throw $exception; } $this->logger->logException($exception, [ - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => $this->appName, ]); if ($exception instanceof HintException) { diff --git a/apps/federation/lib/SyncJob.php b/apps/federation/lib/SyncJob.php index 258d0f2fc9c..6eaaf13944d 100644 --- a/apps/federation/lib/SyncJob.php +++ b/apps/federation/lib/SyncJob.php @@ -50,7 +50,7 @@ class SyncJob extends TimedJob { if ($ex instanceof \Exception) { $this->logger->logException($ex, [ 'message' => "Error while syncing $url.", - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'fed-sync', ]); } diff --git a/apps/federation/lib/TrustedServers.php b/apps/federation/lib/TrustedServers.php index eda77a79325..092279eb2b9 100644 --- a/apps/federation/lib/TrustedServers.php +++ b/apps/federation/lib/TrustedServers.php @@ -244,7 +244,7 @@ class TrustedServers { } catch (\Exception $e) { \OC::$server->getLogger()->logException($e, [ 'message' => 'No Nextcloud server.', - 'level' => \OCP\Util::DEBUG, + 'level' => ILogger::DEBUG, 'app' => 'federation', ]); return false; diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php index 12ab6b0fed8..a533298c06d 100644 --- a/apps/files_external/lib/Lib/Storage/SMB.php +++ b/apps/files_external/lib/Lib/Storage/SMB.php @@ -52,6 +52,7 @@ use OCP\Files\Notify\IChange; use OCP\Files\Notify\IRenameChange; use OCP\Files\Storage\INotifyStorage; use OCP\Files\StorageNotAvailableException; +use OCP\ILogger; use OCP\Util; class SMB extends Common implements INotifyStorage { @@ -202,7 +203,7 @@ class SMB extends Common implements INotifyStorage { $this->remove($target); $result = $this->share->rename($absoluteSource, $absoluteTarget); } catch (\Exception $e) { - \OC::$server->getLogger()->logException($e, ['level' => Util::WARN]); + \OC::$server->getLogger()->logException($e, ['level' => ILogger::WARN]); return false; } unset($this->statCache[$absoluteSource], $this->statCache[$absoluteTarget]); diff --git a/apps/files_external/lib/Lib/Storage/Swift.php b/apps/files_external/lib/Lib/Storage/Swift.php index 4fcd60a797d..689fd700253 100644 --- a/apps/files_external/lib/Lib/Storage/Swift.php +++ b/apps/files_external/lib/Lib/Storage/Swift.php @@ -45,6 +45,7 @@ use Icewind\Streams\CallbackWrapper; use Icewind\Streams\IteratorDirectory; use OC\Files\ObjectStore\SwiftFactory; use OCP\Files\StorageBadConfigException; +use OCP\ILogger; use OpenStack\Common\Error\BadResponseError; use OpenStack\ObjectStore\v1\Models\StorageObject; @@ -132,7 +133,7 @@ class Swift extends \OC\Files\Storage\Common { // Expected response is "404 Not Found", so only log if it isn't if ($e->getResponse()->getStatusCode() !== 404) { \OC::$server->getLogger()->logException($e, [ - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'files_external', ]); } @@ -225,7 +226,7 @@ class Swift extends \OC\Files\Storage\Common { $this->objectCache->remove($path); } catch (BadResponseError $e) { \OC::$server->getLogger()->logException($e, [ - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'files_external', ]); return false; @@ -269,7 +270,7 @@ class Swift extends \OC\Files\Storage\Common { $this->objectCache->remove($path . '/'); } catch (BadResponseError $e) { \OC::$server->getLogger()->logException($e, [ - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'files_external', ]); return false; @@ -307,7 +308,7 @@ class Swift extends \OC\Files\Storage\Common { return IteratorDirectory::wrap($files); } catch (\Exception $e) { \OC::$server->getLogger()->logException($e, [ - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'files_external', ]); return false; @@ -331,7 +332,7 @@ class Swift extends \OC\Files\Storage\Common { } } catch (BadResponseError $e) { \OC::$server->getLogger()->logException($e, [ - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'files_external', ]); return false; @@ -385,7 +386,7 @@ class Swift extends \OC\Files\Storage\Common { } catch (BadResponseError $e) { if ($e->getResponse()->getStatusCode() !== 404) { \OC::$server->getLogger()->logException($e, [ - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'files_external', ]); throw $e; @@ -409,7 +410,7 @@ class Swift extends \OC\Files\Storage\Common { return $this->objectStore->readObject($path); } catch (BadResponseError $e) { \OC::$server->getLogger()->logException($e, [ - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'files_external', ]); return false; @@ -496,7 +497,7 @@ class Swift extends \OC\Files\Storage\Common { $this->objectCache->remove($path2 . '/'); } catch (BadResponseError $e) { \OC::$server->getLogger()->logException($e, [ - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'files_external', ]); return false; @@ -513,7 +514,7 @@ class Swift extends \OC\Files\Storage\Common { $this->objectCache->remove($path2 . '/'); } catch (BadResponseError $e) { \OC::$server->getLogger()->logException($e, [ - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'files_external', ]); return false; diff --git a/apps/files_external/lib/Service/LegacyStoragesService.php b/apps/files_external/lib/Service/LegacyStoragesService.php index f1bd0b753ae..2b681757806 100644 --- a/apps/files_external/lib/Service/LegacyStoragesService.php +++ b/apps/files_external/lib/Service/LegacyStoragesService.php @@ -25,6 +25,7 @@ namespace OCA\Files_External\Service; use OCA\Files_External\Lib\StorageConfig; +use OCP\ILogger; /** * Read mount config from legacy mount.json @@ -190,7 +191,7 @@ abstract class LegacyStoragesService { // don't die if a storage backend doesn't exist \OC::$server->getLogger()->logException($e, [ 'message' => 'Could not load storage.', - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'files_external', ]); } diff --git a/apps/files_external/lib/Service/StoragesService.php b/apps/files_external/lib/Service/StoragesService.php index 89458b70c0c..79eb03cea21 100644 --- a/apps/files_external/lib/Service/StoragesService.php +++ b/apps/files_external/lib/Service/StoragesService.php @@ -37,6 +37,7 @@ use \OCA\Files_External\Lib\Backend\Backend; use \OCA\Files_External\Lib\Auth\AuthMechanism; use OCP\Files\Config\IUserMountCache; use \OCP\Files\StorageNotAvailableException; +use OCP\ILogger; /** * Service class to manage external storages @@ -104,14 +105,14 @@ abstract class StoragesService { // don't die if a storage backend doesn't exist \OC::$server->getLogger()->logException($e, [ 'message' => 'Could not load storage.', - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'files_external', ]); return null; } catch (\InvalidArgumentException $e) { \OC::$server->getLogger()->logException($e, [ 'message' => 'Could not load storage.', - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'files_external', ]); return null; @@ -479,7 +480,7 @@ abstract class StoragesService { // be instantiated or whenever $user vars where used, in which case // the storage id could not be computed \OC::$server->getLogger()->logException($e, [ - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'files_external', ]); } diff --git a/apps/files_trashbin/ajax/delete.php b/apps/files_trashbin/ajax/delete.php index 149bbbd94ff..5fb69d7f2ee 100644 --- a/apps/files_trashbin/ajax/delete.php +++ b/apps/files_trashbin/ajax/delete.php @@ -24,6 +24,9 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + +use OCP\ILogger; + \OC_JSON::checkLoggedIn(); \OC_JSON::callCheck(); \OC::$server->getSession()->close(); @@ -66,7 +69,7 @@ foreach ($list as $file) { OCA\Files_Trashbin\Trashbin::delete($filename, \OCP\User::getUser(), $timestamp); if (OCA\Files_Trashbin\Trashbin::file_exists($filename, $timestamp)) { $error[] = $filename; - \OCP\Util::writeLog('trashbin','can\'t delete ' . $filename . ' permanently.', \OCP\Util::ERROR); + \OCP\Util::writeLog('trashbin','can\'t delete ' . $filename . ' permanently.', ILogger::ERROR); } // only list deleted files if not deleting everything else if (!$deleteAll) { diff --git a/apps/files_trashbin/ajax/undelete.php b/apps/files_trashbin/ajax/undelete.php index 5fb042aa1c4..348148b03bc 100644 --- a/apps/files_trashbin/ajax/undelete.php +++ b/apps/files_trashbin/ajax/undelete.php @@ -26,6 +26,9 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + +use OCP\ILogger; + \OC_JSON::checkLoggedIn(); \OC_JSON::callCheck(); \OC::$server->getSession()->close(); @@ -72,7 +75,7 @@ foreach ($list as $file) { if ( !OCA\Files_Trashbin\Trashbin::restore($path, $filename, $timestamp) ) { $error[] = $filename; - \OCP\Util::writeLog('trashbin', 'can\'t restore ' . $filename, \OCP\Util::ERROR); + \OCP\Util::writeLog('trashbin', 'can\'t restore ' . $filename, ILogger::ERROR); } else { $success[$i]['filename'] = $file; $success[$i]['timestamp'] = $timestamp; diff --git a/apps/files_trashbin/lib/Storage.php b/apps/files_trashbin/lib/Storage.php index 64b6a086271..54b47a6a19e 100644 --- a/apps/files_trashbin/lib/Storage.php +++ b/apps/files_trashbin/lib/Storage.php @@ -132,7 +132,7 @@ class Storage extends Wrapper { // do nothing, in this case we just disable the trashbin and continue \OC::$server->getLogger()->logException($e, [ 'message' => 'Trashbin storage could not check if a file was moved out of a shared folder.', - 'level' => \OCP\Util::DEBUG, + 'level' => ILogger::DEBUG, 'app' => 'files_trashbin', ]); } diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index 30812a3ca05..21f5382d010 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -294,7 +294,7 @@ class UsersController extends AUserData { } catch (\Exception $e) { $this->logger->logException($e, [ 'message' => "Can't send new user mail to $email", - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'ocs_api', ]); throw new OCSException('Unable to send the invitation mail', 109); @@ -306,14 +306,14 @@ class UsersController extends AUserData { } catch (HintException $e ) { $this->logger->logException($e, [ 'message' => 'Failed addUser attempt with hint exception.', - 'level' => \OCP\Util::WARN, + 'level' => ILogger::WARN, 'app' => 'ocs_api', ]); throw new OCSException($e->getHint(), 107); } catch (\Exception $e) { $this->logger->logException($e, [ 'message' => 'Failed addUser attempt with exception.', - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'ocs_api', ]); throw new OCSException('Bad request', 101); @@ -885,7 +885,7 @@ class UsersController extends AUserData { } catch(\Exception $e) { $this->logger->logException($e, [ 'message' => "Can't send new user mail to $email", - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'settings', ]); throw new OCSException('Sending email failed', 102); diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php index 7625218e7e5..ce127c1b365 100644 --- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php +++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php @@ -442,7 +442,7 @@ class UsersControllerTest extends TestCase { ->method('logException') ->with($exception, [ 'message' => 'Failed addUser attempt with exception.', - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'ocs_api', ]); $loggedInUser = $this->getMockBuilder(IUser::class) diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index 61c9c01e9ab..61b479d3e9b 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -353,7 +353,7 @@ class ShareByMailProvider implements IShareProvider { } catch (HintException $hintException) { $this->logger->logException($hintException, [ 'message' => 'Failed to send share by mail.', - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'sharebymail', ]); $this->removeShareFromTable($shareId); @@ -361,7 +361,7 @@ class ShareByMailProvider implements IShareProvider { } catch (\Exception $e) { $this->logger->logException($e, [ 'message' => 'Failed to send share by mail.', - 'level' => \OCP\Util::ERROR, + 'level' => ILogger::ERROR, 'app' => 'sharebymail', ]); $this->removeShareFromTable($shareId); diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php index 4736e365504..3557f45a32f 100644 --- a/apps/user_ldap/lib/Access.php +++ b/apps/user_ldap/lib/Access.php @@ -52,6 +52,7 @@ use OCA\User_LDAP\User\OfflineUser; use OCA\User_LDAP\Mapping\AbstractMapping; use OC\ServerNotAvailableException; use OCP\IConfig; +use OCP\ILogger; use OCP\IUserManager; use OCP\Util; @@ -186,13 +187,13 @@ class Access extends LDAPUtility implements IUserTools { if(!$this->checkConnection()) { \OCP\Util::writeLog('user_ldap', 'No LDAP Connector assigned, access impossible for readAttribute.', - \OCP\Util::WARN); + ILogger::WARN); return false; } $cr = $this->connection->getConnectionResource(); if(!$this->ldap->isResource($cr)) { //LDAP not available - \OCP\Util::writeLog('user_ldap', 'LDAP resource not available.', \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'LDAP resource not available.', ILogger::DEBUG); return false; } //Cancel possibly running Paged Results operation, otherwise we run in @@ -247,7 +248,7 @@ class Access extends LDAPUtility implements IUserTools { } } while($isRangeRequest); - \OCP\Util::writeLog('user_ldap', 'Requested attribute '.$attr.' not found for '.$dn, \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'Requested attribute '.$attr.' not found for '.$dn, ILogger::DEBUG); return false; } @@ -271,13 +272,13 @@ class Access extends LDAPUtility implements IUserTools { if (!$this->ldap->isResource($rr)) { if ($attribute !== '') { //do not throw this message on userExists check, irritates - \OCP\Util::writeLog('user_ldap', 'readAttribute failed for DN ' . $dn, \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'readAttribute failed for DN ' . $dn, ILogger::DEBUG); } //in case an error occurs , e.g. object does not exist return false; } if ($attribute === '' && ($filter === 'objectclass=*' || $this->invokeLDAPMethod('countEntries', $cr, $rr) === 1)) { - \OCP\Util::writeLog('user_ldap', 'readAttribute: ' . $dn . ' found', \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'readAttribute: ' . $dn . ' found', ILogger::DEBUG); return true; } $er = $this->invokeLDAPMethod('firstEntry', $cr, $rr); @@ -363,7 +364,7 @@ class Access extends LDAPUtility implements IUserTools { $cr = $this->connection->getConnectionResource(); if(!$this->ldap->isResource($cr)) { //LDAP not available - \OCP\Util::writeLog('user_ldap', 'LDAP resource not available.', \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'LDAP resource not available.', ILogger::DEBUG); return false; } try { @@ -566,14 +567,14 @@ class Access extends LDAPUtility implements IUserTools { } } else { //If the UUID can't be detected something is foul. - \OCP\Util::writeLog('user_ldap', 'Cannot determine UUID for '.$fdn.'. Skipping.', \OCP\Util::INFO); + \OCP\Util::writeLog('user_ldap', 'Cannot determine UUID for '.$fdn.'. Skipping.', ILogger::INFO); return false; } if(is_null($ldapName)) { $ldapName = $this->readAttribute($fdn, $nameAttribute, $filter); if(!isset($ldapName[0]) && empty($ldapName[0])) { - \OCP\Util::writeLog('user_ldap', 'No or empty name for '.$fdn.' with filter '.$filter.'.', \OCP\Util::INFO); + \OCP\Util::writeLog('user_ldap', 'No or empty name for '.$fdn.' with filter '.$filter.'.', ILogger::INFO); return false; } $ldapName = $ldapName[0]; @@ -592,7 +593,7 @@ class Access extends LDAPUtility implements IUserTools { } catch (\InvalidArgumentException $e) { \OC::$server->getLogger()->logException($e, [ 'app' => 'user_ldap', - 'level' => Util::WARN, + 'level' => ILogger::WARN, ]); // we don't attempt to set a username here. We can go for // for an alternative 4 digit random number as we would append @@ -633,7 +634,7 @@ class Access extends LDAPUtility implements IUserTools { } //if everything else did not help.. - \OCP\Util::writeLog('user_ldap', 'Could not create unique name for '.$fdn.'.', \OCP\Util::INFO); + \OCP\Util::writeLog('user_ldap', 'Could not create unique name for '.$fdn.'.', ILogger::INFO); return false; } @@ -1031,13 +1032,13 @@ class Access extends LDAPUtility implements IUserTools { * Maybe implement exponential backoff? * This was enough to get solr indexer working which has large delays between LDAP fetches. */ - \OCP\Util::writeLog('user_ldap', "Connection lost on $command, attempting to reestablish.", \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', "Connection lost on $command, attempting to reestablish.", ILogger::DEBUG); $this->connection->resetConnectionResource(); $cr = $this->connection->getConnectionResource(); if(!$this->ldap->isResource($cr)) { // Seems like we didn't find any resource. - \OCP\Util::writeLog('user_ldap', "Could not $command, because resource is missing.", \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', "Could not $command, because resource is missing.", ILogger::DEBUG); throw $e; } @@ -1069,7 +1070,7 @@ class Access extends LDAPUtility implements IUserTools { if(!$this->ldap->isResource($cr)) { // Seems like we didn't find any resource. // Return an empty array just like before. - \OCP\Util::writeLog('user_ldap', 'Could not search, because resource is missing.', \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'Could not search, because resource is missing.', ILogger::DEBUG); return false; } @@ -1081,7 +1082,7 @@ class Access extends LDAPUtility implements IUserTools { // cannot use $cr anymore, might have changed in the previous call! $error = $this->ldap->errno($this->connection->getConnectionResource()); if(!is_array($sr) || $error !== 0) { - \OCP\Util::writeLog('user_ldap', 'Attempt for Paging? '.print_r($pagedSearchOK, true), \OCP\Util::ERROR); + \OCP\Util::writeLog('user_ldap', 'Attempt for Paging? '.print_r($pagedSearchOK, true), ILogger::ERROR); return false; } @@ -1152,7 +1153,7 @@ class Access extends LDAPUtility implements IUserTools { * @throws ServerNotAvailableException */ private function count($filter, $base, $attr = null, $limit = null, $offset = null, $skipHandling = false) { - \OCP\Util::writeLog('user_ldap', 'Count filter: '.print_r($filter, true), \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'Count filter: '.print_r($filter, true), ILogger::DEBUG); $limitPerPage = (int)$this->connection->ldapPagingSize; if(!is_null($limit) && $limit < $limitPerPage && $limit > 0) { @@ -1468,7 +1469,7 @@ class Access extends LDAPUtility implements IUserTools { \OCP\Util::writeLog( 'user_ldap', 'Creating advanced filter for search failed, falling back to simple method.', - \OCP\Util::INFO + ILogger::INFO ); } } @@ -1629,16 +1630,20 @@ class Access extends LDAPUtility implements IUserTools { $value = $this->readAttribute($dn, $attribute); if(is_array($value) && isset($value[0]) && !empty($value[0])) { - \OCP\Util::writeLog('user_ldap', - 'Setting '.$attribute.' as '.$uuidAttr, - \OCP\Util::DEBUG); + \OCP\Util::writeLog( + 'user_ldap', + 'Setting '.$attribute.' as '.$uuidAttr, + ILogger::DEBUG + ); $this->connection->$uuidAttr = $attribute; return true; } } - \OCP\Util::writeLog('user_ldap', - 'Could not autodetect the UUID attribute', - \OCP\Util::ERROR); + \OCP\Util::writeLog( + 'user_ldap', + 'Could not autodetect the UUID attribute', + ILogger::ERROR + ); return false; } @@ -1941,7 +1946,7 @@ class Access extends LDAPUtility implements IUserTools { \OCP\Util::writeLog('user_ldap', 'initializing paged search for Filter '.$filter.' base '.print_r($bases, true) .' attr '.print_r($attr, true). ' limit ' .$limit.' offset '.$offset, - \OCP\Util::DEBUG); + ILogger::DEBUG); //get the cookie from the search for the previous search, required by LDAP foreach($bases as $base) { @@ -1969,10 +1974,10 @@ class Access extends LDAPUtility implements IUserTools { if(!$pagedSearchOK) { return false; } - \OCP\Util::writeLog('user_ldap', 'Ready for a paged search', \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'Ready for a paged search', ILogger::DEBUG); } else { $e = new \Exception('No paged search possible, Limit '.$limit.' Offset '.$offset); - \OC::$server->getLogger()->logException($e, ['level' => Util::DEBUG]); + \OC::$server->getLogger()->logException($e, ['level' => ILogger::DEBUG]); } } diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php index 53e1882bd65..a5bbc957ac9 100644 --- a/apps/user_ldap/lib/Connection.php +++ b/apps/user_ldap/lib/Connection.php @@ -37,6 +37,7 @@ namespace OCA\User_LDAP; use OC\ServerNotAvailableException; +use OCP\ILogger; /** * magic properties (incomplete) @@ -192,7 +193,7 @@ class Connection extends LDAPUtility { $this->establishConnection(); } if(is_null($this->ldapConnectionRes)) { - \OCP\Util::writeLog('user_ldap', 'No LDAP Connection to server ' . $this->configuration->ldapHost, \OCP\Util::ERROR); + \OCP\Util::writeLog('user_ldap', 'No LDAP Connection to server ' . $this->configuration->ldapHost, ILogger::ERROR); throw new ServerNotAvailableException('Connection to LDAP server could not be established'); } return $this->ldapConnectionRes; @@ -366,7 +367,7 @@ class Connection extends LDAPUtility { \OCP\Util::writeLog('user_ldap', 'Illegal value for the '. $effectiveSetting.', '.'reset to '. - 'autodetect.', \OCP\Util::INFO); + 'autodetect.', ILogger::INFO); } } @@ -390,10 +391,11 @@ class Connection extends LDAPUtility { if((stripos($this->configuration->ldapHost, 'ldaps://') === 0) && $this->configuration->ldapTLS) { $this->configuration->ldapTLS = false; - \OCP\Util::writeLog('user_ldap', - 'LDAPS (already using secure connection) and '. - 'TLS do not work together. Switched off TLS.', - \OCP\Util::INFO); + \OCP\Util::writeLog( + 'user_ldap', + 'LDAPS (already using secure connection) and TLS do not work together. Switched off TLS.', + ILogger::INFO + ); } } @@ -432,9 +434,11 @@ class Connection extends LDAPUtility { break; } $configurationOK = false; - \OCP\Util::writeLog('user_ldap', - $errorStr.'No '.$subj.' given!', - \OCP\Util::WARN); + \OCP\Util::writeLog( + 'user_ldap', + $errorStr.'No '.$subj.' given!', + ILogger::WARN + ); } } @@ -445,11 +449,11 @@ class Connection extends LDAPUtility { ($agent === '' && $pwd !== '') || ($agent !== '' && $pwd === '') ) { - \OCP\Util::writeLog('user_ldap', - $errorStr.'either no password is given for the '. - 'user agent or a password is given, but not an '. - 'LDAP agent.', - \OCP\Util::WARN); + \OCP\Util::writeLog( + 'user_ldap', + $errorStr.'either no password is given for the user ' . + 'agent or a password is given, but not an LDAP agent.', + ILogger::WARN); $configurationOK = false; } @@ -458,18 +462,21 @@ class Connection extends LDAPUtility { $baseGroups = $this->configuration->ldapBaseGroups; if(empty($base) && empty($baseUsers) && empty($baseGroups)) { - \OCP\Util::writeLog('user_ldap', - $errorStr.'Not a single Base DN given.', - \OCP\Util::WARN); + \OCP\Util::writeLog( + 'user_ldap', + $errorStr.'Not a single Base DN given.', + ILogger::WARN + ); $configurationOK = false; } if(mb_strpos($this->configuration->ldapLoginFilter, '%uid', 0, 'UTF-8') === false) { - \OCP\Util::writeLog('user_ldap', - $errorStr.'login filter does not contain %uid '. - 'place holder.', - \OCP\Util::WARN); + \OCP\Util::writeLog( + 'user_ldap', + $errorStr.'login filter does not contain %uid place holder.', + ILogger::WARN + ); $configurationOK = false; } @@ -511,18 +518,21 @@ class Connection extends LDAPUtility { return false; } if(!$this->ignoreValidation && !$this->configured) { - \OCP\Util::writeLog('user_ldap', - 'Configuration is invalid, cannot connect', - \OCP\Util::WARN); + \OCP\Util::writeLog( + 'user_ldap', + 'Configuration is invalid, cannot connect', + ILogger::WARN + ); return false; } if(!$this->ldapConnectionRes) { if(!$this->ldap->areLDAPFunctionsAvailable()) { $phpLDAPinstalled = false; - \OCP\Util::writeLog('user_ldap', - 'function ldap_connect is not available. Make '. - 'sure that the PHP ldap module is installed.', - \OCP\Util::ERROR); + \OCP\Util::writeLog( + 'user_ldap', + 'function ldap_connect is not available. Make sure that the PHP ldap module is installed.', + ILogger::ERROR + ); return false; } @@ -530,11 +540,13 @@ class Connection extends LDAPUtility { if(putenv('LDAPTLS_REQCERT=never')) { \OCP\Util::writeLog('user_ldap', 'Turned off SSL certificate validation successfully.', - \OCP\Util::DEBUG); + ILogger::DEBUG); } else { - \OCP\Util::writeLog('user_ldap', - 'Could not turn off SSL certificate validation.', - \OCP\Util::WARN); + \OCP\Util::writeLog( + 'user_ldap', + 'Could not turn off SSL certificate validation.', + ILogger::WARN + ); } } @@ -651,7 +663,7 @@ class Connection extends LDAPUtility { \OCP\Util::writeLog('user_ldap', 'Bind failed: ' . $errno . ': ' . $this->ldap->error($cr), - \OCP\Util::WARN); + ILogger::WARN); // Set to failure mode, if LDAP error code is not LDAP_SUCCESS or LDAP_INVALID_CREDENTIALS if($errno !== 0x00 && $errno !== 0x31) { diff --git a/apps/user_ldap/lib/Group_LDAP.php b/apps/user_ldap/lib/Group_LDAP.php index 2e7bddb9c4d..d9e2c7e2e3e 100644 --- a/apps/user_ldap/lib/Group_LDAP.php +++ b/apps/user_ldap/lib/Group_LDAP.php @@ -43,6 +43,7 @@ namespace OCA\User_LDAP; use OC\Cache\CappedMemoryCache; use OCP\GroupInterface; +use OCP\ILogger; class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLDAP { protected $enabled = false; @@ -197,7 +198,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD } } else { \OCP\Util::writeLog('user_ldap', 'No search filter found on member url '. - 'of group ' . $dnGroup, \OCP\Util::DEBUG); + 'of group ' . $dnGroup, ILogger::DEBUG); } } return $dynamicMembers; @@ -656,7 +657,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD } } else { \OCP\Util::writeLog('user_ldap', 'No search filter found on member url '. - 'of group ' . print_r($dynamicGroup, true), \OCP\Util::DEBUG); + 'of group ' . print_r($dynamicGroup, true), ILogger::DEBUG); } } } @@ -699,7 +700,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD $result = $this->access->readAttribute($userDN, 'uid'); if ($result === false) { \OCP\Util::writeLog('user_ldap', 'No uid attribute found for DN ' . $userDN . ' on '. - $this->access->connection->ldapHost, \OCP\Util::DEBUG); + $this->access->connection->ldapHost, ILogger::DEBUG); } $uid = $result[0]; } else { @@ -961,7 +962,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD $cacheKey = 'getGroups-'.$search.'-'.$limit.'-'.$offset; //Check cache before driving unnecessary searches - \OCP\Util::writeLog('user_ldap', 'getGroups '.$cacheKey, \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'getGroups '.$cacheKey, ILogger::DEBUG); $ldap_groups = $this->access->connection->getFromCache($cacheKey); if(!is_null($ldap_groups)) { return $ldap_groups; @@ -976,7 +977,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD $this->access->connection->ldapGroupFilter, $this->access->getFilterPartForGroupSearch($search) )); - \OCP\Util::writeLog('user_ldap', 'getGroups Filter '.$filter, \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'getGroups Filter '.$filter, ILogger::DEBUG); $ldap_groups = $this->access->fetchListOfGroups($filter, array($this->access->connection->ldapGroupDisplayName, 'dn'), $limit, @@ -1021,7 +1022,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD $chunkLimit = min($pagingSize, $overallLimit - $chunkOffset); $ldapGroups = $this->getGroupsChunk($search, $chunkLimit, $chunkOffset); $nread = count($ldapGroups); - \OCP\Util::writeLog('user_ldap', 'getGroups('.$search.'): read '.$nread.' at offset '.$chunkOffset.' (limit: '.$chunkLimit.')', \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'getGroups('.$search.'): read '.$nread.' at offset '.$chunkOffset.' (limit: '.$chunkLimit.')', ILogger::DEBUG); if ($nread) { $allGroups = array_merge($allGroups, $ldapGroups); $chunkOffset += $nread; diff --git a/apps/user_ldap/lib/Jobs/UpdateGroups.php b/apps/user_ldap/lib/Jobs/UpdateGroups.php index c36ec80b93e..776397bd0e9 100644 --- a/apps/user_ldap/lib/Jobs/UpdateGroups.php +++ b/apps/user_ldap/lib/Jobs/UpdateGroups.php @@ -43,6 +43,7 @@ use OCA\User_LDAP\LogWrapper; use OCA\User_LDAP\Mapping\GroupMapping; use OCA\User_LDAP\Mapping\UserMapping; use OCA\User_LDAP\User\Manager; +use OCP\ILogger; class UpdateGroups extends \OC\BackgroundJob\TimedJob { static private $groupsFromDB; @@ -61,7 +62,7 @@ class UpdateGroups extends \OC\BackgroundJob\TimedJob { } static public function updateGroups() { - \OCP\Util::writeLog('user_ldap', 'Run background job "updateGroups"', \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'Run background job "updateGroups"', ILogger::DEBUG); $knownGroups = array_keys(self::getKnownGroups()); $actualGroups = self::getGroupBE()->getGroups(); @@ -69,7 +70,7 @@ class UpdateGroups extends \OC\BackgroundJob\TimedJob { if(empty($actualGroups) && empty($knownGroups)) { \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – groups do not seem to be configured properly, aborting.', - \OCP\Util::INFO); + ILogger::INFO); return; } @@ -77,7 +78,7 @@ class UpdateGroups extends \OC\BackgroundJob\TimedJob { self::handleCreatedGroups(array_diff($actualGroups, $knownGroups)); self::handleRemovedGroups(array_diff($knownGroups, $actualGroups)); - \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – Finished.', \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – Finished.', ILogger::DEBUG); } /** @@ -92,7 +93,7 @@ class UpdateGroups extends \OC\BackgroundJob\TimedJob { * @param string[] $groups */ static private function handleKnownGroups($groups) { - \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – Dealing with known Groups.', \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – Dealing with known Groups.', ILogger::DEBUG); $query = \OC_DB::prepare(' UPDATE `*PREFIX*ldap_group_members` SET `owncloudusers` = ? @@ -107,14 +108,14 @@ class UpdateGroups extends \OC\BackgroundJob\TimedJob { \OCP\Util::emitHook('OC_User', 'post_removeFromGroup', array('uid' => $removedUser, 'gid' => $group)); \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – "'.$removedUser.'" removed from "'.$group.'".', - \OCP\Util::INFO); + ILogger::INFO); $hasChanged = true; } foreach(array_diff($actualUsers, $knownUsers) as $addedUser) { \OCP\Util::emitHook('OC_User', 'post_addToGroup', array('uid' => $addedUser, 'gid' => $group)); \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – "'.$addedUser.'" added to "'.$group.'".', - \OCP\Util::INFO); + ILogger::INFO); $hasChanged = true; } if($hasChanged) { @@ -123,14 +124,14 @@ class UpdateGroups extends \OC\BackgroundJob\TimedJob { } \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – FINISHED dealing with known Groups.', - \OCP\Util::DEBUG); + ILogger::DEBUG); } /** * @param string[] $createdGroups */ static private function handleCreatedGroups($createdGroups) { - \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – dealing with created Groups.', \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – dealing with created Groups.', ILogger::DEBUG); $query = \OC_DB::prepare(' INSERT INTO `*PREFIX*ldap_group_members` (`owncloudname`, `owncloudusers`) @@ -139,20 +140,20 @@ class UpdateGroups extends \OC\BackgroundJob\TimedJob { foreach($createdGroups as $createdGroup) { \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – new group "'.$createdGroup.'" found.', - \OCP\Util::INFO); + ILogger::INFO); $users = serialize(self::getGroupBE()->usersInGroup($createdGroup)); $query->execute(array($createdGroup, $users)); } \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – FINISHED dealing with created Groups.', - \OCP\Util::DEBUG); + ILogger::DEBUG); } /** * @param string[] $removedGroups */ static private function handleRemovedGroups($removedGroups) { - \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – dealing with removed groups.', \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – dealing with removed groups.', ILogger::DEBUG); $query = \OC_DB::prepare(' DELETE FROM `*PREFIX*ldap_group_members` @@ -161,12 +162,12 @@ class UpdateGroups extends \OC\BackgroundJob\TimedJob { foreach($removedGroups as $removedGroup) { \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – group "'.$removedGroup.'" was removed.', - \OCP\Util::INFO); + ILogger::INFO); $query->execute(array($removedGroup)); } \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – FINISHED dealing with removed groups.', - \OCP\Util::DEBUG); + ILogger::DEBUG); } /** diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php index 2f36e205fa6..eb4101ddc25 100644 --- a/apps/user_ldap/lib/User/User.php +++ b/apps/user_ldap/lib/User/User.php @@ -35,6 +35,7 @@ use OCA\User_LDAP\FilesystemHelper; use OCA\User_LDAP\LogWrapper; use OCP\IAvatarManager; use OCP\IConfig; +use OCP\ILogger; use OCP\Image; use OCP\IUserManager; use OCP\Util; @@ -125,10 +126,10 @@ class User { INotificationManager $notificationManager) { if ($username === null) { - $log->log("uid for '$dn' must not be null!", Util::ERROR); + $log->log("uid for '$dn' must not be null!", ILogger::ERROR); throw new \InvalidArgumentException('uid must not be null!'); } else if ($username === '') { - $log->log("uid for '$dn' must not be an empty string", Util::ERROR); + $log->log("uid for '$dn' must not be an empty string", ILogger::ERROR); throw new \InvalidArgumentException('uid must not be an empty string!'); } @@ -507,7 +508,7 @@ class User { if ($this->verifyQuotaValue($aQuota[0])) { $quota = $aQuota[0]; } else { - $this->log->log('not suitable LDAP quota found for user ' . $this->uid . ': [' . $aQuota[0] . ']', \OCP\Util::WARN); + $this->log->log('not suitable LDAP quota found for user ' . $this->uid . ': [' . $aQuota[0] . ']', ILogger::WARN); } } } @@ -515,7 +516,7 @@ class User { if ($this->verifyQuotaValue($valueFromLDAP)) { $quota = $valueFromLDAP; } else { - $this->log->log('not suitable LDAP quota found for user ' . $this->uid . ': [' . $valueFromLDAP . ']', \OCP\Util::WARN); + $this->log->log('not suitable LDAP quota found for user ' . $this->uid . ': [' . $valueFromLDAP . ']', ILogger::WARN); } } @@ -532,10 +533,10 @@ class User { if($quota !== false) { $targetUser->setQuota($quota); } else { - $this->log->log('not suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', \OCP\Util::WARN); + $this->log->log('not suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', ILogger::WARN); } } else { - $this->log->log('trying to set a quota for user ' . $this->uid . ' but the user is missing', \OCP\Util::ERROR); + $this->log->log('trying to set a quota for user ' . $this->uid . ' but the user is missing', ILogger::ERROR); } } @@ -577,13 +578,13 @@ class User { */ private function setOwnCloudAvatar() { if(!$this->image->valid()) { - $this->log->log('jpegPhoto data invalid for '.$this->dn, \OCP\Util::ERROR); + $this->log->log('jpegPhoto data invalid for '.$this->dn, ILogger::ERROR); return; } //make sure it is a square and not bigger than 128x128 $size = min(array($this->image->width(), $this->image->height(), 128)); if(!$this->image->centerCrop($size)) { - $this->log->log('croping image for avatar failed for '.$this->dn, \OCP\Util::ERROR); + $this->log->log('croping image for avatar failed for '.$this->dn, ILogger::ERROR); return; } @@ -597,7 +598,7 @@ class User { } catch (\Exception $e) { \OC::$server->getLogger()->logException($e, [ 'message' => 'Could not set avatar for ' . $this->dn, - 'level' => \OCP\Util::INFO, + 'level' => ILogger::INFO, 'app' => 'user_ldap', ]); } diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php index e56e4675e39..9c7d5711794 100644 --- a/apps/user_ldap/lib/User_LDAP.php +++ b/apps/user_ldap/lib/User_LDAP.php @@ -45,6 +45,7 @@ use OCA\User_LDAP\Exceptions\NotOnLDAP; use OCA\User_LDAP\User\OfflineUser; use OCA\User_LDAP\User\User; use OCP\IConfig; +use OCP\ILogger; use OCP\IUser; use OCP\IUserSession; use OCP\Notification\IManager as INotificationManager; @@ -181,7 +182,7 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn try { $ldapRecord = $this->getLDAPUserByLoginName($uid); } catch(NotOnLDAP $e) { - if($this->ocConfig->getSystemValue('loglevel', Util::WARN) === Util::DEBUG) { + if($this->ocConfig->getSystemValue('loglevel', ILogger::WARN) === ILogger::DEBUG) { \OC::$server->getLogger()->logException($e, ['app' => 'user_ldap']); } return false; @@ -193,7 +194,7 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn Util::writeLog('user_ldap', 'LDAP Login: Could not get user object for DN ' . $dn . '. Maybe the LDAP entry has no set display name attribute?', - Util::WARN); + ILogger::WARN); return false; } if($user->getUsername() !== false) { @@ -278,14 +279,14 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn Util::writeLog('user_ldap', 'getUsers: Options: search '.$search.' limit '.$limit.' offset '.$offset.' Filter: '.$filter, - Util::DEBUG); + ILogger::DEBUG); //do the search and translate results to Nextcloud names $ldap_users = $this->access->fetchListOfUsers( $filter, $this->access->userManager->getAttributes(true), $limit, $offset); $ldap_users = $this->access->nextcloudUserNames($ldap_users); - Util::writeLog('user_ldap', 'getUsers: '.count($ldap_users). ' Users found', Util::DEBUG); + Util::writeLog('user_ldap', 'getUsers: '.count($ldap_users). ' Users found', ILogger::DEBUG); $this->access->connection->writeToCache($cachekey, $ldap_users); return $ldap_users; @@ -358,7 +359,7 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn if(is_null($user)) { Util::writeLog('user_ldap', 'No DN found for '.$uid.' on '. - $this->access->connection->ldapHost, Util::DEBUG); + $this->access->connection->ldapHost, ILogger::DEBUG); $this->access->connection->writeToCache('userExists'.$uid, false); return false; } else if($user instanceof OfflineUser) { diff --git a/apps/user_ldap/lib/Wizard.php b/apps/user_ldap/lib/Wizard.php index cb1168f1b51..26b5a8cab71 100644 --- a/apps/user_ldap/lib/Wizard.php +++ b/apps/user_ldap/lib/Wizard.php @@ -39,6 +39,7 @@ namespace OCA\User_LDAP; use OC\ServerNotAvailableException; +use OCP\ILogger; class Wizard extends LDAPUtility { /** @var \OCP\IL10N */ @@ -301,7 +302,7 @@ class Wizard extends LDAPUtility { if($writeLog) { \OCP\Util::writeLog('user_ldap', 'The mail attribute has ' . 'automatically been reset, because the original value ' . - 'did not return any results.', \OCP\Util::INFO); + 'did not return any results.', ILogger::INFO); } } @@ -679,7 +680,7 @@ class Wizard extends LDAPUtility { foreach($portSettings as $setting) { $p = $setting['port']; $t = $setting['tls']; - \OCP\Util::writeLog('user_ldap', 'Wiz: trying port '. $p . ', TLS '. $t, \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'Wiz: trying port '. $p . ', TLS '. $t, ILogger::DEBUG); //connectAndBind may throw Exception, it needs to be catched by the //callee of this method @@ -702,7 +703,7 @@ class Wizard extends LDAPUtility { 'ldapTLS' => (int)$t ); $this->configuration->setConfiguration($config); - \OCP\Util::writeLog('user_ldap', 'Wiz: detected Port ' . $p, \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'Wiz: detected Port ' . $p, ILogger::DEBUG); $this->result->addChange('ldap_port', $p); return $this->result; } @@ -848,7 +849,7 @@ class Wizard extends LDAPUtility { $errorNo = $this->ldap->errno($cr); $errorMsg = $this->ldap->error($cr); \OCP\Util::writeLog('user_ldap', 'Wiz: Could not search base '.$base. - ' Error '.$errorNo.': '.$errorMsg, \OCP\Util::INFO); + ' Error '.$errorNo.': '.$errorMsg, ILogger::INFO); return false; } $entries = $this->ldap->countEntries($cr, $rr); @@ -1024,7 +1025,7 @@ class Wizard extends LDAPUtility { break; } - \OCP\Util::writeLog('user_ldap', 'Wiz: Final filter '.$filter, \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'Wiz: Final filter '.$filter, ILogger::DEBUG); return $filter; } @@ -1044,7 +1045,7 @@ class Wizard extends LDAPUtility { if(!$hostInfo) { throw new \Exception(self::$l->t('Invalid Host')); } - \OCP\Util::writeLog('user_ldap', 'Wiz: Attempting to connect ', \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'Wiz: Attempting to connect ', ILogger::DEBUG); $cr = $this->ldap->connect($host, $port); if(!is_resource($cr)) { throw new \Exception(self::$l->t('Invalid Host')); @@ -1063,7 +1064,7 @@ class Wizard extends LDAPUtility { } } - \OCP\Util::writeLog('user_ldap', 'Wiz: Attemping to Bind ', \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'Wiz: Attemping to Bind ', ILogger::DEBUG); //interesting part: do the bind! $login = $this->ldap->bind($cr, $this->configuration->ldapAgentName, @@ -1078,7 +1079,7 @@ class Wizard extends LDAPUtility { if($login === true) { $this->ldap->unbind($cr); - \OCP\Util::writeLog('user_ldap', 'Wiz: Bind successful to Port '. $port . ' TLS ' . (int)$tls, \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'Wiz: Bind successful to Port '. $port . ' TLS ' . (int)$tls, ILogger::DEBUG); return true; } |