@@ -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;
+}
@@ -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 */
Flush the pb_log stream when the stream is changed, and add an option to flush the pb_log stream on every write. Useful while debugging. Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com> --- lib/log.c | 10 ++++++++++ lib/log.h | 1 + 2 files changed, 11 insertions(+)