Turn DPRINTF into a wrapper to a generic logging function
DPRINTF() made a generic logging function taking a va_list called vlogger() and reimplemented as a wrapper on top of vlogger().
This commit is contained in:
parent
c3a5222f84
commit
512731c9dc
16
src/logger.c
16
src/logger.c
|
@ -70,7 +70,7 @@ set_logdomains(char *domains)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DPRINTF(int severity, int domain, char *fmt, ...)
|
vlogger(int severity, int domain, char *fmt, va_list args)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char stamp[32];
|
char stamp[32];
|
||||||
|
@ -97,7 +97,7 @@ DPRINTF(int severity, int domain, char *fmt, ...)
|
||||||
|
|
||||||
fprintf(logfile, "[%s] %6s: ", stamp, labels[domain]);
|
fprintf(logfile, "[%s] %6s: ", stamp, labels[domain]);
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_copy(ap, args);
|
||||||
vfprintf(logfile, fmt, ap);
|
vfprintf(logfile, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ DPRINTF(int severity, int domain, char *fmt, ...)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%6s: ", labels[domain]);
|
fprintf(stderr, "%6s: ", labels[domain]);
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_copy(ap, args);
|
||||||
vfprintf(stderr, fmt, ap);
|
vfprintf(stderr, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
@ -114,6 +114,16 @@ DPRINTF(int severity, int domain, char *fmt, ...)
|
||||||
pthread_mutex_unlock(&logger_lck);
|
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
|
void
|
||||||
logger_libevent(int severity, const char *msg)
|
logger_libevent(int severity, const char *msg)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
#ifndef __LOGGER_H__
|
#ifndef __LOGGER_H__
|
||||||
#define __LOGGER_H__
|
#define __LOGGER_H__
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
/* Log domains */
|
/* Log domains */
|
||||||
#define L_CONF 0
|
#define L_CONF 0
|
||||||
#define L_DAAP 1
|
#define L_DAAP 1
|
||||||
|
@ -30,6 +32,9 @@
|
||||||
#define E_SPAM 5
|
#define E_SPAM 5
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
vlogger(int severity, int domain, char *fmt, va_list args);
|
||||||
|
|
||||||
void
|
void
|
||||||
DPRINTF(int severity, int domain, char *fmt, ...);
|
DPRINTF(int severity, int domain, char *fmt, ...);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue