diff --git a/src/logger.c b/src/logger.c index d2b2d8d2..f90e7425 100644 --- a/src/logger.c +++ b/src/logger.c @@ -70,7 +70,7 @@ set_logdomains(char *domains) } void -DPRINTF(int severity, int domain, char *fmt, ...) +vlogger(int severity, int domain, char *fmt, va_list args) { va_list ap; char stamp[32]; @@ -97,7 +97,7 @@ DPRINTF(int severity, int domain, char *fmt, ...) fprintf(logfile, "[%s] %6s: ", stamp, labels[domain]); - va_start(ap, fmt); + va_copy(ap, args); vfprintf(logfile, fmt, ap); va_end(ap); } @@ -106,7 +106,7 @@ DPRINTF(int severity, int domain, char *fmt, ...) { fprintf(stderr, "%6s: ", labels[domain]); - va_start(ap, fmt); + va_copy(ap, args); vfprintf(stderr, fmt, ap); va_end(ap); } @@ -114,6 +114,16 @@ DPRINTF(int severity, int domain, char *fmt, ...) pthread_mutex_unlock(&logger_lck); } +void +DPRINTF(int severity, int domain, char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vlogger(severity, domain, fmt, ap); + va_end(ap); +} + void logger_libevent(int severity, const char *msg) { diff --git a/src/logger.h b/src/logger.h index 319406bd..7221f262 100644 --- a/src/logger.h +++ b/src/logger.h @@ -2,6 +2,8 @@ #ifndef __LOGGER_H__ #define __LOGGER_H__ +#include + /* Log domains */ #define L_CONF 0 #define L_DAAP 1 @@ -30,6 +32,9 @@ #define E_SPAM 5 +void +vlogger(int severity, int domain, char *fmt, va_list args); + void DPRINTF(int severity, int domain, char *fmt, ...);