summaryrefslogtreecommitdiffstats
path: root/src/ccapi/test/test_ccapi_log.c
blob: 8ecb6931f243ec3c2b99b745151f8be3ce7c0532 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef _TEST_CCAPI_LOG_C_
#define _TEST_CCAPI_LOG_C_

#include "test_ccapi_log.h"

void _log_error_v(const char *file, int line, const char *format, va_list ap)
{
	fprintf(stdout, "\n\t%s:%d: ", file, line);
	if (!format) {
		fprintf(stdout, "An unknown error occurred");
	} else {
		vfprintf(stdout, format, ap);
	}
	fflush(stdout);
}

void _log_error(const char *file, int line, const char *format, ...)
{
	va_list ap;
	va_start(ap, format);
	_log_error_v(file, line, format, ap);
	va_end(ap);
}

void test_header(const char *msg) {
	if (msg != NULL) {
		fprintf(stdout, "\nChecking %s... ", msg);
		fflush(stdout);
	}
}

void test_footer(const char *msg, int err) {
	if (msg != NULL) {
		if (!err) {
			fprintf(stdout, "OK\n");
		}
		else {
			fprintf(stdout, "\n*** %d failure%s in %s ***\n", err, (err == 1) ? "" : "s", msg);
		}
	}
}



#endif /* _TEST_CCAPI_LOG_C_ */