diff --git a/src/main.c b/src/main.c index 7cac3c19..54a9a22c 100644 --- a/src/main.c +++ b/src/main.c @@ -63,6 +63,7 @@ pthread_mutex_t global_lock; pthread_mutex_t ffmpeg_lock; static int log_stderr; static int log_decorate; +int log_debug; static void handle_sigpipe(int x) @@ -163,6 +164,7 @@ usage(const char *argv0) " it will allow world-wide administrative access\n" " to your Tvheadend installation until you edit\n" " the access-control from within the Tvheadend UI\n"); + printf(" -d Debug logging"); printf("\n"); printf("For more information read the man page or visit\n"); printf(" http://www.lonelycoder.com/hts/\n"); @@ -227,7 +229,7 @@ main(int argc, char **argv) const char *contentpath = TVHEADEND_CONTENT_PATH; const char *homedir = NULL; - while((c = getopt(argc, argv, "fu:g:c:Ch")) != -1) { + while((c = getopt(argc, argv, "fu:g:c:Chd")) != -1) { switch(c) { case 'f': forkaway = 1; @@ -241,6 +243,9 @@ main(int argc, char **argv) case 'c': contentpath = optarg; break; + case 'd': + log_debug = 1; + break; case 'C': createdefault = 1; break; diff --git a/src/tvhead.h b/src/tvhead.h index c0e327a9..421644f3 100644 --- a/src/tvhead.h +++ b/src/tvhead.h @@ -621,6 +621,13 @@ void tvhlog_spawn(int severity, const char *subsys, const char *fmt, ...); #define LOG_INFO 6 /* informational */ #define LOG_DEBUG 7 /* debug-level messages */ +extern int log_debug; + +#define DEBUGLOG(subsys, fmt...) do { \ + if(log_debug) \ + tvhlog(LOG_DEBUG, subsys, fmt); \ +} while(0) + static inline int64_t getclock_hires(void)