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 <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2021-06-07 15:46:38 +10:00 committed by Wim Taymans
parent 1c083a6d69
commit c049689884

View file

@ -157,8 +157,6 @@ impl_log_logv(void *object,
} else } else
fputs(location, impl->file); fputs(location, impl->file);
fflush(impl->file);
#undef RESERVED_LENGTH #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); fwrite(impl->trace_data, avail - first, 1, impl->file);
} }
spa_ringbuffer_read_update(&impl->trace_rb, index + avail); 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); spa_log_debug(&this->log, NAME " %p: initialized", this);
setlinebuf(this->file);
return 0; return 0;
} }