fix recording daemon logging levels

fixes a variable name collision and also converts AV_LOG constants to
their respective LOG_ values

closes #344

Change-Id: Ie577250fe1191619df9f8a4b38744c43d1ee8e4f
changes/69/12269/4
Richard Fuchs 8 years ago
parent af7b2d0508
commit 27af349783

@ -38,10 +38,10 @@ void __ilog_np(int prio, const char *format, ...) __attribute__ ((format (printf
#ifndef __DEBUG
#define ilog(prio, fmt, ...) \
do { \
int loglevel = get_log_level(); \
if (LOG_LEVEL_MASK((prio)) > LOG_LEVEL_MASK(loglevel)) \
int __loglevel = get_log_level(); \
if (LOG_LEVEL_MASK((prio)) > LOG_LEVEL_MASK(__loglevel)) \
break; \
if ((loglevel & LOG_FLAG_RESTORE) && !((prio) & LOG_FLAG_RESTORE)) \
if ((__loglevel & LOG_FLAG_RESTORE) && !((prio) & LOG_FLAG_RESTORE)) \
break; \
__ilog(prio, fmt, ##__VA_ARGS__); \
} while (0)

@ -9,6 +9,7 @@
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavfilter/avfilter.h>
#include <libavutil/log.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <mysql.h>
@ -60,11 +61,27 @@ static void avlog_ilog(void *ptr, int loglevel, const char *fmt, va_list ap) {
if (vasprintf(&msg, fmt, ap) <= 0)
ilog(LOG_ERR, "av_log message dropped");
else {
#ifdef AV_LOG_PANIC
// translate AV_LOG_ constants to LOG_ levels
if (loglevel >= AV_LOG_VERBOSE)
loglevel = LOG_DEBUG;
else if (loglevel >= AV_LOG_INFO)
loglevel = LOG_NOTICE;
else if (loglevel >= AV_LOG_WARNING)
loglevel = LOG_WARNING;
else if (loglevel >= AV_LOG_ERROR)
loglevel = LOG_ERROR;
else if (loglevel >= AV_LOG_FATAL)
loglevel = LOG_CRIT;
else
loglevel = LOG_ALERT;
#else
// defuse avlog log levels to be either DEBUG or ERR
if (loglevel <= LOG_ERR)
loglevel = LOG_ERR;
else
loglevel = LOG_DEBUG;
#endif
ilog(loglevel, "av_log: %s", msg);
free(msg);
}

Loading…
Cancel
Save