aboutsummaryrefslogtreecommitdiff
path: root/src/log.c
blob: 281c5073527434da627205a5e2dd833dd9bfa552 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "log.h"

#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <stdbool.h>

static enum log_level log_verbosity = LOG_INFO;

void
log_set_verbosity(enum log_level lvl)
{
	log_verbosity = lvl;
}

void
log_printf(enum log_level lvl, const char *restrict fmt, ...)
{
	if (lvl > log_verbosity) return;
	FILE   *out = lvl < LOG_INFO ? stderr : stdout;
	va_list args;
	va_start(args, fmt);
	vfprintf(out, fmt, args);
	va_end(args);
}