Skip to content

Commit

Permalink
Merge pull request #38881 from nextcloud/fix/logcondition-user
Browse files Browse the repository at this point in the history
Fix user log.condition feature
  • Loading branch information
come-nc authored Jun 26, 2023
2 parents 39a0554 + 8ed6086 commit 2d81c04
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lib/private/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,18 @@

use Exception;
use Nextcloud\LogNormalizer\Normalizer;
use OC\AppFramework\Bootstrap\Coordinator;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\ILogger;
use OCP\IUserSession;
use OCP\Log\BeforeMessageLoggedEvent;
use OCP\Log\IDataLogger;
use Throwable;
use function array_merge;
use OC\Log\ExceptionSerializer;
use OCP\ILogger;
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;

/**
Expand Down Expand Up @@ -274,10 +275,13 @@ public function getLogLevel($context) {

// 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;
}
}
Expand Down

0 comments on commit 2d81c04

Please sign in to comment.