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 cc_log_executed_command(char **argv);
void fatal(const char *format, ...) ATTR_FORMAT(printf, 1, 2);
static FILE *logfile;
-static int init_log()
+static int init_log(void)
{
extern char *cache_logfile;
}
}
-static void log_va_list(const char *format, va_list ap)
+static void log_prefix(void)
{
- if (!init_log()) {
- return;
- }
-
fprintf(logfile, "[%-5d] ", getpid());
- vfprintf(logfile, format, ap);
}
/*
- * Log a message to the CCACHE_LOGFILE location without newline and without
- * flushing.
+ * Write a message to the CCACHE_LOGFILE location (adding a newline).
*/
-void cc_log_no_newline(const char *format, ...)
+void cc_log(const char *format, ...)
{
- if (!init_log()) {
- return;
- }
-
va_list ap;
- va_start(ap, format);
- 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, ...)
-{
if (!init_log()) {
return;
}
- va_list ap;
+ log_prefix();
va_start(ap, format);
- log_va_list(format, ap);
+ vfprintf(logfile, format, ap);
va_end(ap);
fprintf(logfile, "\n");
fflush(logfile);
}
+/*
+ * Log an executed command to the CCACHE_LOGFILE location.
+ */
void cc_log_executed_command(char **argv)
{
if (!init_log()) {
return;
}
- cc_log_no_newline("Executing ");
+ log_prefix();
+ fprintf(logfile, "Executing ");
print_command(logfile, argv);
fflush(logfile);
}