summaryrefslogtreecommitdiffstats
path: root/lib/log/log.c
blob: 41b44cc10ff9e02aa227d7ae0e4ccd3592052265 (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

#include <stdarg.h>

#include "log.h"

static FILE *logf;
static int always_flush;

void pb_log(const char *fmt, ...)
{
	va_list ap;
	FILE *stream;

	stream = logf ? logf : stdout;

	va_start(ap, fmt);
	vfprintf(stream, fmt, ap);
	va_end(ap);

	if (always_flush)
		fflush(stream);
}

void pb_log_set_stream(FILE *stream)
{
	fflush(logf ? logf : stdout);
	logf = stream;
}

void pb_log_always_flush(int state)
{
	always_flush = state;
}
OpenPOWER on IntegriCloud