alexjose / audit-log
Log audits events
Installs: 1 361
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: ^7.2|^8.0
- monolog/monolog: ^2.3
Requires (Dev)
- phpunit/phpunit: ^8.5
README
AuditLog - Log audit events using the Monolog
This library aims to log the critical changes happening in the application. This tracks the changes and the source of the events.
Installation
composer require alexjose/audit-log
Basic Usage
$auditLog = new AuditLog(); $auditLog->log([ 'New User Registerd', 'User', 'creation', 1, 'user', 'alex@example.com', [ 'username' => 'john', 'email' => 'john@example.com' ], null, 1, 'user', 'alex@example.com', ]);
Signature of log()
log()
will accept an instance of Event
or an array with the attributes of the Event
.
/** * @param Event|array $event */ public function log($event): void
Signature of new Event()
/** * @param string $message The title of the log * @param string $event The unique name of event * @param string $entityId The id of the entity which got modified * @param string $entityType The type to entity which got modified * @param string $entityTitle The title of the entity which got modified * @param array $newValues The new values of the entity * @param array|null $oldValues The old values of the entity * @param string $userId The id of the user who made the change * @param string $userType The type of the user who made the change * @param string $username The username of the user who made the change */ public function __construct( $message, $module, $event, $entityId, $entityType, $entityTitle, $newValues, $oldValues, $userId, $userType, $username ):void