aboutsummaryrefslogtreecommitdiff
path: root/src/log.c
blob: 0e59ea25b058cf7e24cc2dbc690ae074af74f585 (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
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>

#include <log.h>

void errln(struct ctx_location *location, const char *fmt, ...)
{
	fprintf(stderr, "\x1B[1;36m%s:%lu:%lu:\x1B[0m ", location->path, location->line + 1,
		location->column + 1);

	fprintf(stderr, "\x1B[1;31mError:\x1B[0m ");

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

	fprintf(stderr, "\n");
	context_print(stderr, location);

	exit(1);
}