From 37ca1a0cf161ad30356e08d5886eaf4b8bc43882 Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Fri, 29 Jul 2011 21:15:05 +0200 Subject: [PATCH] Add cc_log_without_flush --- ccache.h | 2 ++ util.c | 36 +++++++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/ccache.h b/ccache.h index 7b86589e8..29f04dbd4 100644 --- a/ccache.h +++ b/ccache.h @@ -99,7 +99,9 @@ bool hash_file(struct mdfour *md, const char *fname); /* ------------------------------------------------------------------------- */ /* util.c */ +void cc_vlog(const char *format, va_list ap); void cc_log(const char *format, ...) ATTR_FORMAT(printf, 1, 2); +void cc_log_without_flush(const char *format, ...) ATTR_FORMAT(printf, 1, 2); void cc_log_argv(const char *prefix, char **argv); void fatal(const char *format, ...) ATTR_FORMAT(printf, 1, 2); void copy_fd(int fd_in, int fd_out); diff --git a/util.c b/util.c index a9ace6e34..d6be41e87 100644 --- a/util.c +++ b/util.c @@ -98,23 +98,45 @@ path_max(const char *path) } /* - * Write a message to the CCACHE_LOGFILE location (adding a newline). + * Write a message to the log file (adding a newline) and flush. */ void -cc_log(const char *format, ...) +cc_vlog(const char *format, va_list ap) { - va_list ap; - if (!init_log()) { return; } log_prefix(); - va_start(ap, format); vfprintf(logfile, format, ap); - va_end(ap); fprintf(logfile, "\n"); - fflush(logfile); +} + +/* + * Write a message to the log file (adding a newline) and flush. + */ +void +cc_log(const char *format, ...) +{ + va_list ap; + va_start(ap, format); + cc_vlog(format, ap); + va_end(ap); + if (logfile) { + fflush(logfile); + } +} + +/* + * Write a message to the log file (adding a newline). + */ +void +cc_log_without_flush(const char *format, ...) +{ + va_list ap; + va_start(ap, format); + cc_vlog(format, ap); + va_end(ap); } /* -- 2.47.3