tic2mqtt-c/logger.c
2021-08-21 15:15:21 +02:00

33 lines
500 B
C

#include "logger.h"
#include <stdio.h>
#include <stdarg.h>
static char* log_level_str[] = {
[LOG_DEBUG] = "DEBUG",
[LOG_INFO] = "INFO",
[LOG_WARNING] = "WARNING",
[LOG_ERROR] = "ERROR",
};
static int log_level;
void set_loglevel(int level)
{
log_level = level;
}
void logger(int priority, const char *fmt, ...)
{
if (priority < log_level)
return;
printf("%s: ", log_level_str[priority]);
va_list args;
va_start(args, fmt);
vprintf(fmt, args);
va_end(args);
}