<?php

namespace KeyLair;

class AuditLog
{
    public static function log(?int $adminUserId, string $action, ?string $details = null): void
    {
        $pdo = Database::connection();
        $stmt = $pdo->prepare(
            'INSERT INTO audit_log (admin_user_id, action, details, ip_hash, created_at)
             VALUES (:admin_id, :action, :details, :ip_hash, NOW())'
        );
        $stmt->execute([
            'admin_id' => $adminUserId,
            'action' => $action,
            'details' => $details,
            'ip_hash' => Helpers::hashIp(Helpers::clientIp()),
        ]);
    }
}
