3838
3939use Exception ;
4040use Nextcloud \LogNormalizer \Normalizer ;
41- use OC \AppFramework \Bootstrap \Coordinator ;
42- use OCP \Log \IDataLogger ;
43- use Throwable ;
44- use function array_merge ;
45- use OC \Log \ExceptionSerializer ;
4641use OCP \ILogger ;
42+ use OCP \IUserSession ;
43+ use OCP \Log \IDataLogger ;
4744use OCP \Log \IFileBased ;
4845use OCP \Log \IWriter ;
4946use OCP \Support \CrashReport \IRegistry ;
47+ use OC \AppFramework \Bootstrap \Coordinator ;
48+ use OC \Log \ExceptionSerializer ;
49+ use Throwable ;
50+ use function array_merge ;
5051use function strtr ;
5152
5253/**
5960 * MonoLog is an example implementing this interface.
6061 */
6162class Log implements ILogger, IDataLogger {
62-
6363 /** @var IWriter */
6464 private $ logger ;
6565
@@ -247,7 +247,6 @@ public function getLogLevel($context) {
247247 // default to false to just process this once per request
248248 $ this ->logConditionSatisfied = false ;
249249 if (!empty ($ logCondition )) {
250-
251250 // check for secret token in the request
252251 if (isset ($ logCondition ['shared_secret ' ])) {
253252 $ request = \OC ::$ server ->getRequest ();
@@ -268,10 +267,13 @@ public function getLogLevel($context) {
268267
269268 // check for user
270269 if (isset ($ logCondition ['users ' ])) {
271- $ user = \OC :: $ server -> getUserSession ( )->getUser ();
270+ $ user = \OCP \Server:: get (IUserSession::class )->getUser ();
272271
273- // if the user matches set the log condition to satisfied
274- if ($ user !== null && in_array ($ user ->getUID (), $ logCondition ['users ' ], true )) {
272+ if ($ user === null ) {
273+ // User is not known for this request yet
274+ $ this ->logConditionSatisfied = null ;
275+ } elseif (in_array ($ user ->getUID (), $ logCondition ['users ' ], true )) {
276+ // if the user matches set the log condition to satisfied
275277 $ this ->logConditionSatisfied = true ;
276278 }
277279 }
0 commit comments