#include #include #include #include "log.h" static const char *log_levels[] = { "info", "warning", "error", "fatal", }; void log_msg(enum log_level level, const char *namespace, const char *format, ...) { va_list args; va_start(args, format); fprintf(stderr, "%s: %s: ", log_levels[level], namespace); vfprintf(stderr, format, args); fprintf(stderr, "\n"); if (level == LOG_ERROR) { exit(EXIT_FAILURE); } else if (level == LOG_FATAL) { abort(); } va_end(args); }