• Clears all log files

    Deletes all archived log files and clears the current log file

    Returns boolean

    Boolean indicating success or failure

    export function clearLogs(): boolean {
    try {
    // Clear the current log file
    fs.writeFileSync(latestLogPath, "", "utf-8");

    // Delete all archived log files
    if (fs.existsSync(logsPath)) {
    const logFiles = fs
    .readdirSync(logsPath)
    .filter((file) => file !== "latest.log" && file.endsWith(".log"));

    let deletedCount = 0;

    for (const file of logFiles) {
    try {
    fs.unlinkSync(path.join(logsPath, file));
    deletedCount++;
    } catch (error) {
    console.error(`Failed to delete log file ${file}:`, error);
    }
    }

    console.log(`Deleted ${deletedCount} archived log files`);
    }

    // Log the clearing action
    saveLog("All logs cleared by user", "INFO", false);

    return true;
    } catch (error) {
    console.error("Failed to clear logs:", error);
    return false;
    }
    }