From c049689884d733cae58bd3096391cb9e92a2d146 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 7 Jun 2021 15:46:38 +1000 Subject: [PATCH] logger: set linebuffering for the log Set this once during setup so we don't have to remember to call fflush() after each logging operation. Signed-off-by: Peter Hutterer --- spa/plugins/support/logger.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spa/plugins/support/logger.c b/spa/plugins/support/logger.c index ca6ff5504..fa042c11d 100644 --- a/spa/plugins/support/logger.c +++ b/spa/plugins/support/logger.c @@ -157,8 +157,6 @@ impl_log_logv(void *object, } else fputs(location, impl->file); - fflush(impl->file); - #undef RESERVED_LENGTH } @@ -202,7 +200,6 @@ static void on_trace_event(struct spa_source *source) fwrite(impl->trace_data, avail - first, 1, impl->file); } spa_ringbuffer_read_update(&impl->trace_rb, index + avail); - fflush(impl->file); } } @@ -318,6 +315,8 @@ impl_init(const struct spa_handle_factory *factory, spa_log_debug(&this->log, NAME " %p: initialized", this); + setlinebuf(this->file); + return 0; }