37241-vm/includes/audit_helpers.php
2026-01-03 08:40:36 +00:00

12 lines
528 B
PHP

<?php
function log_audit_trail(PDO $pdo, string $action, array $details, string $user = 'system') {
try {
$stmt = $pdo->prepare("INSERT INTO audit_log (user, action, details) VALUES (?, ?, ?)");
$stmt->execute([$user, $action, json_encode($details)]);
} catch (PDOException $e) {
// For now, we will log the error to the system's error log.
// In a production environment, this should be handled more robustly.
error_log('Failed to log audit trail: ' . $e->getMessage());
}
}