diff --git a/Processors/Monolog/DeamonLoggerExtraWebProcessor.php b/Processors/Monolog/DeamonLoggerExtraWebProcessor.php index 8e6bb41..d9b2f20 100755 --- a/Processors/Monolog/DeamonLoggerExtraWebProcessor.php +++ b/Processors/Monolog/DeamonLoggerExtraWebProcessor.php @@ -129,7 +129,7 @@ private function addRequestInfo(): void */ private function addUserInfo(): void { - if (!$this->configShowExtraInfo('user')) { + if (!$this->configShowExtraInfo('user') || empty($this->userClass)) { return; } diff --git a/Tests/Processors/Monolog/DeamonLoggerExtraWebProcessorTest.php b/Tests/Processors/Monolog/DeamonLoggerExtraWebProcessorTest.php index c23716b..172a202 100755 --- a/Tests/Processors/Monolog/DeamonLoggerExtraWebProcessorTest.php +++ b/Tests/Processors/Monolog/DeamonLoggerExtraWebProcessorTest.php @@ -118,6 +118,19 @@ public function testAddUserInfoWithNotExistingClass() $this->assertArrayNotHasKey('user_name', $record['extra']); } + + public function testAddUserInfoWithEmptyUserClass() + { + $config = $this->getDisplayConfig([ + 'user' => true, + ], null, ''); + + $processor = new DeamonLoggerExtraWebProcessor($config); + $record = $processor->__invoke($this->getRecord()); + + $this->assertArrayNotHasKey('user_name', $record['extra']); + } + public function testAddUserinfoWithNoTokenStorage() { $config = $this->getDisplayConfig([