3 #include <QProgressDialog>
7 #include "cetlib/filepath_maker.h"
8 #include "fhiclcpp/ParameterSet.h"
9 #include "mfextensions/Binaries/MakeParameterSet.hh"
11 #include "mfextensions/Binaries/mvdlg.hh"
13 #if GCC_VERSION >= 701000 || defined(__clang__)
14 #pragma GCC diagnostic push
15 #pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
18 #define TRACE_NAME "MessageViewer"
21 #if GCC_VERSION >= 701000 || defined(__clang__)
22 #pragma GCC diagnostic pop
29 static void process_fname(std::string& fname)
31 size_t sub_start = fname.find(
"${");
32 size_t sub_end = fname.find(
"}");
34 const size_t npos = std::string::npos;
36 if ((sub_start == npos && sub_end != npos) || (sub_start != npos && sub_end == npos) || (sub_start > sub_end))
38 throw std::runtime_error(
"Unrecognized configuration file. Use default configuration instead.");
41 if (sub_start == npos)
return;
43 std::string env = std::string(getenv(fname.substr(sub_start + 2, sub_end - sub_start - 2).c_str()));
44 fname.replace(sub_start, sub_end - sub_start + 1, env);
49 static fhicl::ParameterSet readConf(std::string
const& fname)
51 if (fname.empty())
return fhicl::ParameterSet();
53 std::string filename = fname;
54 process_fname(filename);
56 std::string env(
"FHICL_FILE_PATH=");
58 if (filename[0] ==
'/')
67 char* mfe_path = getenv(
"MFEXTENSIONS_DIR");
68 if (mfe_path) env.append(
":").append(mfe_path).append(
"/config");
76 cet::filepath_lookup policy(
"FHICL_FILE_PATH");
79 fhicl::ParameterSet pset = artdaq::make_pset(filename, policy);
85 : 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()))
93 fhicl::ParameterSet pset = readConf(conf);
99 btnSuppression->setMenu(sup_menu);
100 btnThrottling->setMenu(thr_menu);
103 connect(btnPause, SIGNAL(clicked()),
this, SLOT(
pause()));
104 connect(btnScrollToBottom, SIGNAL(clicked()),
this, SLOT(scrollToBottom()));
105 connect(btnExit, SIGNAL(clicked()),
this, SLOT(
exit()));
106 connect(btnClear, SIGNAL(clicked()),
this, SLOT(
clear()));
108 connect(btnRMode, SIGNAL(clicked()),
this, SLOT(renderMode()));
109 connect(btnDisplayMode, SIGNAL(clicked()),
this, SLOT(
shortMode()));
111 connect(btnSearch, SIGNAL(clicked()),
this, SLOT(searchMsg()));
112 connect(btnSearchClear, SIGNAL(clicked()),
this, SLOT(searchClear()));
114 connect(btnFilter, SIGNAL(clicked()),
this, SLOT(setFilter()));
116 connect(btnError, SIGNAL(clicked()),
this, SLOT(setSevError()));
117 connect(btnWarning, SIGNAL(clicked()),
this, SLOT(setSevWarning()));
118 connect(btnInfo, SIGNAL(clicked()),
this, SLOT(setSevInfo()));
119 connect(btnDebug, SIGNAL(clicked()),
this, SLOT(setSevDebug()));
121 connect(sup_menu, SIGNAL(triggered(QAction*)),
this, SLOT(setSuppression(QAction*)));
123 connect(thr_menu, SIGNAL(triggered(QAction*)),
this, SLOT(setThrottling(QAction*)));
125 connect(vsSeverity, SIGNAL(valueChanged(
int)),
this, SLOT(
changeSeverity(
int)));
127 connect(&receivers_, SIGNAL(newMessage(msg_ptr_t)),
this, SLOT(onNewMsg(msg_ptr_t)));
129 connect(tabWidget, SIGNAL(currentChanged(
int)),
this, SLOT(tabWidgetCurrentChanged(
int)));
130 connect(tabWidget, SIGNAL(tabCloseRequested(
int)),
this, SLOT(tabCloseRequested(
int)));
131 MsgFilterDisplay allMessages;
132 allMessages.txtDisplay = txtMessages;
133 allMessages.nDisplayMsgs = 0;
134 allMessages.filterExpression =
"";
135 allMessages.nDisplayedDeletedMsgs = 0;
136 allMessages.sevThresh = SINFO;
137 msgFilters_.push_back(allMessages);
140 auto tabBar = tabWidget->findChild<QTabBar*>();
141 tabBar->setTabButton(0, QTabBar::RightSide,
nullptr);
142 tabBar->setTabButton(0, QTabBar::LeftSide,
nullptr);
145 btnRMode->setChecked(
true);
147 btnRMode->setChecked(
false);
149 btnRMode->setEnabled(
false);
153 auto doc =
new QTextDocument(txtMessages);
154 txtMessages->setDocument(doc);
159 msgViewerDlg::~msgViewerDlg()
165 static void str_to_suppress(std::vector<std::string>
const& vs, std::vector<suppress>& s, QMenu* menu)
171 act = menu->addAction(
"None");
172 act->setEnabled(
false);
176 s.reserve(vs.size());
178 for (
size_t i = 0; i < vs.size(); ++i)
180 s.emplace_back(vs[i]);
181 act = menu->addAction(QString(vs[i].c_str()));
182 act->setCheckable(
true);
183 act->setChecked(
true);
184 QVariant v = qVariantFromValue(static_cast<void*>(&s[i]));
189 static void pset_to_throttle(std::vector<fhicl::ParameterSet>
const& ps, std::vector<throttle>& t, QMenu* menu)
195 act = menu->addAction(
"None");
196 act->setEnabled(
false);
200 t.reserve(ps.size());
202 for (
size_t i = 0; i < ps.size(); ++i)
204 auto name = ps[i].get<std::string>(
"name");
205 t.emplace_back(name, ps[i].get<int>(
"limit", -1), ps[i].get<int64_t>(
"timespan", -1));
206 act = menu->addAction(QString(name.c_str()));
207 act->setCheckable(
true);
208 act->setChecked(
true);
209 QVariant v = qVariantFromValue(static_cast<void*>(&t[i]));
214 void msgViewerDlg::parseConf(fhicl::ParameterSet
const& conf)
216 fhicl::ParameterSet nulp;
220 auto sup = conf.get<fhicl::ParameterSet>(
"suppress", nulp);
222 auto sup_host = sup.get<std::vector<std::string>>(
"hosts", std::vector<std::string>());
223 auto sup_app = sup.get<std::vector<std::string>>(
"applications", std::vector<std::string>());
224 auto sup_cat = sup.get<std::vector<std::string>>(
"categories", std::vector<std::string>());
226 str_to_suppress(sup_host, e_sup_host, sup_menu);
227 sup_menu->addSeparator();
229 str_to_suppress(sup_app, e_sup_app, sup_menu);
230 sup_menu->addSeparator();
232 str_to_suppress(sup_cat, e_sup_cat, sup_menu);
235 auto thr = conf.get<fhicl::ParameterSet>(
"throttle", nulp);
237 auto thr_host = thr.get<std::vector<fhicl::ParameterSet>>(
"hosts", std::vector<fhicl::ParameterSet>());
238 auto thr_app = thr.get<std::vector<fhicl::ParameterSet>>(
"applications", std::vector<fhicl::ParameterSet>());
239 auto thr_cat = thr.get<std::vector<fhicl::ParameterSet>>(
"categories", std::vector<fhicl::ParameterSet>());
241 pset_to_throttle(thr_host, e_thr_host, thr_menu);
242 thr_menu->addSeparator();
244 pset_to_throttle(thr_app, e_thr_app, thr_menu);
245 thr_menu->addSeparator();
247 pset_to_throttle(thr_cat, e_thr_cat, thr_menu);
249 maxMsgs = conf.get<
size_t>(
"max_message_buffer_size", 100000);
250 maxDeletedMsgs = conf.get<
size_t>(
"max_displayed_deleted_messages", 100000);
253 bool msgViewerDlg::msg_throttled(msg_ptr_t
const& msg)
259 for (
size_t i = 0; i < e_sup_host.size(); ++i)
260 if (e_sup_host[i].match(msg->host().toStdString()))
return true;
262 for (
size_t i = 0; i < e_sup_app.size(); ++i)
263 if (e_sup_app[i].match(msg->app().toStdString()))
return true;
265 for (
size_t i = 0; i < e_sup_cat.size(); ++i)
266 if (e_sup_cat[i].match(msg->cat().toStdString()))
return true;
274 for (
size_t i = 0; i < e_thr_host.size(); ++i)
275 if (e_thr_host[i].reach_limit(msg->host().toStdString(), msg->time()))
return true;
277 for (
size_t i = 0; i < e_thr_app.size(); ++i)
278 if (e_thr_app[i].reach_limit(msg->app().toStdString(), msg->time()))
return true;
280 for (
size_t i = 0; i < e_thr_cat.size(); ++i)
281 if (e_thr_cat[i].reach_limit(msg->cat().toStdString(), msg->time()))
return true;
288 void msgViewerDlg::writeSettings()
290 QSettings settings(
"ARTDAQ",
"MsgViewer");
292 settings.beginGroup(
"MainWindow");
293 settings.setValue(
"size", size());
294 settings.setValue(
"pos", pos());
298 void msgViewerDlg::readSettings()
300 QSettings settings(
"ARTDAQ",
"MsgViewer");
302 settings.beginGroup(
"MainWindow");
303 QPoint pos = settings.value(
"pos", QPoint(100, 100)).toPoint();
304 QSize size = settings.value(
"size", QSize(660, 760)).toSize();
310 void msgViewerDlg::onNewMsg(msg_ptr_t
const& msg)
317 lcdMsgs->display(nMsgs);
320 if (msg_throttled(msg))
322 lcdSuppressionCount->display(nSupMsgs);
323 lcdThrottlingCount->display(nThrMsgs);
330 msg_pool_.emplace_back(msg);
338 for (
size_t d = 0; d < msgFilters_.size(); ++d)
341 msgFilters_[d].hostFilter.contains(msg->host(), Qt::CaseInsensitive) || msgFilters_[d].hostFilter.empty();
343 msgFilters_[d].appFilter.contains(msg->app(), Qt::CaseInsensitive) || msgFilters_[d].appFilter.empty();
345 msgFilters_[d].catFilter.contains(msg->cat(), Qt::CaseInsensitive) || msgFilters_[d].catFilter.empty();
348 if (hostMatch && appMatch && catMatch)
352 msgFilters_[d].msgs.push_back(msg);
354 if ((
int)d == tabWidget->currentIndex())
360 void msgViewerDlg::trim_msg_pool()
362 bool host_list_update =
false;
363 bool app_list_update =
false;
364 bool cat_list_update =
false;
366 std::lock_guard<std::mutex> lk(msg_pool_mutex_);
367 while (maxMsgs > 0 && msg_pool_.size() > maxMsgs)
369 QString
const& app = msg_pool_.front()->app();
370 QString
const& cat = msg_pool_.front()->cat();
371 QString
const& host = msg_pool_.front()->host();
375 auto catIter = std::find(cat_msgs_[cat].begin(), cat_msgs_[cat].end(), msg_pool_.front());
376 auto hostIter = std::find(host_msgs_[host].begin(), host_msgs_[host].end(), msg_pool_.front());
377 auto appIter = std::find(app_msgs_[app].begin(), app_msgs_[app].end(), msg_pool_.front());
378 if (catIter != cat_msgs_[cat].end()) cat_msgs_[cat].erase(catIter);
379 if (hostIter != host_msgs_[host].end()) host_msgs_[host].erase(hostIter);
380 if (appIter != app_msgs_[app].end()) app_msgs_[app].erase(appIter);
382 if (app_msgs_[app].empty())
384 app_msgs_.erase(app);
385 app_list_update =
true;
387 if (cat_msgs_[cat].empty())
389 cat_msgs_.erase(cat);
390 cat_list_update =
true;
392 if (host_msgs_[host].empty())
394 host_msgs_.erase(host);
395 host_list_update =
true;
400 msg_pool_.erase(msg_pool_.begin());
405 std::lock_guard<std::mutex> lk(msg_classification_mutex_);
406 if (host_list_update)
407 updateList(lwHost, host_msgs_);
409 updateList(lwApplication, app_msgs_);
411 updateList(lwCategory, cat_msgs_);
414 for (
size_t d = 0; d < msgFilters_.size(); ++d)
417 std::lock_guard<std::mutex> lk(filter_mutex_);
418 while (msgFilters_[d].msgs.size() > maxMsgs)
420 if ((*msgFilters_[d].msgs.begin())->sev() >= msgFilters_[d].sevThresh)
421 msgFilters_[d].nDisplayedDeletedMsgs++;
422 msgFilters_[d].msgs.erase(msgFilters_[d].msgs.begin());
426 if ((
int)d == tabWidget->currentIndex())
428 if (maxDeletedMsgs > 0 && msgFilters_[d].nDisplayedDeletedMsgs > static_cast<int>(maxDeletedMsgs))
432 lcdDisplayedDeleted->display(msgFilters_[d].nDisplayedDeletedMsgs);
436 lcdDeletedCount->display(nDeleted);
439 void msgViewerDlg::update_index(msg_ptr_t
const& it)
441 std::lock_guard<std::mutex> lk(msg_classification_mutex_);
442 QString
const& app = it->app();
443 QString
const& cat = it->cat();
444 QString
const& host = it->host();
446 if (cat_msgs_.find(cat) == cat_msgs_.end())
448 cat_msgs_[cat].push_back(it);
449 updateList(lwCategory, cat_msgs_);
453 cat_msgs_[cat].push_back(it);
456 if (host_msgs_.find(host) == host_msgs_.end())
458 host_msgs_[host].push_back(it);
459 updateList(lwHost, host_msgs_);
463 host_msgs_[host].push_back(it);
466 if (app_msgs_.find(app) == app_msgs_.end())
468 app_msgs_[app].push_back(it);
469 updateList(lwApplication, app_msgs_);
473 app_msgs_[app].push_back(it);
477 void msgViewerDlg::displayMsg(msg_ptr_t
const& it,
int display)
479 if (it->sev() < msgFilters_[display].sevThresh)
return;
481 msgFilters_[display].nDisplayMsgs++;
482 if (display == tabWidget->currentIndex())
484 lcdDisplayedMsgs->display(msgFilters_[display].nDisplayMsgs);
487 auto txt = it->text(shortMode_);
490 UpdateTextAreaDisplay(txts, msgFilters_[display].txtDisplay);
493 void msgViewerDlg::displayMsgs(
int display)
495 msgFilters_[display].txtDisplay->clear();
496 msgFilters_[display].nDisplayMsgs = 0;
497 msgFilters_[display].nDisplayedDeletedMsgs = 0;
501 std::lock_guard<std::mutex> lk(filter_mutex_);
502 for (
auto it = msgFilters_[display].msgs.begin(); it != msgFilters_[display].msgs.end(); ++it)
504 if ((*it)->sev() >= msgFilters_[display].sevThresh)
506 txts.push_back((*it)->text(shortMode_));
507 ++msgFilters_[display].nDisplayMsgs;
511 if (display == tabWidget->currentIndex())
513 lcdDisplayedMsgs->display(msgFilters_[display].nDisplayMsgs);
515 UpdateTextAreaDisplay(txts, msgFilters_[display].txtDisplay);
519 void msgViewerDlg::UpdateTextAreaDisplay(QStringList
const& texts, QPlainTextEdit* widget)
521 const QTextCursor old_cursor = widget->textCursor();
522 const int old_scrollbar_value = widget->verticalScrollBar()->value();
523 const bool is_scrolled_down =
524 old_scrollbar_value >= widget->verticalScrollBar()->maximum() * 0.95;
526 if (!paused && !is_scrolled_down)
531 QTextCursor new_cursor = QTextCursor(widget->document());
533 new_cursor.beginEditBlock();
534 new_cursor.movePosition(QTextCursor::End);
536 for (
int i = 0; i < texts.size(); i++)
538 new_cursor.insertBlock();
539 new_cursor.insertHtml(texts.at(i));
540 if (!shortMode_) new_cursor.insertBlock();
542 new_cursor.endEditBlock();
544 if (old_cursor.hasSelection() || paused)
547 widget->setTextCursor(old_cursor);
548 widget->verticalScrollBar()->setValue(old_scrollbar_value);
553 widget->moveCursor(QTextCursor::End);
554 widget->verticalScrollBar()->setValue(widget->verticalScrollBar()->maximum());
555 widget->horizontalScrollBar()->setValue(0);
559 void msgViewerDlg::scrollToBottom()
561 int display = tabWidget->currentIndex();
562 msgFilters_[display].txtDisplay->moveCursor(QTextCursor::End);
563 msgFilters_[display].txtDisplay->verticalScrollBar()->setValue(
564 msgFilters_[display].txtDisplay->verticalScrollBar()->maximum());
565 msgFilters_[display].txtDisplay->horizontalScrollBar()->setValue(0);
568 void msgViewerDlg::updateDisplays()
570 for (
size_t ii = 0; ii < msgFilters_.size(); ++ii)
576 bool msgViewerDlg::updateList(QListWidget* lw, msgs_map_t
const& map)
578 bool nonSelectedBefore = (lw->currentRow() == -1);
579 bool nonSelectedAfter =
true;
581 QString item = nonSelectedBefore ?
"" : lw->currentItem()->text();
585 auto it = map.begin();
587 while (it != map.end())
589 lw->addItem(it->first);
590 if (!nonSelectedBefore && nonSelectedAfter)
592 if (item == it->first)
594 lw->setCurrentRow(row);
595 nonSelectedAfter =
false;
602 if (!nonSelectedBefore && nonSelectedAfter)
return true;
607 msgs_t msgViewerDlg::list_intersect(msgs_t
const& l1, msgs_t
const& l2)
610 auto it1 = l1.begin();
611 auto it2 = l2.begin();
613 while (it1 != l1.end() && it2 != l2.end())
619 else if (*it2 < *it1)
625 output.push_back(*it1);
631 TLOG(TLVL_DEBUG + 35) <<
"list_intersect: output list has " << output.size() <<
" entries";
635 std::string sev_to_string(sev_code_t s)
651 void msgViewerDlg::setFilter()
653 auto hostFilter = toQStringList(lwHost->selectedItems());
654 auto appFilter = toQStringList(lwApplication->selectedItems());
655 auto catFilter = toQStringList(lwCategory->selectedItems());
657 lwHost->setCurrentRow(-1, QItemSelectionModel::Clear);
658 lwApplication->setCurrentRow(-1, QItemSelectionModel::Clear);
659 lwCategory->setCurrentRow(-1, QItemSelectionModel::Clear);
661 if (hostFilter.isEmpty() && appFilter.isEmpty() && catFilter.isEmpty())
667 QString catFilterExpression =
"";
668 QString hostFilterExpression =
"";
669 QString appFilterExpression =
"";
672 for (
auto app = 0; app < appFilter.size(); ++app)
674 appFilterExpression += QString(first ?
"" :
" || ") + appFilter[app];
677 TLOG(TLVL_DEBUG + 35) <<
"setFilter: result contains %zu messages", result.size();
680 if (!hostFilter.isEmpty())
683 for (
auto host = 0; host < hostFilter.size(); ++host)
685 hostFilterExpression += QString(first ?
"" :
" || ") + hostFilter[host];
691 if (!catFilter.isEmpty())
694 for (
auto cat = 0; cat < catFilter.size(); ++cat)
696 catFilterExpression += QString(first ?
"" :
" || ") + catFilter[cat];
702 auto nFilterExpressions =
703 (appFilterExpression !=
"" ? 1 : 0) + (hostFilterExpression !=
"" ? 1 : 0) + (catFilterExpression !=
"" ? 1 : 0);
704 QString filterExpression =
"";
705 if (nFilterExpressions == 1)
707 filterExpression = catFilterExpression + hostFilterExpression + appFilterExpression;
711 filterExpression =
"(" + (catFilterExpression !=
"" ? catFilterExpression +
") && (" :
"") + hostFilterExpression +
712 (hostFilterExpression !=
"" && appFilterExpression !=
"" ?
") && (" :
"") + appFilterExpression +
716 for (
size_t d = 0; d < msgFilters_.size(); ++d)
718 if (msgFilters_[d].filterExpression == filterExpression)
720 tabWidget->setCurrentIndex(d);
726 std::lock_guard<std::mutex> lk(msg_classification_mutex_);
727 for (
auto app = 0; app < appFilter.size(); ++app)
729 auto it = app_msgs_.find(appFilter[app]);
730 if (it != app_msgs_.end())
732 msgs_t temp(it->second);
733 TLOG(TLVL_DEBUG + 35) <<
"setFilter: app " << appFilter[app].toStdString() <<
" has " << temp.size() <<
" messages";
737 TLOG(TLVL_DEBUG + 35) <<
"setFilter: result contains %zu messages", result.size();
739 if (!hostFilter.isEmpty())
742 for (
auto host = 0; host < hostFilter.size(); ++host)
744 auto it = host_msgs_.find(hostFilter[host]);
745 if (it != host_msgs_.end())
747 msgs_t temp(it->second);
748 TLOG(TLVL_DEBUG + 35) <<
"setFilter: host " << hostFilter[host].toStdString() <<
" has " << temp.size() <<
" messages";
749 hostResult.merge(temp);
758 result = list_intersect(result, hostResult);
760 TLOG(TLVL_DEBUG + 35) <<
"setFilter: result contains " << result.size() <<
" messages";
763 if (!catFilter.isEmpty())
766 for (
auto cat = 0; cat < catFilter.size(); ++cat)
768 auto it = cat_msgs_.find(catFilter[cat]);
769 if (it != cat_msgs_.end())
771 msgs_t temp(it->second);
772 TLOG(TLVL_DEBUG + 35) <<
"setFilter: cat " << catFilter[cat].toStdString() <<
" has " << temp.size() <<
" messages";
773 catResult.merge(temp);
782 result = list_intersect(result, catResult);
784 TLOG(TLVL_DEBUG + 35) <<
"setFilter: result contains " << result.size() <<
" messages";
790 auto newTabTitle = QString(
"Filter ") + QString::number(++nFilters);
791 auto newTab =
new QWidget();
793 auto txtDisplay =
new QPlainTextEdit(newTab);
794 auto doc =
new QTextDocument(txtDisplay);
795 txtDisplay->setDocument(doc);
797 auto layout =
new QVBoxLayout();
798 layout->addWidget(txtDisplay);
799 layout->setContentsMargins(0, 0, 0, 0);
800 newTab->setLayout(layout);
802 MsgFilterDisplay filteredMessages;
803 filteredMessages.msgs = result;
804 filteredMessages.hostFilter = hostFilter;
805 filteredMessages.appFilter = appFilter;
806 filteredMessages.catFilter = catFilter;
807 filteredMessages.filterExpression = filterExpression;
808 filteredMessages.txtDisplay = txtDisplay;
809 filteredMessages.nDisplayMsgs = result.size();
810 filteredMessages.nDisplayedDeletedMsgs = 0;
811 filteredMessages.sevThresh = SINFO;
813 std::lock_guard<std::mutex> lk(filter_mutex_);
814 msgFilters_.push_back(filteredMessages);
816 tabWidget->addTab(newTab, newTabTitle);
817 tabWidget->setTabToolTip(tabWidget->count() - 1, filterExpression);
818 tabWidget->setCurrentIndex(tabWidget->count() - 1);
820 displayMsgs(msgFilters_.size() - 1);
828 btnPause->setText(
"Resume Scrolling");
834 btnPause->setText(
"Pause Scrolling");
844 QMessageBox::question(
this, tr(
"Message Viewer"), tr(
"Are you sure you want to clear all received messages?"),
845 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
848 case QMessageBox::Yes:
854 std::lock_guard<std::mutex> lk(msg_pool_mutex_);
858 std::lock_guard<std::mutex> lk(msg_classification_mutex_);
862 updateList(lwApplication, app_msgs_);
863 updateList(lwCategory, cat_msgs_);
864 updateList(lwHost, host_msgs_);
866 for (
auto& display : msgFilters_)
868 std::lock_guard<std::mutex> lk(filter_mutex_);
869 display.txtDisplay->clear();
870 display.msgs.clear();
871 display.nDisplayMsgs = 0;
872 display.nDisplayedDeletedMsgs = 0;
875 lcdMsgs->display(nMsgs);
876 lcdDisplayedMsgs->display(0);
878 case QMessageBox::No:
889 btnDisplayMode->setText(
"Long View");
894 btnDisplayMode->setText(
"Compact View");
901 auto display = tabWidget->currentIndex();
920 displayMsgs(display);
923 void msgViewerDlg::setSevError()
925 auto display = tabWidget->currentIndex();
926 msgFilters_[display].sevThresh = SERROR;
927 btnError->setChecked(
true);
928 btnWarning->setChecked(
false);
929 btnInfo->setChecked(
false);
930 btnDebug->setChecked(
false);
931 vsSeverity->setValue(SERROR);
934 void msgViewerDlg::setSevWarning()
936 auto display = tabWidget->currentIndex();
937 msgFilters_[display].sevThresh = SWARNING;
938 btnError->setChecked(
false);
939 btnWarning->setChecked(
true);
940 btnInfo->setChecked(
false);
941 btnDebug->setChecked(
false);
942 vsSeverity->setValue(SWARNING);
945 void msgViewerDlg::setSevInfo()
947 auto display = tabWidget->currentIndex();
948 msgFilters_[display].sevThresh = SINFO;
949 btnError->setChecked(
false);
950 btnWarning->setChecked(
false);
951 btnInfo->setChecked(
true);
952 btnDebug->setChecked(
false);
953 vsSeverity->setValue(SINFO);
956 void msgViewerDlg::setSevDebug()
958 auto display = tabWidget->currentIndex();
959 msgFilters_[display].sevThresh = SDEBUG;
960 btnError->setChecked(
false);
961 btnWarning->setChecked(
false);
962 btnInfo->setChecked(
false);
963 btnDebug->setChecked(
true);
964 vsSeverity->setValue(SDEBUG);
967 void msgViewerDlg::renderMode()
969 simpleRender = !simpleRender;
973 btnRMode->setChecked(
true);
974 for (
auto display : msgFilters_)
976 display.txtDisplay->setPlainText(display.txtDisplay->toPlainText());
981 btnRMode->setChecked(
false);
986 void msgViewerDlg::searchMsg()
988 QString search = editSearch->text();
990 if (search.isEmpty())
return;
992 auto display = tabWidget->currentIndex();
993 if (search != searchStr)
995 msgFilters_[display].txtDisplay->moveCursor(QTextCursor::Start);
996 if (!msgFilters_[display].txtDisplay->find(search))
998 msgFilters_[display].txtDisplay->moveCursor(QTextCursor::End);
1006 if (!msgFilters_[display].txtDisplay->find(search))
1008 msgFilters_[display].txtDisplay->moveCursor(QTextCursor::Start);
1009 if (!msgFilters_[display].txtDisplay->find(search))
1011 msgFilters_[display].txtDisplay->moveCursor(QTextCursor::End);
1018 void msgViewerDlg::searchClear()
1020 auto display = tabWidget->currentIndex();
1021 editSearch->setText(
"");
1023 msgFilters_[display].txtDisplay->find(
"");
1024 msgFilters_[display].txtDisplay->moveCursor(QTextCursor::End);
1027 void msgViewerDlg::setSuppression(QAction* act)
1029 bool status = act->isChecked();
1030 auto sup =
static_cast<suppress*
>(act->data().value<
void*>());
1034 void msgViewerDlg::setThrottling(QAction* act)
1036 bool status = act->isChecked();
1037 auto thr =
static_cast<throttle*
>(act->data().value<
void*>());
1041 void msgViewerDlg::tabWidgetCurrentChanged(
int newTab)
1043 displayMsgs(newTab);
1044 lcdDisplayedMsgs->display(msgFilters_[newTab].nDisplayMsgs);
1046 lwHost->setCurrentRow(-1, QItemSelectionModel::Clear);
1047 lwApplication->setCurrentRow(-1, QItemSelectionModel::Clear);
1048 lwCategory->setCurrentRow(-1, QItemSelectionModel::Clear);
1050 for (
auto const& host : msgFilters_[newTab].hostFilter)
1052 auto items = lwHost->findItems(host, Qt::MatchExactly);
1055 items[0]->setSelected(
true);
1058 for (
auto const& app : msgFilters_[newTab].appFilter)
1060 auto items = lwApplication->findItems(app, Qt::MatchExactly);
1063 items[0]->setSelected(
true);
1066 for (
auto const& cat : msgFilters_[newTab].catFilter)
1068 auto items = lwCategory->findItems(cat, Qt::MatchExactly);
1071 items[0]->setSelected(
true);
1075 switch (msgFilters_[newTab].sevThresh)
1092 void msgViewerDlg::tabCloseRequested(
int tabIndex)
1094 if (tabIndex == 0 || static_cast<size_t>(tabIndex) >= msgFilters_.size())
return;
1096 auto widget = tabWidget->widget(tabIndex);
1097 tabWidget->removeTab(tabIndex);
1100 msgFilters_.erase(msgFilters_.begin() + tabIndex);
1105 QStringList msgViewerDlg::toQStringList(QList<QListWidgetItem*> in)
1109 for (
auto i = 0; i < in.size(); ++i)
1111 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.