From: Jaroslav Kysela Date: Tue, 16 Aug 2016 08:55:43 +0000 (+0200) Subject: tvhlog: remove notify argument, use LOG_TVH_NOTIFY mask instead X-Git-Tag: v4.2.1~381 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=09e982e63af3289710554137a22db1b668c9de62;p=thirdparty%2Ftvheadend.git tvhlog: remove notify argument, use LOG_TVH_NOTIFY mask instead --- diff --git a/src/dvr/dvr_db.c b/src/dvr/dvr_db.c index 0ea475786..dba3ec439 100644 --- a/src/dvr/dvr_db.c +++ b/src/dvr/dvr_db.c @@ -95,7 +95,7 @@ dvr_entry_trace_(const char *file, int line, dvr_entry_t *de, const char *fmt, . snprintf(buf, sizeof(buf), "entry %s - %s", idnode_uuid_as_str(&de->de_id, ubuf), fmt); - tvhlogv(file, line, 0, LOG_TRACE, "dvr", buf, &args); + tvhlogv(file, line, LOG_TRACE, "dvr", buf, &args); va_end(args); } @@ -120,7 +120,7 @@ dvr_entry_trace_time2_(const char *file, int line, t2name ? " " : "", t2name ? gmtime2local(t2, t2buf, sizeof(t2buf)) : "", fmt); - tvhlogv(file, line, 0, LOG_TRACE, "dvr", buf, &args); + tvhlogv(file, line, LOG_TRACE, "dvr", buf, &args); va_end(args); } diff --git a/src/packet.c b/src/packet.c index 6eb6b683f..84bd89486 100644 --- a/src/packet.c +++ b/src/packet.c @@ -175,7 +175,7 @@ pkt_trace_(const char *file, int line, const char *subsys, th_pkt_t *pkt, pktbuf_len(pkt->pkt_payload), pkt->pkt_err, fmt ? ")" : ""); - tvhlogv(file, line, 0, LOG_TRACE, subsys, buf, &args); + tvhlogv(file, line, LOG_TRACE, subsys, buf, &args); va_end(args); } diff --git a/src/tvhlog.c b/src/tvhlog.c index 466f7696f..4931d7b60 100644 --- a/src/tvhlog.c +++ b/src/tvhlog.c @@ -175,7 +175,7 @@ tvhlog_process } /* Comet (debug must still be enabled??) */ - if(msg->notify && msg->severity < LOG_TRACE) { + if (msg->notify && msg->severity < LOG_TRACE) { htsmsg_t *m = htsmsg_create_map(); snprintf(buf, sizeof(buf), "%s %s", t, msg->msg); htsmsg_add_str(m, "notificationClass", "logmessage"); @@ -263,14 +263,16 @@ tvhlog_thread ( void *p ) return NULL; } -void tvhlogv ( const char *file, int line, - int notify, int severity, +void tvhlogv ( const char *file, int line, int severity, const char *subsys, const char *fmt, va_list *args ) { - int ok, options; + int ok, options, notify; size_t l; char buf[1024]; + notify = (severity & LOG_TVH_NOTIFY) ? 1 : 0; + severity &= ~LOG_TVH_NOTIFY; + pthread_mutex_lock(&tvhlog_mutex); /* Check for full */ @@ -350,13 +352,12 @@ void tvhlogv ( const char *file, int line, /* * Map args */ -void _tvhlog ( const char *file, int line, - int notify, int severity, +void _tvhlog ( const char *file, int line, int severity, const char *subsys, const char *fmt, ... ) { va_list args; va_start(args, fmt); - tvhlogv(file, line, notify, severity, subsys, fmt, &args); + tvhlogv(file, line, severity, subsys, fmt, &args); va_end(args); } @@ -365,10 +366,8 @@ void _tvhlog ( const char *file, int line, */ #define HEXDUMP_WIDTH 16 void -_tvhlog_hexdump(const char *file, int line, - int notify, int severity, - const char *subsys, - const uint8_t *data, ssize_t len ) +_tvhlog_hexdump(const char *file, int line, int severity, + const char *subsys, const uint8_t *data, ssize_t len ) { int i, c; char str[1024]; @@ -395,7 +394,7 @@ _tvhlog_hexdump(const char *file, int line, c++; } str[c] = '\0'; - tvhlogv(file, line, notify, severity, subsys, str, NULL); + tvhlogv(file, line, severity, subsys, str, NULL); len -= HEXDUMP_WIDTH; data += HEXDUMP_WIDTH; } diff --git a/src/tvhlog.h b/src/tvhlog.h index 3636ded6c..748f73720 100644 --- a/src/tvhlog.h +++ b/src/tvhlog.h @@ -54,17 +54,13 @@ void tvhlog_set_debug ( const char *subsys ); void tvhlog_get_debug ( char *subsys, size_t len ); void tvhlog_set_trace ( const char *subsys ); void tvhlog_get_trace ( char *subsys, size_t len ); -void tvhlogv ( const char *file, int line, - int notify, int severity, +void tvhlogv ( const char *file, int line, int severity, const char *subsys, const char *fmt, va_list *args ); -void _tvhlog ( const char *file, int line, - int notify, int severity, +void _tvhlog ( const char *file, int line, int severity, const char *subsys, const char *fmt, ... ) - __attribute__((format(printf,6,7))); -void _tvhlog_hexdump ( const char *file, int line, - int notify, int severity, - const char *subsys, - const uint8_t *data, ssize_t len ); + __attribute__((format(printf,5,6))); +void _tvhlog_hexdump ( const char *file, int line, int severity, + const char *subsys, const uint8_t *data, ssize_t len ); static inline void tvhlog_limit_reset ( tvhlog_limit_t *limit ) { limit->last = 0; limit->count = 0; } static inline int tvhlog_limit ( tvhlog_limit_t *limit, uint32_t delay ) @@ -91,22 +87,24 @@ static inline int tvhlog_limit ( tvhlog_limit_t *limit, uint32_t delay ) #define LOG_TRACE (LOG_DEBUG+1) #endif +#define LOG_TVH_NOTIFY 0x40000000 + /* Macros */ #define tvhlog(severity, subsys, fmt, ...)\ - _tvhlog(__FILE__, __LINE__, 1, severity, subsys, fmt, ##__VA_ARGS__) + _tvhlog(__FILE__, __LINE__, severity | LOG_TVH_NOTIFY, subsys, fmt, ##__VA_ARGS__) #define tvhlog_spawn(severity, subsys, fmt, ...)\ - _tvhlog(__FILE__, __LINE__, 0, severity, subsys, fmt, ##__VA_ARGS__) + _tvhlog(__FILE__, __LINE__, severity, subsys, fmt, ##__VA_ARGS__) #if ENABLE_TRACE #define tvhtrace_enabled() (LOG_TRACE <= atomic_get(&tvhlog_level)) #define tvhtrace(subsys, fmt, ...) \ do { \ if (tvhtrace_enabled()) \ - _tvhlog(__FILE__, __LINE__, 0, LOG_TRACE, subsys, fmt, ##__VA_ARGS__); \ + _tvhlog(__FILE__, __LINE__, LOG_TRACE, subsys, fmt, ##__VA_ARGS__); \ } while (0) #define tvhlog_hexdump(subsys, data, len) \ do { \ if (tvhtrace_enabled()) \ - _tvhlog_hexdump(__FILE__, __LINE__, 0, LOG_TRACE, subsys, (uint8_t*)data, len); \ + _tvhlog_hexdump(__FILE__, __LINE__, LOG_TRACE, subsys, (uint8_t*)data, len); \ } while (0) #else static inline void tvhtrace_no_warnings(const char *fmt, ...) { (void)fmt; }