summaryrefslogtreecommitdiff
path: root/src/logerr.c
blob: fac87f0d7d03ad0056cdad99c7b0503c5fa525bf (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
#include "config.h"

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

#include "logerr.h"



void
vlogerr(
	const char *const file,
	const char *const function,
	const int lineno,
	FILE *restrict stream,
	const char *restrict format,
	...
) {
	if (fprintf(stream, "%s:%s:%d: ", file, function, lineno) < 0) {
		perror(__FILE__ ":vlogerr(): fprintf() < 0");
	}

	va_list args;
	va_start(args, format);
	if (vfprintf(stream, format, args) < 0) {
		perror(__FILE__ ":vlogerr(): vfprintf() < 0");
	}
	va_end(args);

	if (fprintf(stream, "\n") < 0) {
		perror(__FILE__ ":vlogerr(): fprintf() < 0");
	}
}