#include "log.h" void log_print(LogLevel level, const char* format, ...) { time_t now = time(NULL); struct tm *t = localtime(&now); const char* level_tag; switch(level) { case LOG_INFO: level_tag = "INF"; break; case LOG_DEBUG: level_tag = "DBG"; break; case LOG_ERROR: level_tag = "ERR"; break; case LOG_WARN: level_tag = "WRN"; break; default: level_tag = "UNK"; break; } // %02d ensures it prints "05" instead of just "5" printf("[%02d:%02d:%02d %s] ", t->tm_hour, t->tm_min, t->tm_sec, level_tag); va_list args; va_start(args, format); vprintf(format, args); // vprintf takes a va_list instead of ... va_end(args); }