[conf/logger] Log error message from libconfuse in forked-daapd log

This commit is contained in:
chme 2019-06-15 12:08:56 +02:00
parent 9351d905f2
commit 94af51f19b
3 changed files with 29 additions and 0 deletions

View File

@ -206,6 +206,19 @@ uid_t runas_uid;
gid_t runas_gid;
static void
logger_confuse(cfg_t *cfg, const char *format, va_list args)
{
char fmt[80];
if (cfg && cfg->name && cfg->line)
snprintf(fmt, sizeof(fmt), "[%s:%d] %s\n", cfg->name, cfg->line, format);
else
snprintf(fmt, sizeof(fmt), "%s\n", format);
DVPRINTF(E_LOG, L_CONF, fmt, args);
}
static int
cb_loglevel(cfg_t *cfg, cfg_opt_t *opt, const char *value, void *result)
{
@ -355,6 +368,8 @@ conffile_load(char *file)
cfg = cfg_init(toplvl_cfg, CFGF_NONE);
cfg_set_error_function(cfg, logger_confuse);
ret = cfg_parse(cfg, file);
if (ret == CFG_FILE_ERROR)

View File

@ -174,6 +174,17 @@ DPRINTF(int severity, int domain, const char *fmt, ...)
va_end(ap);
}
void
DVPRINTF(int severity, int domain, const char *fmt, va_list ap)
{
// If domain and severity do not match the current log configuration, return early to
// safe some unnecessary code execution (tiny performance gain)
if (logger_initialized && (!((1 << domain) & logdomains) || (severity > threshold)))
return;
vlogger(severity, domain, fmt, ap);
}
void
logger_ffmpeg(void *ptr, int level, const char *fmt, va_list ap)
{

View File

@ -52,6 +52,9 @@
void
DPRINTF(int severity, int domain, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
void
DVPRINTF(int severity, int domain, const char *fmt, va_list ap);
void
logger_ffmpeg(void *ptr, int level, const char *fmt, va_list ap);