/**
 * logger.js — Serviço de Auditoria
 */
const db = require('../db');

async function logAction(userId, action, description = null, targetId = null, ip = null) {
    try {
        await db.execute(
            'INSERT INTO audit_logs (user_id, action_type, description, target_id, ip_address) VALUES (?, ?, ?, ?, ?)',
            [userId, action, description, targetId, ip]
        );
    } catch (err) {
        console.error('[AUDIT ERROR]', err.message);
    }
}

module.exports = { logAction };
