const pool = require("../models/db"); // Import pool for database access

async function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

async function logToDatabase(accountId, message) {
    try {
        await pool.query("INSERT INTO logs (account_id, log_message) VALUES (?, ?)", [accountId, message]);
        console.log(`📝 Logged to database: ${message} for account ${accountId}`);
    } catch (error) {
        console.error(`❌ Failed to log to database for account ${accountId}: ${error.message}`);
    }
}

module.exports = { sleep, logToDatabase };