From a13fe254f2c9e6c103802160fd1d76617baab349 Mon Sep 17 00:00:00 2001 From: Martin Lund Date: Sat, 23 Jul 2022 09:53:08 +0200 Subject: [PATCH] Enable line buffering of log Replace flushing/writing of log at every log write operation with line buffering, meaning log will be written line by line to make it more I/O friendly but still update frequently. --- src/log.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/log.c b/src/log.c index 73dd493..aa86847 100644 --- a/src/log.c +++ b/src/log.c @@ -76,8 +76,8 @@ void log_open(const char *filename) exit(EXIT_FAILURE); } - // Enable full buffering - setvbuf(fp, file_buffer, _IOFBF, BUFSIZ); + // Enable line buffering + setvbuf(fp, file_buffer, _IOLBF, BUFSIZ); } bool log_strip(char c) @@ -149,7 +149,6 @@ void log_printf(const char *format, ...) va_end(args); fwrite(line, strlen(line), 1, fp); - fflush(fp); free(line); } @@ -170,7 +169,6 @@ void log_putc(char c) fputc(c, fp); } } - fflush(fp); } void log_close(void)