vapplog: new helper function for reporting errors.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
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)