dvb_loginfo log support without setting output color. Signed-off-by: André Roth <neolynx@xxxxxxxxx> --- lib/include/dvb-log.h | 3 +++ lib/libdvbv5/dvb-log.c | 26 +++++++++++++------------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/include/dvb-log.h b/lib/include/dvb-log.h index a72adce..755167a 100644 --- a/lib/include/dvb-log.h +++ b/lib/include/dvb-log.h @@ -38,6 +38,9 @@ typedef void (*dvb_logfunc)(int level, const char *fmt, ...) __attribute__ (( fo #define dvb_logwarn(fmt, arg...) do {\ parms->logfunc(LOG_WARNING, fmt, ##arg); \ } while (0) +#define dvb_loginfo(fmt, arg...) do {\ + parms->logfunc(LOG_NOTICE, fmt, ##arg); \ +} while (0) #define dvb_perror(msg) do {\ diff --git a/lib/libdvbv5/dvb-log.c b/lib/libdvbv5/dvb-log.c index 87d92f2..8bb34ca 100644 --- a/lib/libdvbv5/dvb-log.c +++ b/lib/libdvbv5/dvb-log.c @@ -30,15 +30,15 @@ static const struct loglevel { const char *color; int fd; } loglevels[9] = { - {"EMERG ", "\033[31m", STDERR_FILENO }, - {"ALERT ", "\033[31m", STDERR_FILENO }, - {"CRITICAL", "\033[31m", STDERR_FILENO }, - {"ERROR ", "\033[31m", STDERR_FILENO }, - {"WARNING ", "\033[33m", STDOUT_FILENO }, - {"NOTICE ", "\033[36m", STDOUT_FILENO }, - {"INFO ", "\033[36m", STDOUT_FILENO }, - {"DEBUG ", "\033[32m", STDOUT_FILENO }, - {"", "\033[0m", STDOUT_FILENO }, + {"EMERG ", "\033[31m", STDERR_FILENO }, + {"ALERT ", "\033[31m", STDERR_FILENO }, + {"CRITICAL ", "\033[31m", STDERR_FILENO }, + {"ERROR ", "\033[31m", STDERR_FILENO }, + {"WARNING ", "\033[33m", STDOUT_FILENO }, + {"", "\033[36m", STDOUT_FILENO }, /* NOTICE */ + {"", NULL, STDOUT_FILENO }, /* INFO */ + {"DEBUG ", "\033[32m", STDOUT_FILENO }, + {"", "\033[0m", STDOUT_FILENO }, /* reset*/ }; #define LOG_COLOROFF 8 @@ -49,14 +49,14 @@ void dvb_default_log(int level, const char *fmt, ...) va_list ap; va_start(ap, fmt); FILE *out = stdout; - if(STDERR_FILENO == loglevels[level].fd) + if (STDERR_FILENO == loglevels[level].fd) out = stderr; - if(isatty(loglevels[level].fd)) + if (loglevels[level].color && isatty(loglevels[level].fd)) fputs(loglevels[level].color, out); - fprintf(out, "%s ", loglevels[level].name); + fprintf(out, "%s", loglevels[level].name); vfprintf(out, fmt, ap); fprintf(out, "\n"); - if(isatty(loglevels[level].fd)) + if(loglevels[level].color && isatty(loglevels[level].fd)) fputs(loglevels[LOG_COLOROFF].color, out); va_end(ap); } -- 1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html