aboutsummaryrefslogtreecommitdiff
path: root/common/log.c
blob: 847f3952a84e6b0577e8e068d09313d0099dc501 (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
26
27
28
29
30
31
#include <signal.h>
#include <stdarg.h>
#include <stdlib.h>
#include "log.h"

void sway_terminate(int code);

void _sway_abort(const char *format, ...) {
	va_list args;
	va_start(args, format);
	_wlr_vlog(WLR_ERROR, format, args);
	va_end(args);
	sway_terminate(EXIT_FAILURE);
}

bool _sway_assert(bool condition, const char *format, ...) {
	if (condition) {
		return true;
	}

	va_list args;
	va_start(args, format);
	_wlr_vlog(WLR_ERROR, format, args);
	va_end(args);

#ifndef NDEBUG
	raise(SIGABRT);
#endif

	return false;
}