Skip to content

Commit cc94ac8

Browse files
committed
chore: update non existent info messages
1 parent 4c3c982 commit cc94ac8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

app/Audit/ConcreteFormatters/UserActionAuditLogFormatter.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,22 @@ public function format($subject, array $change_set): ?string
1919
$id = $subject->getId() ?? 'unknown';
2020
$title = $subject->getUserAction() ?? 'Unknown UserAction';
2121
$owner = $subject->getOwner();
22+
$ownerFullName = $owner ? $owner->getFullName() : 'Unknown';
23+
$ownerID = $owner ? $owner->getID() : 'N/A';
2224
$realm = $subject->hasRealm() ? $subject->getRealm() : 'N/A';
23-
$ip = $subject->getFromIp();
25+
$ip = $subject->getFromIp() ?? 'Unknown';
2426

2527
switch ($this->event_type) {
2628

2729
case IAuditStrategy::EVENT_ENTITY_CREATION:
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());
30+
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());
2931
case IAuditStrategy::EVENT_ENTITY_UPDATE:
3032
$details = $this->buildChangeDetails($change_set);
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());
33+
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());
3234
case IAuditStrategy::EVENT_ENTITY_DELETION:
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());
35+
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());
3436
}
35-
return "";
37+
return null;
3638

3739
} catch (\Exception $ex) {
3840
Log::warning("UserAction error: " . $ex->getMessage());

0 commit comments

Comments
 (0)