aboutsummaryrefslogtreecommitdiff
path: root/src/log.c
blob: a34c8e8a8bf5bfe13ced6463483fe40b2bb92332 (plain) (blame)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) 2023, Marvin Borner <dev@marvinborner.de>
// SPDX-License-Identifier: MIT

#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>

#include <log.h>

static int debug_enabled = 0;

void debug(const char *format, ...)
{
	if (!debug_enabled)
		return;

	fprintf(stderr, "[DEBUG] ");

	va_list ap;
	va_start(ap, format);
	vfprintf(stderr, format, ap);
	va_end(ap);
}

void debug_enable(int enable)
{
	debug_enabled = enable;
}

void fatal(const char *format, ...)
{
	fprintf(stderr, "[FATAL] ");

	va_list ap;
	va_start(ap, format);
	vfprintf(stderr, format, ap);
	va_end(ap);

	abort();
}