]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Introduce cc_log_no_newline function
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 9 May 2010 20:43:04 +0000 (22:43 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 9 May 2010 20:43:04 +0000 (22:43 +0200)
ccache.h
util.c

index 0e2429051ff7127002f1d4bda7abd0f3e4979d51..a3072dfecc1d5e08e622c0a99782a3491b434e43 100644 (file)
--- a/ccache.h
+++ b/ccache.h
@@ -65,6 +65,7 @@ char *hash_result(struct mdfour *md);
 void hash_result_as_bytes(struct mdfour *md, unsigned char *out);
 void hash_buffer(struct mdfour *md, const void *s, size_t len);
 
+void cc_log_no_newline(const char *format, ...) ATTR_FORMAT(printf, 1, 2);
 void cc_log(const char *format, ...) ATTR_FORMAT(printf, 1, 2);
 void fatal(const char *format, ...) ATTR_FORMAT(printf, 1, 2);
 
diff --git a/util.c b/util.c
index ccbbc5a6f0208bcbe68600b1f8add6723311e80a..9f90efd9f6673c433e6d6d482644f6df7e743fcf 100644 (file)
--- a/util.c
+++ b/util.c
 
 static FILE *logfile;
 
-/* log a message to the CCACHE_LOGFILE location */
-void cc_log(const char *format, ...)
+static void cc_log_va_list(const char *format, va_list ap)
 {
-       va_list ap;
        extern char *cache_logfile;
 
        if (!cache_logfile) return;
@@ -54,8 +52,29 @@ void cc_log(const char *format, ...)
        if (!logfile) return;
 
        fprintf(logfile, "[%-5d] ", getpid());
-       va_start(ap, format);
        vfprintf(logfile, format, ap);
+}
+
+/*
+ * Log a message to the CCACHE_LOGFILE location without newline and without
+ * flushing.
+ */
+void cc_log_no_newline(const char *format, ...)
+{
+       va_list ap;
+       va_start(ap, format);
+       cc_log_va_list(format, ap);
+       va_end(ap);
+}
+
+/*
+ * Log a message to the CCACHE_LOGFILE location adding a newline and flushing.
+ */
+void cc_log(const char *format, ...)
+{
+       va_list ap;
+       va_start(ap, format);
+       cc_log_va_list(format, ap);
        va_end(ap);
        fprintf(logfile, "\n");
        fflush(logfile);