/* * Copyright (C) 2025 dwlr * * BSD 3-Clause License (BSD-3-Clause) * See LICENSE for details */ typedef enum log_kind { LK_DEBUG, LK_INFO, LK_WARN, LK_ERROR, LK_FATAL, LK_ENUM_LEN } log_kind; static char* log_kind_names[LK_ENUM_LEN] = { "DEBUG", "INFO", "WARN", "ERROR", "FATAL", }; #define DBG LK_DEBUG, __FILE__, __LINE__ #define INFO LK_INFO, __FILE__, __LINE__ #define WARN LK_WARN, __FILE__, __LINE__ #define ERR LK_ERROR, __FILE__, __LINE__ #define FATAL LK_FATAL, __FILE__, __LINE__ void report(log_kind kind, const char* file, int line, const char* fmt, ...) { va_list ap; /* TODO: log levels */ printf("[%s] %s:%d - ", log_kind_names[kind], file, line); va_start(ap, fmt); vprintf(fmt, ap); va_end(ap); if(kind == LK_FATAL) abort(); }