diff --git a/debian/changelog b/debian/changelog index d1e6858f..4e2e960c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -36,6 +36,10 @@ hts-tvheadend (2.8) hts; urgency=low Use the '-c' command line option for this. By default Tvheadend puts configuration at $HOME/.hts/tvheadend + * Make it possible to enable debug level log in the web interface. + Press the small top-right gear icon in the log console to enable/disable + debug log. + hts-tvheadend (2.7) hts; urgency=low * Added support for DVB subtitles. Currently only forwarded over HTSP diff --git a/src/main.c b/src/main.c index ca431106..7cc5b7d2 100644 --- a/src/main.c +++ b/src/main.c @@ -72,7 +72,6 @@ static int log_stderr; static int log_decorate; int log_debug_to_syslog; -int log_debug_to_comet; int log_debug_to_console; static char confpath[256]; @@ -504,7 +503,7 @@ tvhlogv(int notify, int severity, const char *subsys, const char *fmt, /** * Send notification to Comet (Push interface to web-clients) */ - if(notify && (log_debug_to_comet || severity < LOG_DEBUG)) { + if(notify) { htsmsg_t *m; time(&now); @@ -515,7 +514,7 @@ tvhlogv(int notify, int severity, const char *subsys, const char *fmt, m = htsmsg_create_map(); htsmsg_add_str(m, "notificationClass", "logmessage"); htsmsg_add_str(m, "logtxt", buf2); - comet_mailbox_add_message(m); + comet_mailbox_add_message(m, severity == LOG_DEBUG); htsmsg_destroy(m); } diff --git a/src/notify.c b/src/notify.c index 9f4046f8..2f096bf6 100644 --- a/src/notify.c +++ b/src/notify.c @@ -30,6 +30,6 @@ void notify_by_msg(const char *class, htsmsg_t *m) { htsmsg_add_str(m, "notificationClass", class); - comet_mailbox_add_message(m); + comet_mailbox_add_message(m, 0); htsmsg_destroy(m); } diff --git a/src/webui/comet.c b/src/webui/comet.c index 66f58f6f..312b6af7 100644 --- a/src/webui/comet.c +++ b/src/webui/comet.c @@ -54,7 +54,7 @@ typedef struct comet_mailbox { htsmsg_t *cmb_messages; /* A vector */ time_t cmb_last_used; LIST_ENTRY(comet_mailbox) cmb_link; - + int cmb_debug; } comet_mailbox_t; @@ -229,13 +229,52 @@ comet_mailbox_poll(http_connection_t *hc, const char *remain, void *opaque) } +/** + * Poll callback + */ +static int +comet_mailbox_dbg(http_connection_t *hc, const char *remain, void *opaque) +{ + comet_mailbox_t *cmb = NULL; + const char *cometid = http_arg_get(&hc->hc_req_args, "boxid"); + + if(cometid == NULL) + return 400; + + pthread_mutex_lock(&comet_mutex); + + LIST_FOREACH(cmb, &mailboxes, cmb_link) { + if(!strcmp(cmb->cmb_boxid, cometid)) { + char buf[64]; + cmb->cmb_debug = !cmb->cmb_debug; + + if(cmb->cmb_messages == NULL) + cmb->cmb_messages = htsmsg_create_list(); + + htsmsg_t *m = htsmsg_create_map(); + htsmsg_add_str(m, "notificationClass", "logmessage"); + snprintf(buf, sizeof(buf), "Loglevel debug: %sabled", + cmb->cmb_debug ? "en" : "dis"); + htsmsg_add_str(m, "logtxt", buf); + htsmsg_add_msg(cmb->cmb_messages, NULL, m); + + pthread_cond_broadcast(&comet_cond); + } + } + pthread_mutex_unlock(&comet_mutex); + + http_output_content(hc, "text/plain; charset=UTF-8"); + return 0; +} + /** * */ void comet_init(void) { - http_path_add("/comet", NULL, comet_mailbox_poll, ACCESS_WEB_INTERFACE); + http_path_add("/comet/poll", NULL, comet_mailbox_poll, ACCESS_WEB_INTERFACE); + http_path_add("/comet/debug", NULL, comet_mailbox_dbg, ACCESS_WEB_INTERFACE); } @@ -243,7 +282,7 @@ comet_init(void) * */ void -comet_mailbox_add_message(htsmsg_t *m) +comet_mailbox_add_message(htsmsg_t *m, int isdebug) { comet_mailbox_t *cmb; @@ -251,6 +290,9 @@ comet_mailbox_add_message(htsmsg_t *m) LIST_FOREACH(cmb, &mailboxes, cmb_link) { + if(isdebug && !cmb->cmb_debug) + continue; + if(cmb->cmb_messages == NULL) cmb->cmb_messages = htsmsg_create_list(); htsmsg_add_msg(cmb->cmb_messages, NULL, htsmsg_copy(m)); diff --git a/src/webui/static/app/comet.js b/src/webui/static/app/comet.js index c7305289..a24bb3b3 100644 --- a/src/webui/static/app/comet.js +++ b/src/webui/static/app/comet.js @@ -17,18 +17,18 @@ Ext.extend(tvheadend.Comet = function() { }, Ext.util.Observable); tvheadend.comet = new tvheadend.Comet(); +tvheadend.boxid = null; tvheadend.cometPoller = function() { var failures = 0; - var boxid = null; var cometRequest = new Ext.util.DelayedTask(function() { Ext.Ajax.request({ - url: 'comet', + url: 'comet/poll', params : { - boxid: (boxid ? boxid : null), + boxid: (tvheadend.boxid ? tvheadend.boxid : null), immediate: failures > 0 ? 1 : 0 }, success: function(result, request) { @@ -55,7 +55,7 @@ tvheadend.cometPoller = function() { function parse_comet_response(responsetxt) { response = Ext.util.JSON.decode(responsetxt); - boxid = response.boxid + tvheadend.boxid = response.boxid for(x = 0; x < response.messages.length; x++) { m = response.messages[x]; tvheadend.comet.fireEvent(m.notificationClass, m); diff --git a/src/webui/static/app/tvheadend.js b/src/webui/static/app/tvheadend.js index a2c5f462..bb2ed299 100644 --- a/src/webui/static/app/tvheadend.js +++ b/src/webui/static/app/tvheadend.js @@ -131,7 +131,19 @@ tvheadend.app = function() { maxSize: 400, collapsible: true, title:'System log', - margins:'0 0 0 0' + margins:'0 0 0 0', + tools:[{ + id:'gear', + qtip: 'Enable debug output', + handler: function(event, toolEl, panel){ + Ext.Ajax.request({ + url: 'comet/debug', + params : { + boxid: tvheadend.boxid + } + }); + } + }] },tvheadend.rootTabPanel ] }); diff --git a/src/webui/webui.h b/src/webui/webui.h index 10d9ac02..48020bb7 100644 --- a/src/webui/webui.h +++ b/src/webui/webui.h @@ -33,7 +33,7 @@ void extjs_start(void); */ void comet_init(void); -void comet_mailbox_add_message(htsmsg_t *m); +void comet_mailbox_add_message(htsmsg_t *m, int isdebug); void comet_flush(void);