Skip to content

Commit 4c3c982

Browse files
committed
Fix formatter functionality
1 parent 49e9b34 commit 4c3c982

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

app/Audit/ConcreteFormatters/UserActionAuditLogFormatter.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,22 @@ public function format($subject, array $change_set): ?string
1818
try {
1919
$id = $subject->getId() ?? 'unknown';
2020
$title = $subject->getUserAction() ?? 'Unknown UserAction';
21+
$owner = $subject->getOwner();
22+
$realm = $subject->hasRealm() ? $subject->getRealm() : 'N/A';
23+
$ip = $subject->getFromIp();
2124

2225
switch ($this->event_type) {
26+
2327
case IAuditStrategy::EVENT_ENTITY_CREATION:
24-
return sprintf("UserAction (%s) for '%s' created by user %s", $id, $title, $this->getUserInfo());
28+
return sprintf("UserAction (%s) for '%s' which owner is \"%s (%s)\", with realm \"%s\" and IP \"%s\" was created by user %s", $id, $title, $owner->getFullName(), $owner->getID(), $realm, $ip, $this->getUserInfo());
2529
case IAuditStrategy::EVENT_ENTITY_UPDATE:
2630
$details = $this->buildChangeDetails($change_set);
27-
return sprintf("UserAction (%s) for '%s' updated: %s by user %s", $id, $title, $details, $this->getUserInfo());
31+
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, $owner->getFullName(), $owner->getID(), $realm, $ip, $details, $this->getUserInfo());
2832
case IAuditStrategy::EVENT_ENTITY_DELETION:
29-
return sprintf("UserAction (%s) for '%s' deleted by user %s", $id, $title, $this->getUserInfo());
33+
return sprintf("UserAction (%s) for '%s' which owner is \"%s (%s)\", with realm \"%s\" and IP \"%s\" was deleted by user %s", $id, $title, $owner->getFullName(), $owner->getID(), $realm, $ip, $this->getUserInfo());
3034
}
35+
return "";
36+
3137
} catch (\Exception $ex) {
3238
Log::warning("UserAction error: " . $ex->getMessage());
3339
}

0 commit comments

Comments
 (0)