alexjose/audit-log

Log audits events

v2.0.4 2022-05-11 16:01 UTC

This package is auto-updated.

Last update: 2024-08-26 23:42:08 UTC


README

Build Status Total Downloads Latest Stable Version License

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