Add cc_log_without_flush

This commit is contained in:
Joel Rosdahl 2011-07-29 21:15:05 +02:00
parent 72206bb1df
commit 37ca1a0cf1
2 changed files with 31 additions and 7 deletions

View File

@ -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);

36
util.c
View File

@ -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);
}
/*