From: Mark Wooding Date: Fri, 5 Feb 2016 00:30:46 +0000 (+0000) Subject: yaid.c (logmsg): Split out a version which takes a captured argument list. X-Git-Tag: 1.0.4~5 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/yaid/commitdiff_plain/a8eb4066035f3b4fadb48e8cdf21252c3b73d9c7 yaid.c (logmsg): Split out a version which takes a captured argument list. --- diff --git a/yaid.c b/yaid.c index 13e1208..d2244b6 100644 --- a/yaid.c +++ b/yaid.c @@ -222,26 +222,21 @@ static void init_writebuf(struct writebuf *wb, /*----- General utilities -------------------------------------------------*/ -/* Format and log MSG somewhere sensible, at the syslog(3) priority PRIO. - * Prefix it with a description of the query Q, if non-null. - */ -void logmsg(const struct query *q, int prio, const char *msg, ...) +static void vlogmsg(const struct query *q, int prio, + const char *msg, va_list *ap) { - va_list ap; dstr d = DSTR_INIT; time_t t; struct tm *tm; char buf[64]; - va_start(ap, msg); if (q) { dputsock(&d, q->ao, &q->s[L]); dstr_puts(&d, " <-> "); dputsock(&d, q->ao, &q->s[R]); dstr_puts(&d, ": "); } - dstr_vputf(&d, msg, &ap); - va_end(ap); + dstr_vputf(&d, msg, ap); if (!(flags & F_RUNNING)) moan("%s", d.buf); @@ -257,6 +252,18 @@ void logmsg(const struct query *q, int prio, const char *msg, ...) dstr_destroy(&d); } +/* Format and log MSG somewhere sensible, at the syslog(3) priority PRIO. + * Prefix it with a description of the query Q, if non-null. + */ +void logmsg(const struct query *q, int prio, const char *msg, ...) +{ + va_list ap; + + va_start(ap, msg); + vlogmsg(q, prio, msg, &ap); + va_end(ap); +} + /* Fix up a socket FD so that it won't bite us. Returns zero on success, or * nonzero on error. */