Commit e2d912eb4a37d964cfb486c61f922e355fdab1e3

Rusty Russell 2011-07-06T16:44:36

vapplog: new helper function for reporting errors.

diff --git a/miner.h b/miner.h
index d6f400f..c386c17 100644
--- a/miner.h
+++ b/miner.h
@@ -253,6 +253,7 @@ struct work {
 
 bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
 
+extern void vapplog(int prio, const char *fmt, va_list ap);
 extern void applog(int prio, const char *fmt, ...);
 extern struct thread_q *tq_new(void);
 extern void tq_free(struct thread_q *tq);
diff --git a/util.c b/util.c
index ca0ca79..db3c127 100644
--- a/util.c
+++ b/util.c
@@ -57,12 +57,8 @@ struct thread_q {
 	pthread_cond_t		cond;
 };
 
-void applog(int prio, const char *fmt, ...)
+void vapplog(int prio, const char *fmt, va_list ap)
 {
-	va_list ap;
-
-	va_start(ap, fmt);
-
 #ifdef HAVE_SYSLOG_H
 	if (use_syslog) {
 		vsyslog(prio, fmt, ap);
@@ -96,8 +92,15 @@ void applog(int prio, const char *fmt, ...)
 		vfprintf(stderr, f, ap);	/* atomic write to stderr */
 		fflush(stderr);
 	}
+}
+
+void applog(int prio, const char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	vapplog(prio, fmt, ap);
 	va_end(ap);
-	fflush(stderr);
 }
 
 static void databuf_free(struct data_buffer *db)