Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
tvhlog: remove notify argument, use LOG_TVH_NOTIFY mask instead
  • Loading branch information
perexg committed Aug 16, 2016
1 parent eb90c21 commit 09e982e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/dvr/dvr_db.c
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/packet.c
Expand Up @@ -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);
}

Expand Down
23 changes: 11 additions & 12 deletions src/tvhlog.c
Expand Up @@ -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");
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
}

Expand All @@ -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];
Expand All @@ -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;
}
Expand Down
24 changes: 11 additions & 13 deletions src/tvhlog.h
Expand Up @@ -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 )
Expand All @@ -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; }
Expand Down

0 comments on commit 09e982e

Please sign in to comment.