/* Comet (debug must still be enabled??) */
if (msg->notify && msg->severity < LOG_TRACE) {
- htsmsg_t *m = htsmsg_create_map();
snprintf(buf, sizeof(buf), "%s %s", t, msg->msg);
+ comet_mailbox_add_logmsg(buf, msg->severity >= LOG_DEBUG, 0);
+
+ htsmsg_t *m = htsmsg_create_map();
htsmsg_add_str(m, "notificationClass", "logmessage");
htsmsg_add_str(m, "logtxt", buf);
comet_mailbox_add_message(m, msg->severity >= LOG_DEBUG, 0);
typedef struct comet_mailbox {
char *cmb_boxid; /* SHA-1 hash */
char *cmb_lang; /* UI language */
+ int cmb_restricted; /* !admin */
htsmsg_t *cmb_messages; /* A vector */
int64_t cmb_last_used;
LIST_ENTRY(comet_mailbox) cmb_link;
comet_mailbox_t *cmb = NULL;
const char *cometid = http_arg_get(&hc->hc_req_args, "boxid");
const char *immediate = http_arg_get(&hc->hc_req_args, "immediate");
+ const char *lang = hc->hc_access->aa_lang_ui;
int im = immediate ? atoi(immediate) : 0, e;
int64_t mono;
htsmsg_t *m;
break;
if(cmb == NULL) {
- cmb = comet_mailbox_create(hc->hc_access->aa_lang_ui);
+ cmb = comet_mailbox_create(lang);
comet_access_update(hc, cmb);
comet_serverIpPort(hc, cmb);
}
cmb->cmb_last_used = 0; /* Make sure we're not flushed out */
+ if (http_access_verify(hc, ACCESS_ADMIN)) {
+ if (!cmb->cmb_restricted) {
+ pthread_mutex_unlock(&comet_mutex);
+ comet_mailbox_add_logmsg(tvh_gettext_lang(lang, N_("Restricted log mode (no administrator)")), 0, 0);
+ pthread_mutex_lock(&comet_mutex);
+ cmb->cmb_restricted = 1;
+ }
+ }
if(!im && cmb->cmb_messages == NULL) {
mono = mclk() + sec2mono(10);
{
comet_mailbox_t *cmb = NULL;
const char *cometid = http_arg_get(&hc->hc_req_args, "boxid");
+ const char *lang = hc->hc_access->aa_lang_ui;
+ const char *s;
if(cometid == NULL)
return 400;
if(cmb->cmb_messages == NULL)
cmb->cmb_messages = htsmsg_create_list();
-
+
+ if(cmb->cmb_restricted || http_access_verify(hc, ACCESS_ADMIN))
+ s = N_("Only admin can watch the realtime log.");
+ else if(cmb->cmb_debug)
+ s = N_("Loglevel debug: enabled");
+ else
+ s = N_("Loglevel debug: disabled");
+ snprintf(buf, sizeof(buf), "%s", tvh_gettext_lang(lang, s));
+
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);
-
+
tvh_cond_signal(&comet_cond, 1);
+ break;
}
}
pthread_mutex_unlock(&comet_mutex);
if (atomic_get(&comet_running)) {
LIST_FOREACH(cmb, &mailboxes, cmb_link) {
- if(isdebug && !cmb->cmb_debug)
+ if(cmb->cmb_restricted)
continue;
+ if(isdebug && !cmb->cmb_debug)
+ continue;
+
if(cmb->cmb_messages == NULL)
cmb->cmb_messages = htsmsg_create_list();
e = htsmsg_copy(m);
pthread_mutex_unlock(&comet_mutex);
}
+
+/**
+ *
+ */
+void
+comet_mailbox_add_logmsg(const char *txt, int isdebug, int rewrite)
+{
+ htsmsg_t *m = htsmsg_create_map();
+ htsmsg_add_str(m, "notificationClass", "logmessage");
+ htsmsg_add_str(m, "logtxt", txt);
+ comet_mailbox_add_message(m, isdebug, 0);
+ htsmsg_destroy(m);
+}