diff --git a/app/Audit/ConcreteFormatters/UserActionAuditLogFormatter.php b/app/Audit/ConcreteFormatters/UserActionAuditLogFormatter.php index 0dbaccf7..3738319f 100644 --- a/app/Audit/ConcreteFormatters/UserActionAuditLogFormatter.php +++ b/app/Audit/ConcreteFormatters/UserActionAuditLogFormatter.php @@ -18,16 +18,24 @@ public function format($subject, array $change_set): ?string try { $id = $subject->getId() ?? 'unknown'; $title = $subject->getUserAction() ?? 'Unknown UserAction'; + $owner = $subject->getOwner(); + $ownerFullName = $owner ? $owner->getFullName() : 'Unknown'; + $ownerID = $owner ? $owner->getID() : 'N/A'; + $realm = $subject->hasRealm() ? $subject->getRealm() : 'N/A'; + $ip = $subject->getFromIp() ?? 'Unknown'; switch ($this->event_type) { + case IAuditStrategy::EVENT_ENTITY_CREATION: - return sprintf("UserAction (%s) for '%s' created by user %s", $id, $title, $this->getUserInfo()); + return sprintf("UserAction (%s) for '%s' which owner is \"%s (%s)\", with realm \"%s\" and IP \"%s\" was created by user %s", $id, $title, $ownerFullName, $ownerID, $realm, $ip, $this->getUserInfo()); case IAuditStrategy::EVENT_ENTITY_UPDATE: $details = $this->buildChangeDetails($change_set); - return sprintf("UserAction (%s) for '%s' updated: %s by user %s", $id, $title, $details, $this->getUserInfo()); + return sprintf("UserAction (%s) for '%s' which owner is \"%s (%s)\", with realm \"%s\" and IP \"%s\" was updated: %s by user %s", $id, $title, $ownerFullName, $ownerID, $realm, $ip, $details, $this->getUserInfo()); case IAuditStrategy::EVENT_ENTITY_DELETION: - return sprintf("UserAction (%s) for '%s' deleted by user %s", $id, $title, $this->getUserInfo()); + return sprintf("UserAction (%s) for '%s' which owner is \"%s (%s)\", with realm \"%s\" and IP \"%s\" was deleted by user %s", $id, $title, $ownerFullName, $ownerID, $realm, $ip, $this->getUserInfo()); } + return null; + } catch (\Exception $ex) { Log::warning("UserAction error: " . $ex->getMessage()); } diff --git a/config/audit_log.php b/config/audit_log.php index 95bbacf8..1213289f 100644 --- a/config/audit_log.php +++ b/config/audit_log.php @@ -1,10 +1,13 @@ [ - \Models\UserAction::class => [ + UserAction::class => [ 'enabled' => true, - 'strategy' => App\Audit\ConcreteFormatters\UserActionAuditLogFormatter::class + 'strategy' => UserActionAuditLogFormatter::class, ], ] ]; \ No newline at end of file