3 #include <QProgressDialog>
7 #include "cetlib/filepath_maker.h"
8 #include "fhiclcpp/ParameterSet.h"
10 #include "mfextensions/Binaries/mvdlg.hh"
12 #if GCC_VERSION >= 701000 || defined(__clang__)
13 #pragma GCC diagnostic push
14 #pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
17 #define TRACE_NAME "MessageViewer"
18 #include "TRACE/trace.h"
20 #if GCC_VERSION >= 701000 || defined(__clang__)
21 #pragma GCC diagnostic pop
28 static void process_fname(std::string& fname)
30 size_t sub_start = fname.find(
"${");
31 size_t sub_end = fname.find(
"}");
33 const size_t npos = std::string::npos;
35 if ((sub_start == npos && sub_end != npos) || (sub_start != npos && sub_end == npos) || (sub_start > sub_end))
37 throw std::runtime_error(
"Unrecognized configuration file. Use default configuration instead.");
40 if (sub_start == npos)
return;
42 std::string env = std::string(getenv(fname.substr(sub_start + 2, sub_end - sub_start - 2).c_str()));
43 fname.replace(sub_start, sub_end - sub_start + 1, env);
48 static fhicl::ParameterSet readConf(std::string
const& fname)
50 if (fname.empty())
return fhicl::ParameterSet();
52 std::string filename = fname;
53 process_fname(filename);
55 std::string env(
"FHICL_FILE_PATH=");
57 if (filename[0] ==
'/')
66 char* mfe_path = getenv(
"MFEXTENSIONS_DIR");
67 if (mfe_path) env.append(
":").append(mfe_path).append(
"/config");
75 cet::filepath_lookup policy(
"FHICL_FILE_PATH");
78 fhicl::ParameterSet pset = fhicl::ParameterSet::make(filename, policy);
84 : QDialog(parent), paused(false), shortMode_(false), nMsgs(0), nSupMsgs(0), nThrMsgs(0), nFilters(0), nDeleted(0), simpleRender(true), searchStr(
""), msg_pool_(), host_msgs_(), cat_msgs_(), app_msgs_(), sup_menu(new QMenu(this)), thr_menu(new QMenu(this)), receivers_(readConf(conf).get<fhicl::ParameterSet>(
"receivers", fhicl::ParameterSet()))
92 fhicl::ParameterSet pset = readConf(conf);
98 btnSuppression->setMenu(sup_menu);
99 btnThrottling->setMenu(thr_menu);
102 connect(btnPause, SIGNAL(clicked()),
this, SLOT(
pause()));
103 connect(btnScrollToBottom, SIGNAL(clicked()),
this, SLOT(scrollToBottom()));
104 connect(btnExit, SIGNAL(clicked()),
this, SLOT(
exit()));
105 connect(btnClear, SIGNAL(clicked()),
this, SLOT(
clear()));
107 connect(btnRMode, SIGNAL(clicked()),
this, SLOT(renderMode()));
108 connect(btnDisplayMode, SIGNAL(clicked()),
this, SLOT(
shortMode()));
110 connect(btnSearch, SIGNAL(clicked()),
this, SLOT(searchMsg()));
111 connect(btnSearchClear, SIGNAL(clicked()),
this, SLOT(searchClear()));
113 connect(btnFilter, SIGNAL(clicked()),
this, SLOT(setFilter()));
115 connect(btnError, SIGNAL(clicked()),
this, SLOT(setSevError()));
116 connect(btnWarning, SIGNAL(clicked()),
this, SLOT(setSevWarning()));
117 connect(btnInfo, SIGNAL(clicked()),
this, SLOT(setSevInfo()));
118 connect(btnDebug, SIGNAL(clicked()),
this, SLOT(setSevDebug()));
120 connect(sup_menu, SIGNAL(triggered(QAction*)),
this, SLOT(setSuppression(QAction*)));
122 connect(thr_menu, SIGNAL(triggered(QAction*)),
this, SLOT(setThrottling(QAction*)));
124 connect(vsSeverity, SIGNAL(valueChanged(
int)),
this, SLOT(
changeSeverity(
int)));
126 connect(&receivers_, SIGNAL(newMessage(msg_ptr_t)),
this, SLOT(onNewMsg(msg_ptr_t)));
128 connect(tabWidget, SIGNAL(currentChanged(
int)),
this, SLOT(tabWidgetCurrentChanged(
int)));
129 connect(tabWidget, SIGNAL(tabCloseRequested(
int)),
this, SLOT(tabCloseRequested(
int)));
130 MsgFilterDisplay allMessages;
131 allMessages.txtDisplay = txtMessages;
132 allMessages.nDisplayMsgs = 0;
133 allMessages.filterExpression =
"";
134 allMessages.nDisplayedDeletedMsgs = 0;
135 allMessages.sevThresh = SINFO;
136 msgFilters_.push_back(allMessages);
139 auto tabBar = tabWidget->findChild<QTabBar*>();
140 tabBar->setTabButton(0, QTabBar::RightSide,
nullptr);
141 tabBar->setTabButton(0, QTabBar::LeftSide,
nullptr);
144 btnRMode->setChecked(
true);
146 btnRMode->setChecked(
false);
148 btnRMode->setEnabled(
false);
152 auto doc =
new QTextDocument(txtMessages);
153 txtMessages->setDocument(doc);
158 msgViewerDlg::~msgViewerDlg()
164 static void str_to_suppress(std::vector<std::string>
const& vs, std::vector<suppress>& s, QMenu* menu)
170 act = menu->addAction(
"None");
171 act->setEnabled(
false);
175 s.reserve(vs.size());
177 for (
size_t i = 0; i < vs.size(); ++i)
179 s.emplace_back(vs[i]);
180 act = menu->addAction(QString(vs[i].c_str()));
181 act->setCheckable(
true);
182 act->setChecked(
true);
183 QVariant v = qVariantFromValue(static_cast<void*>(&s[i]));
188 static void pset_to_throttle(std::vector<fhicl::ParameterSet>
const& ps, std::vector<throttle>& t, QMenu* menu)
194 act = menu->addAction(
"None");
195 act->setEnabled(
false);
199 t.reserve(ps.size());
201 for (
size_t i = 0; i < ps.size(); ++i)
203 auto name = ps[i].get<std::string>(
"name");
204 t.emplace_back(name, ps[i].get<int>(
"limit", -1), ps[i].get<int64_t>(
"timespan", -1));
205 act = menu->addAction(QString(name.c_str()));
206 act->setCheckable(
true);
207 act->setChecked(
true);
208 QVariant v = qVariantFromValue(static_cast<void*>(&t[i]));
213 void msgViewerDlg::parseConf(fhicl::ParameterSet
const& conf)
215 fhicl::ParameterSet nulp;
219 auto sup = conf.get<fhicl::ParameterSet>(
"suppress", nulp);
221 auto sup_host = sup.get<std::vector<std::string>>(
"hosts", std::vector<std::string>());
222 auto sup_app = sup.get<std::vector<std::string>>(
"applications", std::vector<std::string>());
223 auto sup_cat = sup.get<std::vector<std::string>>(
"categories", std::vector<std::string>());
225 str_to_suppress(sup_host, e_sup_host, sup_menu);
226 sup_menu->addSeparator();
228 str_to_suppress(sup_app, e_sup_app, sup_menu);
229 sup_menu->addSeparator();
231 str_to_suppress(sup_cat, e_sup_cat, sup_menu);
234 auto thr = conf.get<fhicl::ParameterSet>(
"throttle", nulp);
236 auto thr_host = thr.get<std::vector<fhicl::ParameterSet>>(
"hosts", std::vector<fhicl::ParameterSet>());
237 auto thr_app = thr.get<std::vector<fhicl::ParameterSet>>(
"applications", std::vector<fhicl::ParameterSet>());
238 auto thr_cat = thr.get<std::vector<fhicl::ParameterSet>>(
"categories", std::vector<fhicl::ParameterSet>());
240 pset_to_throttle(thr_host, e_thr_host, thr_menu);
241 thr_menu->addSeparator();
243 pset_to_throttle(thr_app, e_thr_app, thr_menu);
244 thr_menu->addSeparator();
246 pset_to_throttle(thr_cat, e_thr_cat, thr_menu);
248 maxMsgs = conf.get<
size_t>(
"max_message_buffer_size", 100000);
249 maxDeletedMsgs = conf.get<
size_t>(
"max_displayed_deleted_messages", 100000);
252 bool msgViewerDlg::msg_throttled(msg_ptr_t
const& msg)
258 for (
size_t i = 0; i < e_sup_host.size(); ++i)
259 if (e_sup_host[i].match(msg->host().toStdString()))
return true;
261 for (
size_t i = 0; i < e_sup_app.size(); ++i)
262 if (e_sup_app[i].match(msg->app().toStdString()))
return true;
264 for (
size_t i = 0; i < e_sup_cat.size(); ++i)
265 if (e_sup_cat[i].match(msg->cat().toStdString()))
return true;
273 for (
size_t i = 0; i < e_thr_host.size(); ++i)
274 if (e_thr_host[i].reach_limit(msg->host().toStdString(), msg->time()))
return true;
276 for (
size_t i = 0; i < e_thr_app.size(); ++i)
277 if (e_thr_app[i].reach_limit(msg->app().toStdString(), msg->time()))
return true;
279 for (
size_t i = 0; i < e_thr_cat.size(); ++i)
280 if (e_thr_cat[i].reach_limit(msg->cat().toStdString(), msg->time()))
return true;
287 void msgViewerDlg::writeSettings()
289 QSettings settings(
"ARTDAQ",
"MsgViewer");
291 settings.beginGroup(
"MainWindow");
292 settings.setValue(
"size", size());
293 settings.setValue(
"pos", pos());
297 void msgViewerDlg::readSettings()
299 QSettings settings(
"ARTDAQ",
"MsgViewer");
301 settings.beginGroup(
"MainWindow");
302 QPoint pos = settings.value(
"pos", QPoint(100, 100)).toPoint();
303 QSize size = settings.value(
"size", QSize(660, 760)).toSize();
309 void msgViewerDlg::onNewMsg(msg_ptr_t
const& msg)
316 lcdMsgs->display(nMsgs);
319 if (msg_throttled(msg))
321 lcdSuppressionCount->display(nSupMsgs);
322 lcdThrottlingCount->display(nThrMsgs);
329 msg_pool_.emplace_back(msg);
337 for (
size_t d = 0; d < msgFilters_.size(); ++d)
340 msgFilters_[d].hostFilter.contains(msg->host(), Qt::CaseInsensitive) || msgFilters_[d].hostFilter.empty();
342 msgFilters_[d].appFilter.contains(msg->app(), Qt::CaseInsensitive) || msgFilters_[d].appFilter.empty();
344 msgFilters_[d].catFilter.contains(msg->cat(), Qt::CaseInsensitive) || msgFilters_[d].catFilter.empty();
347 if (hostMatch && appMatch && catMatch)
351 msgFilters_[d].msgs.push_back(msg);
353 if ((
int)d == tabWidget->currentIndex())
359 void msgViewerDlg::trim_msg_pool()
361 bool host_list_update =
false;
362 bool app_list_update =
false;
363 bool cat_list_update =
false;
365 std::lock_guard<std::mutex> lk(msg_pool_mutex_);
366 while (maxMsgs > 0 && msg_pool_.size() > maxMsgs)
368 QString
const& app = msg_pool_.front()->app();
369 QString
const& cat = msg_pool_.front()->cat();
370 QString
const& host = msg_pool_.front()->host();
374 auto catIter = std::find(cat_msgs_[cat].begin(), cat_msgs_[cat].end(), msg_pool_.front());
375 auto hostIter = std::find(host_msgs_[host].begin(), host_msgs_[host].end(), msg_pool_.front());
376 auto appIter = std::find(app_msgs_[app].begin(), app_msgs_[app].end(), msg_pool_.front());
377 if (catIter != cat_msgs_[cat].end()) cat_msgs_[cat].erase(catIter);
378 if (hostIter != host_msgs_[host].end()) host_msgs_[host].erase(hostIter);
379 if (appIter != app_msgs_[app].end()) app_msgs_[app].erase(appIter);
381 if (app_msgs_[app].empty())
383 app_msgs_.erase(app);
384 app_list_update =
true;
386 if (cat_msgs_[cat].empty())
388 cat_msgs_.erase(cat);
389 cat_list_update =
true;
391 if (host_msgs_[host].empty())
393 host_msgs_.erase(host);
394 host_list_update =
true;
399 msg_pool_.erase(msg_pool_.begin());
404 std::lock_guard<std::mutex> lk(msg_classification_mutex_);
405 if (host_list_update)
406 updateList(lwHost, host_msgs_);
408 updateList(lwApplication, app_msgs_);
410 updateList(lwCategory, cat_msgs_);
413 for (
size_t d = 0; d < msgFilters_.size(); ++d)
416 std::lock_guard<std::mutex> lk(filter_mutex_);
417 while (msgFilters_[d].msgs.size() > maxMsgs)
419 if ((*msgFilters_[d].msgs.begin())->sev() >= msgFilters_[d].sevThresh)
420 msgFilters_[d].nDisplayedDeletedMsgs++;
421 msgFilters_[d].msgs.erase(msgFilters_[d].msgs.begin());
425 if ((
int)d == tabWidget->currentIndex())
427 if (maxDeletedMsgs > 0 && msgFilters_[d].nDisplayedDeletedMsgs > static_cast<int>(maxDeletedMsgs))
431 lcdDisplayedDeleted->display(msgFilters_[d].nDisplayedDeletedMsgs);
435 lcdDeletedCount->display(nDeleted);
438 void msgViewerDlg::update_index(msg_ptr_t
const& it)
440 std::lock_guard<std::mutex> lk(msg_classification_mutex_);
441 QString
const& app = it->app();
442 QString
const& cat = it->cat();
443 QString
const& host = it->host();
445 if (cat_msgs_.find(cat) == cat_msgs_.end())
447 cat_msgs_[cat].push_back(it);
448 updateList(lwCategory, cat_msgs_);
452 cat_msgs_[cat].push_back(it);
455 if (host_msgs_.find(host) == host_msgs_.end())
457 host_msgs_[host].push_back(it);
458 updateList(lwHost, host_msgs_);
462 host_msgs_[host].push_back(it);
465 if (app_msgs_.find(app) == app_msgs_.end())
467 app_msgs_[app].push_back(it);
468 updateList(lwApplication, app_msgs_);
472 app_msgs_[app].push_back(it);
476 void msgViewerDlg::displayMsg(msg_ptr_t
const& it,
int display)
478 if (it->sev() < msgFilters_[display].sevThresh)
return;
480 msgFilters_[display].nDisplayMsgs++;
481 if (display == tabWidget->currentIndex())
483 lcdDisplayedMsgs->display(msgFilters_[display].nDisplayMsgs);
486 auto txt = it->text(shortMode_);
489 UpdateTextAreaDisplay(txts, msgFilters_[display].txtDisplay);
492 void msgViewerDlg::displayMsgs(
int display)
494 msgFilters_[display].txtDisplay->clear();
495 msgFilters_[display].nDisplayMsgs = 0;
496 msgFilters_[display].nDisplayedDeletedMsgs = 0;
500 std::lock_guard<std::mutex> lk(filter_mutex_);
501 for (
auto it = msgFilters_[display].msgs.begin(); it != msgFilters_[display].msgs.end(); ++it)
503 if ((*it)->sev() >= msgFilters_[display].sevThresh)
505 txts.push_back((*it)->text(shortMode_));
506 ++msgFilters_[display].nDisplayMsgs;
510 if (display == tabWidget->currentIndex())
512 lcdDisplayedMsgs->display(msgFilters_[display].nDisplayMsgs);
514 UpdateTextAreaDisplay(txts, msgFilters_[display].txtDisplay);
518 void msgViewerDlg::UpdateTextAreaDisplay(QStringList
const& texts, QPlainTextEdit* widget)
520 const QTextCursor old_cursor = widget->textCursor();
521 const int old_scrollbar_value = widget->verticalScrollBar()->value();
522 const bool is_scrolled_down =
523 old_scrollbar_value >= widget->verticalScrollBar()->maximum() * 0.95;
525 if (!paused && !is_scrolled_down)
530 QTextCursor new_cursor = QTextCursor(widget->document());
532 new_cursor.beginEditBlock();
533 new_cursor.movePosition(QTextCursor::End);
535 for (
int i = 0; i < texts.size(); i++)
537 new_cursor.insertBlock();
538 new_cursor.insertHtml(texts.at(i));
539 if (!shortMode_) new_cursor.insertBlock();
541 new_cursor.endEditBlock();
543 if (old_cursor.hasSelection() || paused)
546 widget->setTextCursor(old_cursor);
547 widget->verticalScrollBar()->setValue(old_scrollbar_value);
552 widget->moveCursor(QTextCursor::End);
553 widget->verticalScrollBar()->setValue(widget->verticalScrollBar()->maximum());
554 widget->horizontalScrollBar()->setValue(0);
558 void msgViewerDlg::scrollToBottom()
560 int display = tabWidget->currentIndex();
561 msgFilters_[display].txtDisplay->moveCursor(QTextCursor::End);
562 msgFilters_[display].txtDisplay->verticalScrollBar()->setValue(
563 msgFilters_[display].txtDisplay->verticalScrollBar()->maximum());
564 msgFilters_[display].txtDisplay->horizontalScrollBar()->setValue(0);
567 void msgViewerDlg::updateDisplays()
569 for (
size_t ii = 0; ii < msgFilters_.size(); ++ii)
575 bool msgViewerDlg::updateList(QListWidget* lw, msgs_map_t
const& map)
577 bool nonSelectedBefore = (lw->currentRow() == -1);
578 bool nonSelectedAfter =
true;
580 QString item = nonSelectedBefore ?
"" : lw->currentItem()->text();
584 auto it = map.begin();
586 while (it != map.end())
588 lw->addItem(it->first);
589 if (!nonSelectedBefore && nonSelectedAfter)
591 if (item == it->first)
593 lw->setCurrentRow(row);
594 nonSelectedAfter =
false;
601 if (!nonSelectedBefore && nonSelectedAfter)
return true;
606 msgs_t msgViewerDlg::list_intersect(msgs_t
const& l1, msgs_t
const& l2)
609 auto it1 = l1.begin();
610 auto it2 = l2.begin();
612 while (it1 != l1.end() && it2 != l2.end())
618 else if (*it2 < *it1)
624 output.push_back(*it1);
630 TLOG(TLVL_DEBUG + 35) <<
"list_intersect: output list has " << output.size() <<
" entries";
634 std::string sev_to_string(sev_code_t s)
650 void msgViewerDlg::setFilter()
652 auto hostFilter = toQStringList(lwHost->selectedItems());
653 auto appFilter = toQStringList(lwApplication->selectedItems());
654 auto catFilter = toQStringList(lwCategory->selectedItems());
656 lwHost->setCurrentRow(-1, QItemSelectionModel::Clear);
657 lwApplication->setCurrentRow(-1, QItemSelectionModel::Clear);
658 lwCategory->setCurrentRow(-1, QItemSelectionModel::Clear);
660 if (hostFilter.isEmpty() && appFilter.isEmpty() && catFilter.isEmpty())
666 QString catFilterExpression =
"";
667 QString hostFilterExpression =
"";
668 QString appFilterExpression =
"";
671 for (
auto app = 0; app < appFilter.size(); ++app)
673 appFilterExpression += QString(first ?
"" :
" || ") + appFilter[app];
676 TLOG(TLVL_DEBUG + 35) <<
"setFilter: result contains %zu messages", result.size();
679 if (!hostFilter.isEmpty())
682 for (
auto host = 0; host < hostFilter.size(); ++host)
684 hostFilterExpression += QString(first ?
"" :
" || ") + hostFilter[host];
690 if (!catFilter.isEmpty())
693 for (
auto cat = 0; cat < catFilter.size(); ++cat)
695 catFilterExpression += QString(first ?
"" :
" || ") + catFilter[cat];
701 auto nFilterExpressions =
702 (appFilterExpression !=
"" ? 1 : 0) + (hostFilterExpression !=
"" ? 1 : 0) + (catFilterExpression !=
"" ? 1 : 0);
703 QString filterExpression =
"";
704 if (nFilterExpressions == 1)
706 filterExpression = catFilterExpression + hostFilterExpression + appFilterExpression;
710 filterExpression =
"(" + (catFilterExpression !=
"" ? catFilterExpression +
") && (" :
"") + hostFilterExpression +
711 (hostFilterExpression !=
"" && appFilterExpression !=
"" ?
") && (" :
"") + appFilterExpression +
715 for (
size_t d = 0; d < msgFilters_.size(); ++d)
717 if (msgFilters_[d].filterExpression == filterExpression)
719 tabWidget->setCurrentIndex(d);
725 std::lock_guard<std::mutex> lk(msg_classification_mutex_);
726 for (
auto app = 0; app < appFilter.size(); ++app)
728 auto it = app_msgs_.find(appFilter[app]);
729 if (it != app_msgs_.end())
731 msgs_t temp(it->second);
732 TLOG(TLVL_DEBUG + 35) <<
"setFilter: app " << appFilter[app].toStdString() <<
" has " << temp.size() <<
" messages";
736 TLOG(TLVL_DEBUG + 35) <<
"setFilter: result contains %zu messages", result.size();
738 if (!hostFilter.isEmpty())
741 for (
auto host = 0; host < hostFilter.size(); ++host)
743 auto it = host_msgs_.find(hostFilter[host]);
744 if (it != host_msgs_.end())
746 msgs_t temp(it->second);
747 TLOG(TLVL_DEBUG + 35) <<
"setFilter: host " << hostFilter[host].toStdString() <<
" has " << temp.size() <<
" messages";
748 hostResult.merge(temp);
757 result = list_intersect(result, hostResult);
759 TLOG(TLVL_DEBUG + 35) <<
"setFilter: result contains " << result.size() <<
" messages";
762 if (!catFilter.isEmpty())
765 for (
auto cat = 0; cat < catFilter.size(); ++cat)
767 auto it = cat_msgs_.find(catFilter[cat]);
768 if (it != cat_msgs_.end())
770 msgs_t temp(it->second);
771 TLOG(TLVL_DEBUG + 35) <<
"setFilter: cat " << catFilter[cat].toStdString() <<
" has " << temp.size() <<
" messages";
772 catResult.merge(temp);
781 result = list_intersect(result, catResult);
783 TLOG(TLVL_DEBUG + 35) <<
"setFilter: result contains " << result.size() <<
" messages";
789 auto newTabTitle = QString(
"Filter ") + QString::number(++nFilters);
790 auto newTab =
new QWidget();
792 auto txtDisplay =
new QPlainTextEdit(newTab);
793 auto doc =
new QTextDocument(txtDisplay);
794 txtDisplay->setDocument(doc);
796 auto layout =
new QVBoxLayout();
797 layout->addWidget(txtDisplay);
798 layout->setContentsMargins(0, 0, 0, 0);
799 newTab->setLayout(layout);
801 MsgFilterDisplay filteredMessages;
802 filteredMessages.msgs = result;
803 filteredMessages.hostFilter = hostFilter;
804 filteredMessages.appFilter = appFilter;
805 filteredMessages.catFilter = catFilter;
806 filteredMessages.filterExpression = filterExpression;
807 filteredMessages.txtDisplay = txtDisplay;
808 filteredMessages.nDisplayMsgs = result.size();
809 filteredMessages.nDisplayedDeletedMsgs = 0;
810 filteredMessages.sevThresh = SINFO;
812 std::lock_guard<std::mutex> lk(filter_mutex_);
813 msgFilters_.push_back(filteredMessages);
815 tabWidget->addTab(newTab, newTabTitle);
816 tabWidget->setTabToolTip(tabWidget->count() - 1, filterExpression);
817 tabWidget->setCurrentIndex(tabWidget->count() - 1);
819 displayMsgs(msgFilters_.size() - 1);
827 btnPause->setText(
"Resume Scrolling");
833 btnPause->setText(
"Pause Scrolling");
843 QMessageBox::question(
this, tr(
"Message Viewer"), tr(
"Are you sure you want to clear all received messages?"),
844 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
847 case QMessageBox::Yes:
853 std::lock_guard<std::mutex> lk(msg_pool_mutex_);
857 std::lock_guard<std::mutex> lk(msg_classification_mutex_);
861 updateList(lwApplication, app_msgs_);
862 updateList(lwCategory, cat_msgs_);
863 updateList(lwHost, host_msgs_);
865 for (
auto& display : msgFilters_)
867 std::lock_guard<std::mutex> lk(filter_mutex_);
868 display.txtDisplay->clear();
869 display.msgs.clear();
870 display.nDisplayMsgs = 0;
871 display.nDisplayedDeletedMsgs = 0;
874 lcdMsgs->display(nMsgs);
875 lcdDisplayedMsgs->display(0);
877 case QMessageBox::No:
888 btnDisplayMode->setText(
"Long View");
893 btnDisplayMode->setText(
"Compact View");
900 auto display = tabWidget->currentIndex();
919 displayMsgs(display);
922 void msgViewerDlg::setSevError()
924 auto display = tabWidget->currentIndex();
925 msgFilters_[display].sevThresh = SERROR;
926 btnError->setChecked(
true);
927 btnWarning->setChecked(
false);
928 btnInfo->setChecked(
false);
929 btnDebug->setChecked(
false);
930 vsSeverity->setValue(SERROR);
933 void msgViewerDlg::setSevWarning()
935 auto display = tabWidget->currentIndex();
936 msgFilters_[display].sevThresh = SWARNING;
937 btnError->setChecked(
false);
938 btnWarning->setChecked(
true);
939 btnInfo->setChecked(
false);
940 btnDebug->setChecked(
false);
941 vsSeverity->setValue(SWARNING);
944 void msgViewerDlg::setSevInfo()
946 auto display = tabWidget->currentIndex();
947 msgFilters_[display].sevThresh = SINFO;
948 btnError->setChecked(
false);
949 btnWarning->setChecked(
false);
950 btnInfo->setChecked(
true);
951 btnDebug->setChecked(
false);
952 vsSeverity->setValue(SINFO);
955 void msgViewerDlg::setSevDebug()
957 auto display = tabWidget->currentIndex();
958 msgFilters_[display].sevThresh = SDEBUG;
959 btnError->setChecked(
false);
960 btnWarning->setChecked(
false);
961 btnInfo->setChecked(
false);
962 btnDebug->setChecked(
true);
963 vsSeverity->setValue(SDEBUG);
966 void msgViewerDlg::renderMode()
968 simpleRender = !simpleRender;
972 btnRMode->setChecked(
true);
973 for (
auto display : msgFilters_)
975 display.txtDisplay->setPlainText(display.txtDisplay->toPlainText());
980 btnRMode->setChecked(
false);
985 void msgViewerDlg::searchMsg()
987 QString search = editSearch->text();
989 if (search.isEmpty())
return;
991 auto display = tabWidget->currentIndex();
992 if (search != searchStr)
994 msgFilters_[display].txtDisplay->moveCursor(QTextCursor::Start);
995 if (!msgFilters_[display].txtDisplay->find(search))
997 msgFilters_[display].txtDisplay->moveCursor(QTextCursor::End);
1005 if (!msgFilters_[display].txtDisplay->find(search))
1007 msgFilters_[display].txtDisplay->moveCursor(QTextCursor::Start);
1008 if (!msgFilters_[display].txtDisplay->find(search))
1010 msgFilters_[display].txtDisplay->moveCursor(QTextCursor::End);
1017 void msgViewerDlg::searchClear()
1019 auto display = tabWidget->currentIndex();
1020 editSearch->setText(
"");
1022 msgFilters_[display].txtDisplay->find(
"");
1023 msgFilters_[display].txtDisplay->moveCursor(QTextCursor::End);
1026 void msgViewerDlg::setSuppression(QAction* act)
1028 bool status = act->isChecked();
1029 auto sup =
static_cast<suppress*
>(act->data().value<
void*>());
1033 void msgViewerDlg::setThrottling(QAction* act)
1035 bool status = act->isChecked();
1036 auto thr =
static_cast<throttle*
>(act->data().value<
void*>());
1040 void msgViewerDlg::tabWidgetCurrentChanged(
int newTab)
1042 displayMsgs(newTab);
1043 lcdDisplayedMsgs->display(msgFilters_[newTab].nDisplayMsgs);
1045 lwHost->setCurrentRow(-1, QItemSelectionModel::Clear);
1046 lwApplication->setCurrentRow(-1, QItemSelectionModel::Clear);
1047 lwCategory->setCurrentRow(-1, QItemSelectionModel::Clear);
1049 for (
auto const& host : msgFilters_[newTab].hostFilter)
1051 auto items = lwHost->findItems(host, Qt::MatchExactly);
1054 items[0]->setSelected(
true);
1057 for (
auto const& app : msgFilters_[newTab].appFilter)
1059 auto items = lwApplication->findItems(app, Qt::MatchExactly);
1062 items[0]->setSelected(
true);
1065 for (
auto const& cat : msgFilters_[newTab].catFilter)
1067 auto items = lwCategory->findItems(cat, Qt::MatchExactly);
1070 items[0]->setSelected(
true);
1074 switch (msgFilters_[newTab].sevThresh)
1091 void msgViewerDlg::tabCloseRequested(
int tabIndex)
1093 if (tabIndex == 0 || static_cast<size_t>(tabIndex) >= msgFilters_.size())
return;
1095 auto widget = tabWidget->widget(tabIndex);
1096 tabWidget->removeTab(tabIndex);
1099 msgFilters_.erase(msgFilters_.begin() + tabIndex);
1104 QStringList msgViewerDlg::toQStringList(QList<QListWidgetItem*> in)
1108 for (
auto i = 0; i < in.size(); ++i)
1110 out << in[i]->text();
void use(bool flag)
Enable or disable this throttle
void exit()
Exit the program.
void start()
Start all receivers
Suppress messages based on a regular expression
void clear()
Clear the message buffer.
void use(bool flag)
Set whether the suppression is active
Throttle messages based on name and time limits. Separate from MessageFacility limiting.
msgViewerDlg(std::string const &conf, QDialog *parent=nullptr)
Message Viewer Dialog Constructor.
void stop()
Stop all receivers
void pause()
Pause message receiving.
void changeSeverity(int sev)
Change the severity threshold.
void shortMode()
Switch to/from Short message mode.
void closeEvent(QCloseEvent *event)
Perform actions on window close.