db = $db; } public function log($action, $details = null, $userId = null) { try { $this->db->query( "INSERT INTO audit_log (user_id, action, entity_type, details, ip_address) VALUES (?, ?, 'updater', ?, ?)", [ $userId, $action, is_string($details) ? $details : json_encode($details, JSON_UNESCAPED_UNICODE), $_SERVER['REMOTE_ADDR'] ?? null, ] ); } catch (\Throwable $e) { // Logging darf nie ein Update verhindern. } } }