Log libevent errors through our own logger

This commit is contained in:
Julien BLACHE 2009-05-08 18:17:01 +02:00
parent 11f18eaf6f
commit c3a5222f84
3 changed files with 42 additions and 3 deletions

View File

@ -23,6 +23,8 @@
#include <errno.h>
#include <pthread.h>
#include <event.h>
#include "logger.h"
@ -32,7 +34,7 @@ static int threshold;
static int console;
static char *logfilename;
static FILE *logfile;
static char *labels[] = { "config", "daap", "db", "httpd", "main", "mdns", "misc", "parse", "rsp", "scan", "xcode", "lock" };
static char *labels[] = { "config", "daap", "db", "httpd", "main", "mdns", "misc", "parse", "rsp", "scan", "xcode", "event", "lock" };
static int
@ -112,6 +114,35 @@ DPRINTF(int severity, int domain, char *fmt, ...)
pthread_mutex_unlock(&logger_lck);
}
void
logger_libevent(int severity, const char *msg)
{
switch (severity)
{
case _EVENT_LOG_DEBUG:
severity = E_DBG;
break;
case _EVENT_LOG_ERR:
severity = E_LOG;
break;
case _EVENT_LOG_WARN:
severity = E_WARN;
break;
case _EVENT_LOG_MSG:
severity = E_INFO;
break;
default:
severity = E_LOG;
break;
}
DPRINTF(severity, L_EVENT, "%s\n", msg);
}
void
logger_reinit(void)
{

View File

@ -14,10 +14,12 @@
#define L_RSP 8
#define L_SCAN 9
#define L_XCODE 10
/* libevent logging */
#define L_EVENT 11
/* Will go away */
#define L_LOCK 11
#define N_LOGDOMAINS 12
#define L_LOCK 12
#define N_LOGDOMAINS 13
/* Severities */
#define E_FATAL 0
@ -31,6 +33,9 @@
void
DPRINTF(int severity, int domain, char *fmt, ...);
void
logger_libevent(int severity, const char *msg);
void
logger_reinit(void);

View File

@ -447,6 +447,9 @@ int main(int argc, char *argv[]) {
exit(EXIT_FAILURE);
}
/* Set up libevent logging callback */
event_set_log_callback(logger_libevent);
DPRINTF(E_LOG, L_MAIN, "Firefly Version %s taking off\n", VERSION);
/* initialize ffmpeg */