summaryrefslogtreecommitdiffstats
path: root/lib/log
diff options
context:
space:
mode:
Diffstat (limited to 'lib/log')
-rw-r--r--lib/log/log.c10
-rw-r--r--lib/log/log.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/log/log.c b/lib/log/log.c
index e006fd0..41b44cc 100644
--- a/lib/log/log.c
+++ b/lib/log/log.c
@@ -4,6 +4,7 @@
#include "log.h"
static FILE *logf;
+static int always_flush;
void pb_log(const char *fmt, ...)
{
@@ -15,9 +16,18 @@ void pb_log(const char *fmt, ...)
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;
+}
diff --git a/lib/log/log.h b/lib/log/log.h
index 3e92555..813a19e 100644
--- a/lib/log/log.h
+++ b/lib/log/log.h
@@ -5,5 +5,6 @@
void pb_log(const char *fmt, ...);
void pb_log_set_stream(FILE *stream);
+void pb_log_always_flush(int state);
#endif /* _LOG_H */
OpenPOWER on IntegriCloud