#include "debug.h"
#include <stdint.h>
#include "stdio.h"
#include <stdarg.h>

static const uint32_t g_LogSeverityColors[] =
{
    [LVL_DEBUG]    = 0xAAAAAA, // light gray
    [LVL_INFO]     = 0xFFFFFF, // white
    [LVL_WARN]     = 0xFFFF00, // yellow
    [LVL_ERROR]    = 0xFF0000, // red
    [LVL_CRITICAL] = 0xFFFFFF, // white (can do red background separately if you want)
};


static const char* const g_ColorReset = "\033[0m";

void logf(const char* module, DebugLevel level, const char* fmt, ...) {
    va_list args;
    va_start(args, fmt);

    uint32_t color = g_LogSeverityColors[level];

    fputs_colored("[", color);
    fputs_colored(module, color);
    fputs_colored("] ", color);

    // print formatted text in same color
    vfprintf(fmt, args);  // or adapt vfprintf to take a color

    fputc('\n');

    va_end(args);
}