Feat: Implement logging database handler
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Logging;
|
||||
|
||||
use App\Entity\User;
|
||||
use Monolog\LogRecord;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
|
||||
@@ -16,18 +17,20 @@ class InjectUserProcessor
|
||||
return $record;
|
||||
}
|
||||
|
||||
if ('cli' === php_sapi_name()) {
|
||||
/** @var User $user */
|
||||
$user = $this->security->getUser();
|
||||
|
||||
if (null === $user || 'cli' === php_sapi_name()) {
|
||||
$record->extra['user'] = [
|
||||
'id' => null,
|
||||
'username' => 'system',
|
||||
'role' => 'system',
|
||||
];
|
||||
return $record;
|
||||
} elseif (null === $user = $this->security->getUser()) {
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
$record['extra']['user'] = [
|
||||
$record->extra['user'] = [
|
||||
'id' => $user->getId(),
|
||||
'email' => $user->getEmail(),
|
||||
'roles' => $user->getRoles(),
|
||||
|
||||
Reference in New Issue
Block a user