diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2023-06-19 09:35:46 +0200 |
---|---|---|
committer | Anna Larch <anna@nextcloud.com> | 2023-08-24 15:04:54 +0200 |
commit | 36f9ca2218b0739d2826b8a58ba718f65cdc6bf3 (patch) | |
tree | 4563925825863e8fa313a63f10f61d7c3f3a757b /lib | |
parent | c19469872b544b804585b69ff54c08e34070bed0 (diff) | |
download | nextcloud-server-36f9ca2218b0739d2826b8a58ba718f65cdc6bf3.tar.gz nextcloud-server-36f9ca2218b0739d2826b8a58ba718f65cdc6bf3.zip |
fix(loggging): user log condition feature
Signed-off-by: Anna Larch <anna@nextcloud.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Log.php | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/lib/private/Log.php b/lib/private/Log.php index c139510a3b3..5c1862370fe 100644 --- a/lib/private/Log.php +++ b/lib/private/Log.php @@ -38,15 +38,16 @@ namespace OC; use Exception; use Nextcloud\LogNormalizer\Normalizer; -use OC\AppFramework\Bootstrap\Coordinator; -use OCP\Log\IDataLogger; -use Throwable; -use function array_merge; -use OC\Log\ExceptionSerializer; use OCP\ILogger; +use OCP\IUserSession; +use OCP\Log\IDataLogger; use OCP\Log\IFileBased; use OCP\Log\IWriter; use OCP\Support\CrashReport\IRegistry; +use OC\AppFramework\Bootstrap\Coordinator; +use OC\Log\ExceptionSerializer; +use Throwable; +use function array_merge; use function strtr; /** @@ -71,7 +72,12 @@ class Log implements ILogger, IDataLogger { * @param Normalizer|null $normalizer * @param IRegistry|null $registry */ - public function __construct(IWriter $logger, SystemConfig $config = null, Normalizer $normalizer = null, IRegistry $registry = null) { + public function __construct( + IWriter $logger, + SystemConfig $config = null, + Normalizer $normalizer = null, + IRegistry $registry = null + ) { // FIXME: Add this for backwards compatibility, should be fixed at some point probably if ($config === null) { $config = \OC::$server->getSystemConfig(); @@ -257,10 +263,13 @@ class Log implements ILogger, IDataLogger { // check for user if (isset($logCondition['users'])) { - $user = \OC::$server->getUserSession()->getUser(); + $user = \OCP\Server::get(IUserSession::class)->getUser(); - // if the user matches set the log condition to satisfied - if ($user !== null && in_array($user->getUID(), $logCondition['users'], true)) { + if ($user === null) { + // User is not known for this request yet + $this->logConditionSatisfied = null; + } elseif (in_array($user->getUID(), $logCondition['users'], true)) { + // if the user matches set the log condition to satisfied $this->logConditionSatisfied = true; } } |