summary refs log tree commit diff
path: root/logging.h
blob: 0e676dd13a6e3c684e642d93280e68ec5967b7b5 (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
#include <stdarg.h>
#include <unistd.h>
#include <time.h>

static void
aura_printf(const char *fmt, ...)
{
	char timestr[20] = { 0 };
	va_list args = { 0 };
	struct tm *m = { 0 };
	time_t stamp = 0;

	stamp = time(NULL);
	m = localtime(&stamp);
	strftime((char *)&timestr, 20, "%G-%m-%d %H:%M:%S", m);

	printf("{%s} [%d] ", (char *)&timestr, getpid());
	va_start(args, fmt);
	vprintf(fmt, args);
	va_end(args);

	return;
}

static void
aura_fprintf(FILE *stream, const char *fmt, ...)
{
	va_list args = { 0 };

	fprintf(stream, "[%d] ", getpid());
	va_start(args, fmt);
	vfprintf(stream, fmt, args);
	va_end(args);

	return;
}