blob: ecbd7142d2e5c14ce1f5847d2bb93a6e467790df (
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
|
#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 : stderr;
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 : stderr);
logf = stream;
}
FILE * pb_log_get_stream(void)
{
return logf ? logf : stderr;
}
void pb_log_always_flush(int state)
{
always_flush = state;
}
|