]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
tvhlog: remove notify argument, use LOG_TVH_NOTIFY mask instead
authorJaroslav Kysela <perex@perex.cz>
Tue, 16 Aug 2016 08:55:43 +0000 (10:55 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 16 Aug 2016 08:55:43 +0000 (10:55 +0200)
src/dvr/dvr_db.c
src/packet.c
src/tvhlog.c
src/tvhlog.h

index 0ea475786e3fc9eaa701159ca26279506d0fac74..dba3ec439d1ef2af6de4de8533b6ab75d0afbc9e 100644 (file)
@@ -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);
 }
 
index 6eb6b683fe1438a732de5bfd0cc28170432ae68a..84bd8948647fffcc728d543f118e4e98f06f72c3 100644 (file)
@@ -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);
 }
 
index 466f7696f2ac4773979d0af7fb862dc821cd1741..4931d7b6009196179415c6dd330faf266e536a33 100644 (file)
@@ -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;
   }
index 3636ded6cac0969ad0daf90839c1a39fa3cc98cc..748f73720d9cd5533222d80d01a064a6a3db2502 100644 (file)
@@ -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; }