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/**
@@ -71,7 +72,12 @@ class Log implements ILogger, IDataLogger {
7172 * @param Normalizer|null $normalizer
7273 * @param IRegistry|null $registry
7374 */
74- public function __construct (IWriter $ logger , SystemConfig $ config = null , Normalizer $ normalizer = null , IRegistry $ registry = null ) {
75+ public function __construct (
76+ IWriter $ logger ,
77+ SystemConfig $ config = null ,
78+ Normalizer $ normalizer = null ,
79+ IRegistry $ registry = null
80+ ) {
7581 // FIXME: Add this for backwards compatibility, should be fixed at some point probably
7682 if ($ config === null ) {
7783 $ config = \OC ::$ server ->getSystemConfig ();
@@ -257,10 +263,13 @@ public function getLogLevel($context) {
257263
258264 // check for user
259265 if (isset ($ logCondition ['users ' ])) {
260- $ user = \OC :: $ server -> getUserSession ( )->getUser ();
266+ $ user = \OCP \Server:: get (IUserSession::class )->getUser ();
261267
262- // if the user matches set the log condition to satisfied
263- if ($ user !== null && in_array ($ user ->getUID (), $ logCondition ['users ' ], true )) {
268+ if ($ user === null ) {
269+ // User is not known for this request yet
270+ $ this ->logConditionSatisfied = null ;
271+ } elseif (in_array ($ user ->getUID (), $ logCondition ['users ' ], true )) {
272+ // if the user matches set the log condition to satisfied
264273 $ this ->logConditionSatisfied = true ;
265274 }
266275 }
0 commit comments