]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Add cc_log_without_flush
authorJoel Rosdahl <joel@rosdahl.net>
Fri, 29 Jul 2011 19:15:05 +0000 (21:15 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Fri, 29 Jul 2011 19:15:05 +0000 (21:15 +0200)
ccache.h
util.c

index 7b86589e8cd6cba82c7c543974d980476e7bb67d..29f04dbd4fb94add991f3405854906231ced1a2e 100644 (file)
--- 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 a9ace6e34e646b7a77b6128fcb35a30029d91c81..d6be41e87c2ebd691b9db65b3d87e17832a35c93 100644 (file)
--- 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);
 }
 
 /*